def __ask_import__(self, *args): if not self._import_box: #print args #print '__import__' themes = self.cmd.getall(['theme'], 'themes') self._import_box = CList('hello') self._import_box.set_rows(themes) self._import_box.set_ok(self.__import_ok__)
def __init__(self, client, path): CList.__init__(self, path) self._gc_client = client self._path_ = path #rows = self.__make_rows__(self._getdirs_(path)) #print rows #self.set_rows(rows) self.set_rows(self._getdirs_(path), [path]) self.set_row_select(self.make_new_window) self.add_button('go_up', self._go_up, label='go up')
def __hello__(self, listbox, row, column, event): self.statement.table = listbox.get_selected_data()[0]['table'] table = self.statement.table tb = CList(table, name=table) rows = self.cmd.getall('*', table) cols = [] if len(rows): cols = rows[0].keys() tb.set_rows(rows, cols) tb.set_usize(400,200)
class ColorThingyWindow(CommandBoxWindow): def __init__(self, rgb, conn, name='ColorThingyWindow'): CommandBoxWindow.__init__(self, name=name) self.browser = ColorThingy(rgb) self.rgb = rgb self.cmd = StatementCursor(conn, 'themer') self.theme = None self.vbox.add(self.browser) self.tbar.add_button('import', 'import', self.__ask_import__) self.tbar.add_button('insert', 'insert', self.__ask_insert__) self.tbar.add_button('update', 'update', self.__update_theme__) self.tbar.add_button('save', 'save', self.__save_files__) self._insert_box = None self._import_box = None def __ask_import__(self, *args): if not self._import_box: #print args #print '__import__' themes = self.cmd.getall(['theme'], 'themes') self._import_box = CList('hello') self._import_box.set_rows(themes) self._import_box.set_ok(self.__import_ok__) def __import_ok__(self, *args): theme = self._import_box.listbox.get_selected_data()[0]['theme'] self._import_box.destroy() self._import_box = None rows = self.cmd.select(table=theme) b = self.browser b._style.quick_set(rows) for e, sb in b._elements.items(): for s in sb.keys(): color = b._style.elements[e][s] sb[s] = color.name _bg_widget(sb[s].button, color) self.theme = theme def __ask_insert__(self, *args): if not self._import_box: self._insert_box = EntryDialog('please insert name') self._insert_box.set_ok(self.__insert_ok__) def __insert_ok__(self, *args): style = self.browser._style tname = self._insert_box.get() self.theme = tname table = ThemeTable(tname) self.cmd.create_table(table) self.cmd.insert('themes', {'theme': tname}) for row in style.to_irows(): self.cmd.insert(tname, row) def __update_theme__(self, *args): if self.theme: for element, states in self.browser._style.to_urows(): self.cmd.update(self.theme, states, "element = '%s'" % element) def __save_files__(self, *args): colordict = Rgbdb() tmpl = GtkrcTemplate(self.theme, theme_base, self.browser._style) tmpl.write_files()
def __init__(self, conn): self.cmd = StatementCursor(conn, name='TableBrowser') CList.__init__(self, 'Tables', name='TableBrowser') self.set_rows(self.cmd.tables(), ['table']) self.set_row_select(self.__hello__) self.statement = Statement('select')
class ColorThingyWindow(CommandBoxWindow): def __init__(self, rgb, conn, name='ColorThingyWindow'): CommandBoxWindow.__init__(self, name=name) self.browser = ColorThingy(rgb) self.rgb = rgb self.cmd = StatementCursor(conn, 'themer') self.theme = None self.vbox.add(self.browser) self.tbar.add_button('import', 'import', self.__ask_import__) self.tbar.add_button('insert', 'insert', self.__ask_insert__) self.tbar.add_button('update', 'update', self.__update_theme__) self.tbar.add_button('save', 'save', self.__save_files__) self._insert_box = None self._import_box = None def __ask_import__(self, *args): if not self._import_box: #print args #print '__import__' themes = self.cmd.getall(['theme'], 'themes') self._import_box = CList('hello') self._import_box.set_rows(themes) self._import_box.set_ok(self.__import_ok__) def __import_ok__(self, *args): theme = self._import_box.listbox.get_selected_data()[0]['theme'] self._import_box.destroy() self._import_box = None rows = self.cmd.select(table=theme) b = self.browser b._style.quick_set(rows) for e, sb in b._elements.items(): for s in sb.keys(): color = b._style.elements[e][s] sb[s] = color.name _bg_widget(sb[s].button, color) self.theme = theme def __ask_insert__(self, *args): if not self._import_box: self._insert_box = EntryDialog('please insert name') self._insert_box.set_ok(self.__insert_ok__) def __insert_ok__(self, *args): style = self.browser._style tname = self._insert_box.get() self.theme = tname table = ThemeTable(tname) self.cmd.create_table(table) self.cmd.insert('themes', {'theme':tname}) for row in style.to_irows(): self.cmd.insert(tname, row) def __update_theme__(self, *args): if self.theme: for element, states in self.browser._style.to_urows(): self.cmd.update(self.theme, states, "element = '%s'" %element) def __save_files__(self, *args): colordict = Rgbdb() tmpl = GtkrcTemplate(self.theme, theme_base, self.browser._style) tmpl.write_files()