From e26fdd79a4d484c44e8bcdd14d4e07a3f6ba8362 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 7 Nov 2008 12:22:37 -0500 Subject: [PATCH 1/2] possible fix to wrong window positioning seen by Elaetic --- pyfpdb/HUD_main.py | 39 +++++++++++++++++++++++++++++++-------- pyfpdb/Hud.py | 9 ++++++++- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index b1955a6b..f54fa9af 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -37,6 +37,7 @@ import os import thread import time import string +import re errorfile = open('HUD-error.txt', 'w', 0) sys.stderr = errorfile @@ -70,9 +71,10 @@ def create_HUD(new_hand_id, table, db_name, table_name, max, poker_game, db_conn hud_dict[table_name] = Hud.Hud(table, max, poker_game, config, db_name) hud_dict[table_name].create(new_hand_id, config) hud_dict[table_name].update(new_hand_id, config, stat_dict) + hud_dict[table_name].reposition_windows() return False finally: - gtk.gdk.threads_leave + gtk.gdk.threads_leave() gobject.idle_add(idle_func) def update_HUD(new_hand_id, table_name, config, stat_dict): @@ -83,13 +85,15 @@ def update_HUD(new_hand_id, table_name, config, stat_dict): hud_dict[table_name].update(new_hand_id, config, stat_dict) return False finally: - gtk.gdk.threads_leave + gtk.gdk.threads_leave() gobject.idle_add(idle_func) def read_stdin(): # This is the thread function global hud_dict db_connection = Database.Database(config, db_name, 'temp') +# tourny_finder = re.compile('(\d+) (\d+)') + while True: # wait for a new hand number on stdin new_hand_id = sys.stdin.readline() new_hand_id = string.rstrip(new_hand_id) @@ -101,20 +105,39 @@ def read_stdin(): # This is the thread function if hud_dict[h].deleted: del(hud_dict[h]) -# connect to the db and get basic info about the new hand +# get basic info about the new hand from the db (table_name, max, poker_game) = db_connection.get_table_name(new_hand_id) + +# find out if this hand is from a tournament + is_tournament = False +# (t_number, s_number) = (0, 0) +# mat_obj = tourny_finder(table_name) +# if len(mat_obj.groups) == 2: +# is_tournament = True +# (t_number, s_number) = mat_obj.group(1, 2) + stat_dict = db_connection.get_stats_from_hand(new_hand_id) -# if a hud for this table exists, just update it +# if a hud for this CASH table exists, just update it if hud_dict.has_key(table_name): update_HUD(new_hand_id, table_name, config, stat_dict) +# if a hud for this TOURNAMENT table exists, just update it +# elif hud_dict.has_key(t_number): +# update_HUD(new_hand_id, t_number, config, stat_dict) # otherwise create a new hud else: - tablewindow = Tables.discover_table_by_name(config, table_name) - if tablewindow == None: - sys.stderr.write("table name "+table_name+" not found\n") + if is_tournament: + tablewindow = Tables.discover_tournament_table(config, t_number, s_number) + if tablewindow == None: + sys.stderr.write("table name "+table_name+" not found\n") + else: + create_HUD(new_hand_id, tablewindow, db_name, t_number, max, poker_game, db_connection, config, stat_dict) else: - create_HUD(new_hand_id, tablewindow, db_name, table_name, max, poker_game, db_connection, config, stat_dict) + tablewindow = Tables.discover_table_by_name(config, table_name) + if tablewindow == None: + sys.stderr.write("table name "+table_name+" not found\n") + else: + create_HUD(new_hand_id, tablewindow, db_name, table_name, max, poker_game, db_connection, config, stat_dict) if __name__== "__main__": sys.stderr.write("HUD_main starting\n") diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 2712c55b..11cf61cc 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -93,6 +93,10 @@ class Hud: self.menu.append(self.item2) self.item2.connect("activate", self.save_layout) self.item2.show() + self.item3 = gtk.MenuItem('Reposition Stats') + self.menu.append(self.item3) + self.item3.connect("activate", self.reposition_windows) + self.item3.show() self.ebox.connect_object("button-press-event", self.on_button_press, self.menu) self.main_window.show_all() @@ -118,6 +122,10 @@ class Hud: self.main_window.destroy() self.deleted = True + def reposition_windows(self, args): + for w in self.stat_windows: + self.stat_windows[w].window.move(self.stat_windows[w].x, + self.stat_windows[w].y) def save_layout(self, *args): new_layout = [] # todo: have the hud track the poker table's window position regularly, don't forget to update table.x and table.y. @@ -180,7 +188,6 @@ class Hud: self.stats[config.supported_games[self.poker_game].stats[stat].row] \ [config.supported_games[self.poker_game].stats[stat].col] = \ config.supported_games[self.poker_game].stats[stat].stat_name - # self.mucked_window = gtk.Window() # self.m = Mucked.Mucked(self.mucked_window, self.db_connection) # self.mucked_window.show_all() From 28037de7a6c011ab59ba3b8c3c2f15fa335c1218 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 8 Nov 2008 16:58:24 -0500 Subject: [PATCH 2/2] skip the set_opacity statement in windows until figured out --- pyfpdb/Hud.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 11cf61cc..2490ad91 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -349,7 +349,8 @@ class Stat_Window: # font = pango.FontDescription("Sans 8") self.label[r][c].modify_font(font) - self.window.set_opacity(parent.colors['hudopacity']) + if not os.name == 'nt': # seems to be a bug in opacity on windows + self.window.set_opacity(parent.colors['hudopacity']) self.window.realize self.window.move(self.x, self.y) self.window.show_all()