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 load_browser(self, fname):
     #RGBdb *db = rgbdb,
     ndb = 0
     contents = [0] * MAX_RGB
     #*dbs = db + MAX_RGB;
     lr = -1
     lg = -1
     lb = -1
     if not os.path.exists(fname):
         xfl.fl_show_alert("Load", fname, "Can't open database file", 0)
         return 0
     filep = open(fname, 'r')
     xfl.fl_freeze_form(self.pcl)
     # read the items
     #contents = filep.readlines()
     #filep.close()
     self.set_entry(0)
     #print("lencont", len(contents))
     #while ( db < dbs && read_entry( fp, &r, &g, &b, name ) )
     #for ndb in range(0, len(contents)):
     #while ndb < len(contents):
     while True:
         if ndb == 752:      #MAX_RGB:
             break
         #print "contents[ndb]", contents[ndb]
         #print "ndb", ndb
         contents[ndb] = filep.readline()
         print(contents[ndb])
         r, g, b, name = self.read_entry(contents[ndb])
         #print "#"+str(r)+"#"+str(g)+"#"+str(b)+"#"+name
         self.rgbdb[ndb]['r'] = r
         self.rgbdb[ndb]['g'] = g
         self.rgbdb[ndb]['b'] = b
         #print self.rgbdb[ndb]['r'], self.rgbdb[ndb]['g'], self.rgbdb[ndb]['b']
         # unique the entries on the fly
         if lr != r or lg != g or lb != b:
             lr = r
             lg = g
             lb = b
             buf = "(%3d %3d %3d) %s" % (r, g, b, name)          #sprintf( buf, "(%3d %3d %3d) %s", r, g, b, name)
             xfl.fl_addto_browser(self.pcolbr, buf)
         ndb += 1            # db++;
     filep.close()
     #if ndb < MAX_RGB:                         #db < dbs
     #    self.rgbdb[ndb]['r'] = 1000        #db->r = 1000;  /* sentinel
     #else:
     #    ndb -= 1                #db--;
     #    self.rgbdb[ndb]['r'] = 1000        #db->r = 1000;
     xfl.fl_set_browser_topline(self.pcolbr, 1)
     xfl.fl_select_browser_line(self.pcolbr, 1)
     self.set_entry(0)
     xfl.fl_unfreeze_form(self.pcl)
     #print self.rgbdb[5], self.rgbdb[4], self.rgbdb[10], self.rgbdb[100]
     return 1
def timeoutCB(tid, stuff):
    xfl.fl_show_alert("Standby", "This may abort", "with SEGV", 1)