From 75a94299f984f369414bd7797595455f378d9916 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 19 Mar 2009 13:18:50 -0400 Subject: [PATCH 1/5] Make sure HUD_main gets community cards for AWs to use. --- pyfpdb/HUD_main.py | 4 +++- pyfpdb/Mucked.py | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index 666cf836..aceab383 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -151,7 +151,9 @@ class HUD_main(object): try: (table_name, max, poker_game) = self.db_connection.get_table_name(new_hand_id) stat_dict = self.db_connection.get_stats_from_hand(new_hand_id) - cards = self.db_connection.get_cards(new_hand_id) + cards = self.db_connection.get_cards(new_hand_id) + comm_cards = self.db_connection.get_common_cards(new_hand_id) + cards['common'] = comm_cards['common'] except Exception, err: print "db error: skipping ", new_hand_id, err sys.stderr.write("Database error %s in hand %d. Skipping.\n" % (err, int(new_hand_id))) diff --git a/pyfpdb/Mucked.py b/pyfpdb/Mucked.py index 1d7e9597..a915facc 100755 --- a/pyfpdb/Mucked.py +++ b/pyfpdb/Mucked.py @@ -349,10 +349,6 @@ class Flop_Mucked(Aux_Window): self.m_windows[i].show_all() self.m_windows[i].hide() - def update_data(self, new_hand_id, db_connection): - cards = db_connection.get_common_cards(new_hand_id) - self.hud.cards['common'] = cards['common'] - def update_gui(self, new_hand_id): """Prepare and show the mucked cards.""" if self.displayed_cards: From 33055f7f864893eca23f93852be386b0eb094115 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 19 Mar 2009 16:10:18 -0400 Subject: [PATCH 2/5] Hello_menu demo added to Hello.py module. --- pyfpdb/Hello.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pyfpdb/Hello.py b/pyfpdb/Hello.py index b5d1d366..41262d6c 100644 --- a/pyfpdb/Hello.py +++ b/pyfpdb/Hello.py @@ -99,3 +99,15 @@ class Hello_plus(Aux_Window): # hands played that was updated in the "update_data()" function. self.label.set_text("Hello %s\nYou have played %d hands\n on %s." % (self.hero, self.hands_played, self.site)) +class Hello_Menu(Aux_Window): + """A 'Hello World' Aux_Window demo.""" + def create(self): +# This demo puts a menu item on the HUD mainwindow. + self.item = gtk.MenuItem('Print cards') + self.hud.menu.append(self.item) + self.item.connect("activate", self.print_cards) + self.item.show() + + def print_cards(self, *args): +# callback for the menu item + print "cards =", self.hud.cards From 72c0cdfa527fe87aa7e45fbc7a4535eaa602bc37 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 19 Mar 2009 20:58:40 -0400 Subject: [PATCH 3/5] Needed to make previous commit work. --- pyfpdb/Mucked.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/Mucked.py b/pyfpdb/Mucked.py index a915facc..abde491f 100755 --- a/pyfpdb/Mucked.py +++ b/pyfpdb/Mucked.py @@ -37,7 +37,7 @@ import Database class Aux_Window: def __init__(self, hud, params, config): - self.config = hud + self.hud = hud self.config = config def update_data(self, *parms): From d59016f249d9d7c159a9b364043820160b78e599 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 20 Mar 2009 19:28:57 -0400 Subject: [PATCH 4/5] Button clicking for FlopMucked. --- pyfpdb/Mucked.py | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/pyfpdb/Mucked.py b/pyfpdb/Mucked.py index abde491f..334ba694 100755 --- a/pyfpdb/Mucked.py +++ b/pyfpdb/Mucked.py @@ -318,6 +318,7 @@ class Flop_Mucked(Aux_Window): self.params = params # dict aux params from config self.positions = {} # dict of window positions self.displayed_cards = False + self.timer_on = False # bool = Ture if the timeout for removing the cards is on self.card_images = self.get_card_images() def create(self): @@ -375,34 +376,60 @@ class Flop_Mucked(Aux_Window): self.displayed_cards = True if self.displayed_cards and float(self.params['timeout']) > 0: - gobject.timeout_add(int(1000*float(self.params['timeout'])), self.hide_mucked_cards) + self.timer_on = True + gobject.timeout_add(int(1000*float(self.params['timeout'])), self.timed_out) def destroy(self): """Destroy all of the mucked windows.""" for w in self.m_windows.values(): w.destroy() + def timed_out(self): +# this is the callback from the timeout + +# if timer_on is False the user has cancelled the timer with a click +# so just return False to cancel the timer + if not self.timer_on: + return False + else: + self.hide_mucked_cards() + return False + def hide_mucked_cards(self): """Hide the mucked card windows.""" -# this is the callback from the timeout for (i, w) in self.m_windows.iteritems(): self.positions[i] = w.get_position() w.hide() self.displayed_cards = False - return False # this tells the system to NOT run this timeout again def button_press_cb(self, widget, event, *args): """Handle button clicks in the event boxes.""" + +# shift-any button exposes all the windows and turns off the timer + if event.state & gtk.gdk.SHIFT_MASK: + self.timer_on = False + self.expose_all() + if event.button == 3: # right button event pass elif event.button == 2: # middle button event - self.hide_mucked_cards() + if self.timer_on == True: + self.timer_on = False + else: + self.timer_on = False + self.hide_mucked_cards() elif event.button == 1: # left button event window = widget.get_parent() window.begin_move_drag(event.button, int(event.x_root), int(event.y_root), event.time) + def expose_all(self): + for (i, cards) in self.hud.cards.iteritems(): + self.m_windows[i].present() + self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) # here is where I move back + self.displayed_cards = True + def save_layout(self, *args): """Save new layout back to the aux element in the config file.""" new_locs = {} From 847fd5f6c18cc8e3bd90b9cdc5d75538156cfe89 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 20 Mar 2009 19:32:02 -0400 Subject: [PATCH 5/5] Tool tips for FlopMucked. --- pyfpdb/Mucked.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyfpdb/Mucked.py b/pyfpdb/Mucked.py index 334ba694..fe2baa71 100755 --- a/pyfpdb/Mucked.py +++ b/pyfpdb/Mucked.py @@ -25,6 +25,7 @@ Mucked cards display for FreePokerTools HUD. # Standard Library modules import sys +import pprint # pyGTK modules import pygtk @@ -375,6 +376,9 @@ class Flop_Mucked(Aux_Window): self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) # here is where I move back self.displayed_cards = True + for stats in self.hud.stat_dict.itervalues(): + self.eb[stats['seat']].set_tooltip_text(stats['screen_name']) + if self.displayed_cards and float(self.params['timeout']) > 0: self.timer_on = True gobject.timeout_add(int(1000*float(self.params['timeout'])), self.timed_out)