From 7f40d9dd3a988f33456556c06bb6599d54daf05f Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Sat, 28 Nov 2009 11:48:06 +0000 Subject: [PATCH 1/4] change default for min_seats to 0 in case hc.activeSeats is zero --- pyfpdb/Database.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 26dc4efe..775e1475 100755 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -452,23 +452,23 @@ class Database: stat_dict = {} if seats_style == 'A': - seats_min, seats_max = 2, 10 + seats_min, seats_max = 0, 10 elif seats_style == 'C': seats_min, seats_max = seats_cust_nums[num_seats][0], seats_cust_nums[num_seats][1] elif seats_style == 'E': seats_min, seats_max = num_seats, num_seats else: - seats_min, seats_max = 2, 10 + seats_min, seats_max = 0, 10 print "bad seats_style value:", seats_style if h_seats_style == 'A': - h_seats_min, h_seats_max = 2, 10 + h_seats_min, h_seats_max = 0, 10 elif h_seats_style == 'C': h_seats_min, h_seats_max = h_seats_cust_nums[num_seats][0], h_seats_cust_nums[num_seats][1] elif h_seats_style == 'E': h_seats_min, h_seats_max = num_seats, num_seats else: - h_seats_min, h_seats_max = 2, 10 + h_seats_min, h_seats_max = 0, 10 print "bad h_seats_style value:", h_seats_style print "opp seats style", seats_style, "hero seats style", h_seats_style print "opp seats:", seats_min, seats_max, " hero seats:", h_seats_min, h_seats_max From cce15450243f1e8a783aa4720f73bfa36084dde6 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Sat, 28 Nov 2009 21:11:52 +0000 Subject: [PATCH 2/4] add gui stuff to test, stop crash if xml.dom.ext not present --- pyfpdb/Configuration.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index 728ffd5c..83648577 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -960,8 +960,14 @@ if __name__== "__main__": for game in c.get_supported_games(): print c.get_game_parameters(game) + for hud_param, value in c.get_hud_ui_parameters().iteritems(): + print "hud param %s = %s" % (hud_param, value) + print "start up path = ", c.execution_path("") - from xml.dom.ext import PrettyPrint - for site_node in c.doc.getElementsByTagName("site"): - PrettyPrint(site_node, stream=sys.stdout, encoding="utf-8") + try: + from xml.dom.ext import PrettyPrint + for site_node in c.doc.getElementsByTagName("site"): + PrettyPrint(site_node, stream=sys.stdout, encoding="utf-8") + except: + print "xml.dom.ext needs PyXML to be installed!" From db3371a20271c4a64589745ae75c45f1d5b339ff Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Sat, 28 Nov 2009 22:00:44 +0000 Subject: [PATCH 3/4] use notebook widget to show proper tabs --- pyfpdb/fpdb.py | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index 80d3fb93..0eb4d4cd 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -101,14 +101,10 @@ class fpdb: if i == new_tab_name: return # if tab already exists, just go to it + self.nb.append_page(new_tab, gtk.Label(new_tab_name)) self.tabs.append(new_tab) self.tab_names.append(new_tab_name) - - new_tab_sel_button = gtk.ToggleButton(new_tab_name) - new_tab_sel_button.connect("clicked", self.tab_clicked, new_tab_name) - self.tab_box.add(new_tab_sel_button) - new_tab_sel_button.show() - self.tab_buttons.append(new_tab_sel_button) + new_tab.show() def display_tab(self, new_tab_name): """displays the indicated tab""" @@ -118,14 +114,10 @@ class fpdb: tab_no = i break - if tab_no == -1: - raise FpdbError("invalid tab_no") + if tab_no < 0 or tab_no >= self.nb.get_n_pages(): + raise FpdbError("invalid tab_no " + str(tab_no)) else: - self.main_vbox.remove(self.current_tab) - self.current_tab=self.tabs[tab_no] - self.main_vbox.add(self.current_tab) - self.tab_buttons[tab_no].set_active(True) - self.current_tab.show() + self.nb.set_current_page(tab_no) def delete_event(self, widget, event, data=None): return False @@ -628,18 +620,12 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt") menubar.show() #done menubar + self.nb = gtk.Notebook() + self.nb.set_show_tabs(True) + self.nb.show() + self.main_vbox.pack_start(self.nb, True, True, 0) self.tabs=[] self.tab_names=[] - self.tab_buttons=[] - self.tab_box = gtk.HBox(True,1) - self.main_vbox.pack_start(self.tab_box, False, True, 0) - self.tab_box.show() - #done tab bar - - self.current_tab = gtk.VBox(False,1) - self.current_tab.set_border_width(1) - self.main_vbox.add(self.current_tab) - self.current_tab.show() self.tab_main_help(None, None) From c77ae3907753e98972ab5d06c3b97ddf76e5d205 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Sat, 28 Nov 2009 23:36:54 +0000 Subject: [PATCH 4/4] add close buttons to tabs --- pyfpdb/fpdb.py | 88 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 79 insertions(+), 9 deletions(-) diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index 0eb4d4cd..14117bdf 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -95,22 +95,37 @@ class fpdb: self.add_tab(new_tab, new_tab_name) self.display_tab(new_tab_name) - def add_tab(self, new_tab, new_tab_name): + def add_tab(self, new_page, new_tab_name): """adds a tab, namely creates the button and displays it and appends all the relevant arrays""" - for i in self.tab_names: #todo: check this is valid - if i == new_tab_name: + for name in self.nb_tabs: #todo: check this is valid + if name == new_tab_name: return # if tab already exists, just go to it - self.nb.append_page(new_tab, gtk.Label(new_tab_name)) - self.tabs.append(new_tab) - self.tab_names.append(new_tab_name) - new_tab.show() + used_before = False + for i, name in enumerate(self.tab_names): #todo: check this is valid + if name == new_tab_name: + used_before = True + event_box = self.tabs[i] + page = self.pages[i] + break + + if not used_before: + event_box = self.create_custom_tab(new_tab_name, self.nb) + page = new_page + self.pages.append(new_page) + self.tabs.append(event_box) + self.tab_names.append(new_tab_name) + + #self.nb.append_page(new_page, gtk.Label(new_tab_name)) + self.nb.append_page(page, event_box) + self.nb_tabs.append(new_tab_name) + page.show() def display_tab(self, new_tab_name): """displays the indicated tab""" tab_no = -1 - for i, name in enumerate(self.tab_names): - if name == new_tab_name: + for i, name in enumerate(self.nb_tabs): + if new_tab_name == name: tab_no = i break @@ -119,6 +134,59 @@ class fpdb: else: self.nb.set_current_page(tab_no) + def create_custom_tab(self, text, nb): + #create a custom tab for notebook containing a + #label and a button with STOCK_ICON + eventBox = gtk.EventBox() + tabBox = gtk.HBox(False, 2) + tabLabel = gtk.Label(text) + tabBox.pack_start(tabLabel, False) + eventBox.add(tabBox) + + if nb.get_n_pages() > 0: + tabButton = gtk.Button() + + tabButton.connect('clicked', self.remove_tab, (nb, text)) + #Add a picture on a button + self.add_icon_to_button(tabButton) + tabBox.pack_start(tabButton, False) + + # needed, otherwise even calling show_all on the notebook won't + # make the hbox contents appear. + tabBox.show_all() + return eventBox + + def add_icon_to_button(self, button): + iconBox = gtk.HBox(False, 0) + image = gtk.Image() + image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU) + gtk.Button.set_relief(button, gtk.RELIEF_NONE) + settings = gtk.Widget.get_settings(button); + (w,h) = gtk.icon_size_lookup_for_settings(settings, gtk.ICON_SIZE_MENU); + gtk.Widget.set_size_request (button, w + 4, h + 4); + image.show() + iconBox.pack_start(image, True, False, 0) + button.add(iconBox) + iconBox.show() + return + + # Remove a page from the notebook + def remove_tab(self, button, data): + (nb, text) = data + page = -1 + #print "\n remove_tab: start", text + for i, tab in enumerate(self.nb_tabs): + if text == tab: + page = i + #print " page =", page + if page >= 0 and page < self.nb.get_n_pages(): + #print " removing page", page + del self.nb_tabs[page] + nb.remove_page(page) + # Need to refresh the widget -- + # This forces the widget to redraw itself. + #nb.queue_draw_area(0,0,-1,-1) needed or not?? + def delete_event(self, widget, event, data=None): return False @@ -624,8 +692,10 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt") self.nb.set_show_tabs(True) self.nb.show() self.main_vbox.pack_start(self.nb, True, True, 0) + self.pages=[] self.tabs=[] self.tab_names=[] + self.nb_tabs=[] self.tab_main_help(None, None)