def main(lsysargv, sysargv): xfl.fl_initialize(lsysargv, sysargv, "FormDemo", None, 0) xfl.fl_set_resource(xfl.FLOKLabel, "Go") if xfl.fl_show_question("Do you want bold font ?", 1): xfl.fl_set_goodies_font(xfl.FL_BOLD_STYLE, xfl.FL_NORMAL_SIZE) xfl.fl_show_messages("This is a test program for the goodies of the " "xforms library") xfl.fl_add_timeout(5000, timeout_remove_alert, 0) xfl.fl_show_alert("Alert", "Alert form can be used to inform", \ " about recoverable errors", 0) if xfl.fl_show_question("Do you want to quit?", 0): sys.exit(0) s = xfl.fl_show_input("Enter a string:", "") if not s: s = "" str1 = s xfl.fl_show_message("You typed:", "", str1) choice = xfl.fl_show_choices("Pick a choice", 3, "One", "Two", \ "Three", 2) if choice == 1: xfl.fl_show_message("You typed: One", "", "") elif choice == 2: xfl.fl_show_message("You typed: Two", "", "") elif choice == 3: xfl.fl_show_message("You typed: Three", "", "") else: xfl.fl_show_message("An error occured!", "", "") s = xfl.fl_show_input("Enter another string:", str1) if not s: s = "<Cancel>" str2 = s xfl.fl_show_message("You typed:", "", str2) xfl.fl_show_messages("Good Bye") xfl.fl_finish() return 0
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 post_handler(self, pobj, event, mx, my, key, xev): if not pobj.contents.u_cdata: return 0 if event == xfl.FL_ENTER: self.timeoutID = xfl.fl_add_timeout(self.INTERVAL, \ self.do_tips, pobj) elif event == xfl.FL_LEAVE or event == xfl.FL_PUSH: xfl.fl_hide_oneliner() if self.timeoutID: xfl.fl_remove_timeout(self.timeoutID) self.timeoutID = 0 return 0
def do_tips(self, id_, pobj): onetext = "" #if xfl.fl_is_same_object(pobj, self.fd_form0.done): # onetext = "Want to quit ?\nPress me" #elif xfl.fl_is_same_object(pobj, self.fd_form0.peek): # onetext = "Turn preempting off" #elif xfl.fl_is_same_object(pobj, self.fd_form0.override): # onetext = "Turn preempting on" xfl.fl_show_oneliner(onetext, pobj.contents.form.x + \ pobj.contents.x, pobj.contents.form.y + \ pobj.contents.y + pobj.contents.h + 1) self.timeoutID = xfl.fl_add_timeout(self.INTERVAL, self.do_tips, pobj)
def pressedCB(pobj, data): tid = xfl.fl_add_timeout(300, timeoutCB, None) print("tid=%d\n" % tid)