def __init__(self, lsysargv, sysargv): self.rgbdb = [{'r':0, 'g':0, 'b':0}] * MAX_RGB self.pcl = None self.pdbobj = None self.prescol = None self.pcolbr = None self.prs = None self.pgs = None self.pbs = None self.dbname = "" if os.path.exists(rgbfile): self.dbname = rgbfile elif os.path.exists(rgbfile_2): self.dbname = rgbfile_2 xfl.fl_initialize(lsysargv, sysargv, "FormDemo", None, 0) self.create_form_cl() if self.load_browser(self.dbname): xfl.fl_set_object_label(self.pdbobj, self.dbname) else: xfl.fl_set_object_label(self.pdbobj, "None") xfl.fl_set_form_minsize(self.pcl, self.pcl.contents.w , \ self.pcl.contents.h) xfl.fl_set_form_maxsize(self.pcl, 2 * self.pcl.contents.w , \ 2 * self.pcl.contents.h) xfl.fl_show_form(self.pcl, xfl.FL_PLACE_FREE, xfl.FL_TRANSIENT, \ "RGB Browser") xfl.fl_do_forms() sys.exit(0)
def deactivate_cb(self, pobj, data): if xfl.fl_object_is_active(self.fd_scb.hor_thin): xfl.fl_set_object_label(self.fd_scb.deactivate, "Activate") xfl.fl_deactivate_object(self.fd_scb.hor_thin) else: xfl.fl_set_object_label(self.fd_scb.deactivate, "Deactivate") xfl.fl_activate_object(self.fd_scb.hor_thin)
def start_timer(self, pobj, data): self.fdform0.ldata += 200.0 numldata = self.fdform0.ldata / 1000 buf = "Timer accuracy testing %.3f sec ..." % numldata xfl.fl_set_object_label(self.fdform0.report, buf) self.start_sec, self.start_usec = xfl.fl_gettime() xfl.fl_set_timer(self.fdform0.timer, numldata)
def hide_it(self, pobj, alln): if xfl.fl_object_is_visible(self.fd_canvasform.canvas): xfl.fl_hide_object(self.fd_canvasform.canvas) xfl.fl_set_object_label(pobj, "ShowCanvas") else: xfl.fl_show_object(self.fd_canvasform.canvas) xfl.fl_set_object_label(pobj, "HideCanvas")
def deactivate_cb(self, pobj, data): if xfl.fl_object_is_active(self.fd_mainform.folder): xfl.fl_set_object_label(pobj, "Activate") xfl.fl_deactivate_object(self.fd_mainform.folder) else: xfl.fl_set_object_label(pobj, "Deactivate") xfl.fl_activate_object(self.fd_mainform.folder)
def hide_cb(self, pobj, data): if xfl.fl_object_is_visible(self.fd_scb.hor_thin): xfl.fl_set_object_label(self.fd_scb.hide, "Show") xfl.fl_hide_object(self.fd_scb.hor_thin) else: xfl.fl_set_object_label(self.fd_scb.hide, "Hide") xfl.fl_show_object(self.fd_scb.hor_thin)
def cb(self, pobj, data): self.cols[data] = xfl.fl_get_dial_value(pobj) xfl.fl_mapcolor(xfl.FL_FREE_COL1, self.cols[0], self.cols[1], \ self.cols[2]) xfl.fl_redraw_object(self.presult) strng = "%d" % self.cols[data] xfl.fl_set_object_label(self.ptexts[data], strng)
def dial_callback(self, pobj, arg): clr = [0, 1, 2] for i in range(RED, BLUE + 1): clr[i] = xfl.fl_get_dial_value(self.pdial[i]) strng = "%d" % clr[arg] xfl.fl_set_object_label(self.ptext[arg], strng) xfl.fl_mapcolor(xfl.FL_FREE_COL1, clr[0], clr[1], clr[2]) xfl.fl_redraw_object(self.presult)
def xyplot_cb(pobj, data): x, y, i = xfl.fl_get_xyplot(pobj) if i < 0: return buf = "X=%.3f Y=%.3f" % (x, y) xfl.fl_set_object_label(xypui.status, buf)
def db_cb(self, pobj, q): p = xfl.fl_show_input("Enter new database name", self.dbname) if not p or p == self.dbname: return buf = p if self.load_browser(buf): self.dbname = buf xfl.fl_set_object_label(pobj, self.dbname)
def timer_cb(self, idt, data): timerval = 1.0e-3 * self.fd_form.ldata self.fd_form.timer_id = 0 end_sec, end_usec = xfl.fl_gettime() df = end_sec - self.start_sec + 1.0e-6 * (end_usec - self.start_usec) buf = "Timeout: %.3f Actual: %.3f DeltaE: %.3f" % \ (timerval, df, df - timerval) xfl.fl_set_object_label(self.fd_form.report, buf)
def start_timer(self, pobj, data): if self.fd_form.timer_id: xfl.fl_remove_timeout(self.fd_form.timer_id) self.fd_form.ldata += 200 buf = "Timer accuracy testing %.3f sec ..." % \ float(self.fd_form.ldata * 0.001) xfl.fl_set_object_label(self.fd_form.report, buf) self.start_sec, self.start_usec = xfl.fl_gettime() self.fd_form.timer_id = xfl.fl_add_timeout(self.fd_form.ldata, \ self.timer_cb, 0)
def fill_browser(pobj): nfiles = 0 dl, nfiles = xfl.fl_get_dirlist( ".", "*", 0) xfl.fl_freeze_form(pobj.contents.form) buf = "Total %d files" % nfiles xfl.fl_set_object_label(fd_fbform.total, buf) xfl.fl_clear_browser(fd_fbform.browser) for ds in range(0, nfiles): buf = "%-10s\t%5ldK\t%s\n" % (dl[ds].name, \ dl[ds].dl_size >> 10, time.ctime(dl[ds].dl_mtime)) xfl.fl_addto_browser_chars(fd_fbform.browser, buf) xfl.fl_unfreeze_form(pobj.contents.form)
def __init__(self, lsysargv, sysargv): xfl.fl_initialize(lsysargv, sysargv, "FormDemo", None, 0) self.pform = xfl.fl_bgn_form(xfl.FL_UP_BOX, 400, 300) ppassword1 = xfl.fl_add_input(xfl.FL_SECRET_INPUT, 140, 40, \ 160, 40, "Password 1:") xfl.fl_set_object_return(ppassword1, xfl.FL_RETURN_CHANGED) ppassword2 = xfl.fl_add_input(xfl.FL_SECRET_INPUT, 140, 100, \ 160, 40, "Password 2:") xfl.fl_set_object_return(ppassword2, xfl.FL_RETURN_CHANGED) pinfo = xfl.fl_add_box(xfl.FL_SHADOW_BOX, 20, 160, 360, 40, "") pbut = xfl.fl_add_button(xfl.FL_NORMAL_BUTTON, 280, 240, \ 100, 40, "Quit") xfl.fl_end_form() xfl.fl_show_form(self.pform, xfl.FL_PLACE_MOUSE, \ xfl.FL_FULLBORDER, "Secret input demo") while not xfl.fl_is_same_object(xfl.fl_do_forms(), pbut): strng = "Password 1 is: %s , Password 2 is: %s" % \ (xfl.fl_get_input(ppassword1), \ xfl.fl_get_input(ppassword2)) xfl.fl_set_object_label(pinfo, strng) xfl.fl_finish() sys.exit(0)
def main(lsysargv, sysargv): xfl.fl_initialize(lsysargv, sysargv, "FormDemo", None, 0) pform = xfl.fl_bgn_form(xfl.FL_UP_BOX, 400, 300) pstrobj = xfl.fl_add_box(xfl.FL_DOWN_BOX, 10, 10, 380, 240, "Press Next") xfl.fl_set_object_lsize(pstrobj, xfl.FL_NORMAL_SIZE) pbut = xfl.fl_add_button(xfl.FL_NORMAL_BUTTON, 160, 260, 80, 30, "Next") xfl.fl_end_form() xfl.fl_set_form_hotobject(pform, pbut) xfl.fl_show_form(pform, xfl.FL_PLACE_HOTSPOT, xfl.FL_TRANSIENT, \ "longlabel") xfl.fl_do_forms() xfl.fl_set_object_label(pstrobj, label1) xfl.fl_do_forms() xfl.fl_set_object_label(pstrobj, label2) xfl.fl_do_forms() xfl.fl_set_object_label(pstrobj, "Now we turn to a short label") xfl.fl_do_forms() xfl.fl_set_object_label(pstrobj, label3) xfl.fl_set_object_label(pbut, "Quit") xfl.fl_do_forms() xfl.fl_finish() return 0
def ccb(self, pobj, data): button = xfl.fl_mouse_button() idx = xfl.fl_get_label_char_at_mouse(pobj) label = xfl.fl_get_object_label(pobj) if idx == -1: return digit = label[idx] # it's an int if button == xfl.FL_LEFT_MOUSE or button == xfl.FL_SCROLLUP_MOUSE: if digit == "9": digit = "0" else: digit = chr(ord(digit) + 1) elif button == xfl.FL_RIGHT_MOUSE or button == xfl.FL_SCROLLDOWN_MOUSE: if digit == "0": digit = "9" else: digit = chr(ord(digit) - 1) newstrng = list(label) newstrng[idx] = digit strng = "".join(newstrng) xfl.fl_set_object_label(pobj, strng)
def preemptive_handler(self, pobj, event, mx, my, key, xev): override = xfl.fl_get_button(self.fd_form0.override) if override: what = "preempted" else: what = "detected" if event == xfl.FL_ENTER: if xfl.fl_get_button(self.fd_form0.enter): buf = "%s %s" % ("FL_ENTER", what) xfl.fl_set_object_label(self.fd_form0.event, buf) if override: return xfl.FL_PREEMPT else: return 0 elif event == xfl.FL_LEAVE: if xfl.fl_get_button(self.fd_form0.leave): buf ="%s %s" % ("FL_LEAVE", what) xfl.fl_set_object_label(self.fd_form0.event, buf) if override: return xfl.FL_PREEMPT else: return 0 elif event == xfl.FL_PUSH or event == xfl.FL_MOTION: # one of the quirks of the button class if xfl.fl_get_button(self.fd_form0.push): buf = "%s %s" % ("FL_PUSH", what) xfl.fl_set_object_label(self.fd_form0.event, buf) if override: return xfl.FL_PREEMPT else: return 0 elif event == xfl.FL_RELEASE: if xfl.fl_get_button(self.fd_form0.release): buf = "%s %s" % ("FL_RELEASE", what) xfl.fl_set_object_label(self.fd_form0.event, buf) if override: return xfl.FL_PREEMPT else: return 0 return 0
def input_callback(self, pobj, data): buf = "Input%ld returned" % data xfl.fl_set_object_label(self.ui.status, buf) xfl.fl_XFlush() xfl.fl_msleep(50)
def peek_event(self, form, xev): if xev.contents.type == xfl.KeyPress: xfl.fl_set_object_label(self.ui.status, "keyboard input") xfl.fl_XFlush() # necessary to show the label xfl.fl_msleep(50) return 0
def positioner_cb(self, pobj, data): strng = "%f" % xfl.fl_get_positioner_xvalue(pobj) xfl.fl_set_object_label(self.pxval, strng) strng = "%f" % xfl.fl_get_positioner_yvalue(pobj) xfl.fl_set_object_label(self.pyval, strng)
def __init__(self, lsysargv, sysargv): strng = "" xfl.fl_initialize(lsysargv, sysargv, "FormDemo", None, 0) self.makeform() xfl.fl_show_form(self.pform, xfl.FL_PLACE_MOUSE, \ xfl.FL_TRANSIENT, "A Form") r = xfl.fl_get_dial_value(self.pred) + 0.001 g = xfl.fl_get_dial_value(self.pgreen) + 0.001 b = xfl.fl_get_dial_value(self.pblue) + 0.001 xfl.fl_freeze_form(self.pform) xfl.fl_mapcolor(xfl.FL_FREE_COL1, r, g, b) strng = "%d" % r xfl.fl_set_object_label(self.predtext, strng) strng = "%d" % g xfl.fl_set_object_label(self.pgreentext, strng) strng = "%d" % b xfl.fl_set_object_label(self.pbluetext, strng) xfl.fl_unfreeze_form(self.pform) while True: if xfl.fl_is_same_object(xfl.fl_do_forms(), self.pbutton): break r = xfl.fl_get_dial_value(self.pred) + 0.001 g = xfl.fl_get_dial_value(self.pgreen) + 0.001 b = xfl.fl_get_dial_value(self.pblue) + 0.001 xfl.fl_freeze_form(self.pform) xfl.fl_mapcolor(xfl.FL_FREE_COL1, r, g, b) strng = "%d" % r xfl.fl_set_object_label(self.predtext, strng) strng = "%d" % g xfl.fl_set_object_label(self.pgreentext, strng) strng = "%d" % b xfl.fl_set_object_label(self.pbluetext, strng) xfl.fl_unfreeze_form(self.pform) xfl.fl_hide_form(self.pform) xfl.fl_finish() sys.exit(0)
def show_val(self, pob, delta): self.val += delta strng = "%d" % self.val xfl.fl_set_object_label(self.pvalobj, strng)
def valchange_cb(self, pobj, data): buf = "%.3f" % xfl.fl_get_thumbwheel_value(pobj) xfl.fl_set_object_label(self.preport, buf)
def timer_cb(self, pobj, data): timerval = self.fdform0.ldata * 0.001 end_sec, end_usec = xfl.fl_gettime() df = end_sec - self.start_sec + (end_usec - self.start_usec) * 1.0e-6 buf = "Timeout: %.3f Actual: %.3f DeltaE: %.3f" % (timerval, df, df - timerval) xfl.fl_set_object_label(self.fdform0.report, buf)
def slider_cb(self, pobj, data): strng = "%f" % xfl.fl_get_slider_value(pobj) xfl.fl_set_object_label(self.pboxvalue, strng)