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 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 test_fl_set_browser_topline(self):
     """fl_set_browser_topline(ptr_flobject, linenum)"""
     xfl.fl_set_browser_topline(s, 254, 149, {'a': 0, 'b': 1}, E.U., )