def __init__(self): self.conn = engine.connect() self.ins_collection = collection.insert() self.ins_event = event.insert() self.ins_site = site.insert() self.ins_player = player.insert() self.ins_annotator = annotator.insert() self.ins_game = game.insert() self.collection_dict = {} self.event_dict = {} self.site_dict = {} self.player_dict = {} self.annotator_dict = {} self.next_id = [0, 0, 0, 0, 0] self.next_id[COLLECTION] = self.ini_names(collection, COLLECTION) self.next_id[EVENT] = self.ini_names(event, EVENT) self.next_id[SITE] = self.ini_names(site, SITE) self.next_id[PLAYER] = self.ini_names(player, PLAYER) self.next_id[ANNOTATOR] = self.ini_names(annotator, ANNOTATOR)
def __init__(self): GObject.GObject.__init__(self) self.offset = 0 self.orderby = None self.where = None self.count = 0 self.conn = engine.connect() self.liststore = Gtk.ListStore(int, str, str, str, str, str, str, str, str, str, str) self.modelsort = Gtk.TreeModelSort(self.liststore) self.modelsort.set_sort_column_id(0, Gtk.SortType.ASCENDING) self.set_model(self.modelsort) self.get_selection().set_mode(Gtk.SelectionMode.BROWSE) self.set_headers_visible(True) self.set_rules_hint(True) self.set_search_column(1) cols = (_("Id"), _("White"), _("W Elo"), _("Black"), _("B Elo"), _("Result"), _("Event"), _("Site"), _("Round"), _("Date"), _("ECO")) for i, col in enumerate(cols): r = Gtk.CellRendererText() column = Gtk.TreeViewColumn(col, r, text=i) column.set_resizable(True) column.set_reorderable(True) column.set_sort_column_id(i) column.connect("clicked", self.column_clicked, i) self.append_column(column) self.connect("row-activated", self.row_activated) self.set_cursor(0) self.columns_autosize() self.gameno = 0 self.uri = pychess_pdb self.chessfile = load(open(self.uri)) self.build_query() w = Gtk.Window(Gtk.WindowType.TOPLEVEL) w.set_title(_("PyChess Game Database")) w.set_size_request(1000, 400) hbox = Gtk.HBox() self.playerlist = Gtk.ListStore(str) self.match = set() completion = Gtk.EntryCompletion() completion.set_model(self.playerlist) completion.set_text_column(0) for player in self.chessfile.players: self.playerlist.append(player) entry = Gtk.Entry() entry.set_completion(completion) entry.connect('activate', self.activate_entry) hbox.pack_start(entry, False, False, 0) toolbar = Gtk.Toolbar() hbox.pack_start(toolbar, True, True, 0) firstButton = Gtk.ToolButton(Gtk.STOCK_MEDIA_PREVIOUS) toolbar.insert(firstButton, -1) prevButton = Gtk.ToolButton(Gtk.STOCK_MEDIA_REWIND) toolbar.insert(prevButton, -1) nextButton = Gtk.ToolButton(Gtk.STOCK_MEDIA_FORWARD) toolbar.insert(nextButton, -1) lastButton = Gtk.ToolButton(Gtk.STOCK_MEDIA_NEXT) toolbar.insert(lastButton, -1) firstButton.connect("clicked", self.on_first_clicked) prevButton.connect("clicked", self.on_prev_clicked) nextButton.connect("clicked", self.on_next_clicked) lastButton.connect("clicked", self.on_last_clicked) vbox = Gtk.VBox() vbox.pack_start(hbox, False, False, 0) sw = Gtk.ScrolledWindow() sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN) sw.add(self) vbox.pack_start(sw, True, True, 0) w.add(vbox) w.show_all()