From e85a531f6ada8948e3384dd8cf5f75e5c7b082c7 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 27 Feb 2009 14:27:57 -0500 Subject: [PATCH 01/12] Fix missing "self." in previous commit. --- pyfpdb/Hud.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 12f66175..da791415 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -303,7 +303,7 @@ class Hud: if this_stat.hudcolor != "": self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudfgcolor'])) - self.stat_windows[stat_dict[s]['seat']].label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(this_stat.hudcolor)) + self.stat_windows[self.stat_dict[s]['seat']].label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(this_stat.hudcolor)) self.stat_windows[self.stat_dict[s]['seat']].label[r][c].set_text(statstring) if statstring != "xxx": # is there a way to tell if this particular stat window is visible already, or no? From d44c90aec7f385a98dd8eef531162c9cb15a9bf6 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 27 Feb 2009 19:47:52 -0500 Subject: [PATCH 02/12] Temp fix to HUD crashing when closed table is updated. Also fixes popups not closing correctly. General cleanup in the HUD closing code. Closing a HUD is now managed by the HUD_Main object--this should ensure that no objects are left dangling. --- pyfpdb/HUD_main.py | 21 ++++++++------------- pyfpdb/Hud.py | 43 +++++++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 33 deletions(-) diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index 2084850b..7418cfc8 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -76,7 +76,14 @@ class HUD_main(object): def destroy(*args): # call back for terminating the main eventloop gtk.main_quit() - + + def kill_hud(self, event, table): +# called by an event in the HUD, to kill this specific HUD + self.hud_dict[table].kill() + self.hud_dict[table].main_window.destroy() + self.vb.remove(self.hud_dict[table].tablehudlabel) + del(self.hud_dict[table]) + def create_HUD(self, new_hand_id, table, table_name, max, poker_game, is_tournament, stat_dict, cards): def idle_func(): @@ -117,18 +124,6 @@ class HUD_main(object): gtk.gdk.threads_leave() gobject.idle_add(idle_func) - def HUD_removed(self, tablename): - - tablename = Tables.clean_title(tablename) - # TODO: There's a potential problem here somewhere, that this hacks around .. the table_name as being passed to HUD_create is cleaned, - # but the table.name as being passed here is not cleaned. I don't know why. -eric - if tablename in self.hud_dict and self.hud_dict[tablename].deleted: - self.vb.remove(self.hud_dict[tablename].tablehudlabel) - del self.hud_dict[tablename] - return False - - return True - def read_stdin(self): # This is the thread function """Do all the non-gui heavy lifting for the HUD program.""" diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index da791415..73dd3472 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -81,7 +81,7 @@ class Hud: self.main_window = gtk.Window() self.main_window.set_gravity(gtk.gdk.GRAVITY_STATIC) self.main_window.set_title(self.table.name + " FPDBHUD") - self.main_window.destroyhandler = self.main_window.connect("destroy", self.kill_hud) +# self.main_window.destroyhandler = self.main_window.connect("destroy", self.kill_hud) self.main_window.set_decorated(False) self.main_window.set_opacity(self.colors["hudopacity"]) @@ -106,7 +106,7 @@ class Hud: self.menu = gtk.Menu() self.item1 = gtk.MenuItem('Kill this HUD') self.menu.append(self.item1) - self.item1.connect("activate", self.kill_hud_menu) + self.item1.connect("activate", self.parent.kill_hud, self.table.name) self.item1.show() self.item2 = gtk.MenuItem('Save Layout') @@ -168,23 +168,18 @@ class Hud: return True return False - def kill_hud(self, *args): - if self.deleted: - return # no killing self twice. - for k in self.stat_windows: - self.stat_windows[k].window.destroy() + def kill(self, *args): +# kill all stat_windows, popups and aux_windows in this HUD +# heap dead, burnt bodies, blood 'n guts, veins between my teeth + for s in self.stat_windows.itervalues(): + for p in s.popups: + s.kill_popup(p) + s.window.destroy() + self.stat_windows = {} # also kill any aux windows for m in self.aux_windows: m.destroy() - self.aux_windows.remove(m) - - self.deleted = True - self.main_window.disconnect(self.main_window.destroyhandler) # so we don't potentially infiniteloop in here, right - self.main_window.destroy() - self.parent.HUD_removed(self.table.name) - - def kill_hud_menu(self, *args): - self.main_window.destroy() + self.aux_windows = [] def reposition_windows(self, *args): for w in self.stat_windows: @@ -285,7 +280,8 @@ class Hud: def update(self, hand, config): self.hand = hand # this is the last hand, so it is available later - self.update_table_position() + if os.name == 'nt': + self.update_table_position() for s in self.stat_dict: try: @@ -345,7 +341,7 @@ class Stat_Window: # and double-clicks. if event.button == 3: # right button event - Popup_window(widget, self) + self.popups.append(Popup_window(widget, self)) if event.button == 2: # middle button event self.window.hide() @@ -356,7 +352,11 @@ class Stat_Window: self.window.begin_resize_drag(gtk.gdk.WINDOW_EDGE_SOUTH_EAST, event.button, int(event.x_root), int(event.y_root), event.time) else: self.window.begin_move_drag(event.button, int(event.x_root), int(event.y_root), event.time) - + + def kill_popup(self, popup): + popup.window.destroy() + self.popups.remove(popup) + def relocate(self, x, y): self.x = x + self.table.x self.y = y + self.table.y @@ -372,6 +372,7 @@ class Stat_Window: self.y = y + table.y # x and y are the location relative to table.x & y self.player_id = player_id # looks like this isn't used ;) self.sb_click = 0 # used to figure out button clicks + self.popups = [] # list of open popups for this stat window self.useframes = parent.config.get_frames(parent.site) self.window = gtk.Window() @@ -431,6 +432,7 @@ def destroy(*args): # call back for terminating the main eventloop class Popup_window: def __init__(self, parent, stat_window): self.sb_click = 0 + self.stat_window = stat_window # create the popup window self.window = gtk.Window() @@ -513,7 +515,8 @@ class Popup_window: pass if event.button == 3: # right button event - self.window.destroy() + self.stat_window.kill_popup(self) +# self.window.destroy() def toggle_decorated(self, widget): top = widget.get_toplevel() From c0400f6c66f5ddd3d6de2b4507ca74322993a51d Mon Sep 17 00:00:00 2001 From: Worros Date: Sat, 28 Feb 2009 12:34:41 +0900 Subject: [PATCH 03/12] Fix Everleaf GameInfo regex to detect FL Added regression test mechanism while at it --- pyfpdb/EverleafToFpdb.py | 2 +- pyfpdb/RegressionTest.py | 60 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/pyfpdb/EverleafToFpdb.py b/pyfpdb/EverleafToFpdb.py index 4c565d44..4c78051f 100755 --- a/pyfpdb/EverleafToFpdb.py +++ b/pyfpdb/EverleafToFpdb.py @@ -28,7 +28,7 @@ class Everleaf(HandHistoryConverter): # Static regexes re_SplitHands = re.compile(r"\n\n+") - re_GameInfo = re.compile(r".*Blinds \$?(?P[.0-9]+)/\$?(?P[.0-9]+) (?P(NL|PL)) (?P(Hold\'em|Omaha|7 Card Stud))") + re_GameInfo = re.compile(r"^(Blinds )?\$?(?P[.0-9]+)/\$?(?P[.0-9]+) ((?PNL|PL) )?(?P(Hold\'em|Omaha|7 Card Stud))", re.MULTILINE) re_HandInfo = re.compile(r".*#(?P[0-9]+)\n.*\nBlinds \$?(?P[.0-9]+)/\$?(?P[.0-9]+) (?P.*) - (?P\d\d\d\d/\d\d/\d\d - \d\d:\d\d:\d\d)\nTable (?P[- a-zA-Z]+)") re_Button = re.compile(r"^Seat (?P
[- a-zA-Z]+)") + re_HandInfo = re.compile(r".*#(?P[0-9]+)\n.*\n(Blinds )?\$?(?P[.0-9]+)/\$?(?P[.0-9]+) (?P.*) - (?P\d\d\d\d/\d\d/\d\d - \d\d:\d\d:\d\d)\nTable (?P
[- a-zA-Z]+)") re_Button = re.compile(r"^Seat (?P