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 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 boxtype_cb(self, pobj, arg):

        req_bt = (xfl.fl_get_select_item(pobj)).contents.val
        lastbt = -1

        if lastbt != req_bt:
            xfl.fl_freeze_form(self.pform)
            xfl.fl_redraw_form(self.pform)
            for i in range(0, len(tobj)):
                xfl.fl_set_object_boxtype(tobj[i], btypes[req_bt]["val"])
            xfl.fl_unfreeze_form(self.pform)
            lastbt = req_bt
    def bw_cb(self, pobj, data):
        bws = [-4, -3, -2, -1, 1, 2, 3, 4]
        n = xfl.fl_get_select_item(pobj).contents.val - 1
        # xfl.FL_POPUP_RETURN

        xfl.fl_freeze_form(pobj.contents.form)
        xfl.fl_set_object_bw(self.fd_buttform.backface, bws[n])
        xfl.fl_set_object_bw(self.fd_buttform.objsgroup, bws[n])
        xfl.fl_set_object_bw(self.fd_buttform.done, bws[n])

        # redrawing the backface wipes out the done button. Redraw it
        #xfl.fl_redraw_object(self.fd_buttform.done)
        xfl.fl_unfreeze_form(pobj.contents.form)
 def set_entry(self, i):
     #RGBdb *db = rgbdb + i;
     #print("i", i, "rgbdb[i].r", self.rgbdb[i]['r'], "rgbdb[i].g",
     #        self.rgbdb[i]['g'], "rgbdb[i].b",  self.rgbdb[i]['b'])
     xfl.fl_freeze_form(self.pcl)
     xfl.fl_mapcolor(xfl.FL_FREE_COL4 + i, self.rgbdb[i]['r'], \
             self.rgbdb[i]['g'], self.rgbdb[i]['b'])
     xfl.fl_mapcolor(xfl.FL_FREE_COL4, self.rgbdb[i]['r'], \
             self.rgbdb[i]['g'], self.rgbdb[i]['b'])
     xfl.fl_set_slider_value(self.prs, self.rgbdb[i]['r'])
     xfl.fl_set_slider_value(self.pgs, self.rgbdb[i]['g'])
     xfl.fl_set_slider_value(self.pbs, self.rgbdb[i]['b'])
     #xfl.fl_redraw_object(self.prescol)
     xfl.fl_unfreeze_form(self.pcl)
 def search_rgb(self, pobj, q):
     top = xfl.fl_get_browser_topline(self.pcolbr)
     r = int(xfl.fl_get_slider_value(self.prs))
     g = int(xfl.fl_get_slider_value(self.pgs))
     b = int(xfl.fl_get_slider_value(self.pbs))
     xfl.fl_freeze_form(self.pcl)
     xfl.fl_mapcolor(xfl.FL_FREE_COL4, r, g, b)
     #xfl.fl_redraw_object(self.prescol)
     i = self.search_entry(r, g, b)
     # change topline only if necessary
     if i < top or i > (top + 15):
         xfl.fl_set_browser_topline(self.pcolbr, i - 8)
     xfl.fl_select_browser_line(self.pcolbr, i + 1)
     xfl.fl_unfreeze_form(self.pcl)
 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)