Smooth wrinkles in mucked card display.

This commit is contained in:
Ray 2008-11-13 17:07:24 -05:00
parent 806744bf34
commit d90fa208de
2 changed files with 22 additions and 18 deletions

View File

@ -168,7 +168,6 @@ class Hud:
adj = self.adj_seats(hand, config) adj = self.adj_seats(hand, config)
loc = self.config.get_locations(self.table.site, self.max) loc = self.config.get_locations(self.table.site, self.max)
print "adj = ", adj
# create the stat windows # create the stat windows
for i in range(1, self.max + 1): for i in range(1, self.max + 1):
@ -195,7 +194,7 @@ class Hud:
[config.supported_games[self.poker_game].stats[stat].col] = \ [config.supported_games[self.poker_game].stats[stat].col] = \
config.supported_games[self.poker_game].stats[stat].stat_name config.supported_games[self.poker_game].stats[stat].stat_name
self.mucked_window = gtk.Window() self.mucked_window = gtk.Window()
self.m = Mucked.Mucked(self.mucked_window, self.db_connection) self.m = Mucked.Mucked(self.mucked_window, self.config, self.db_name)
self.mucked_window.show_all() self.mucked_window.show_all()
def update(self, hand, config, stat_dict): def update(self, hand, config, stat_dict):
@ -217,7 +216,7 @@ class Hud:
tip = stat_dict[s]['screen_name'] + "\n" + number[5] + "\n" + \ tip = stat_dict[s]['screen_name'] + "\n" + number[5] + "\n" + \
number[3] + ", " + number[4] number[3] + ", " + number[4]
Stats.do_tip(self.stat_windows[stat_dict[s]['seat']].e_box[r][c], tip) Stats.do_tip(self.stat_windows[stat_dict[s]['seat']].e_box[r][c], tip)
# self.m.update(hand) self.m.update(hand)
def topify_window(self, window): def topify_window(self, window):
"""Set the specified gtk window to stayontop in MS Windows.""" """Set the specified gtk window to stayontop in MS Windows."""

View File

@ -45,26 +45,28 @@ import Mucked
import HandHistory import HandHistory
class Mucked: class Mucked:
def __init__(self, parent, db_connection): def __init__(self, parent, config, db_name):
self.parent = parent #this is the parent of the mucked cards widget self.config = config
self.db_connection = db_connection self.parent = parent #this is the parent of the mucked cards widget
self.db_name = db_name
self.vbox = gtk.VBox() self.vbox = gtk.VBox()
self.parent.add(self.vbox) self.parent.add(self.vbox)
self.mucked_list = MuckedList (self.vbox, db_connection) self.mucked_list = MuckedList (self.vbox, config, db_name)
self.mucked_cards = MuckedCards(self.vbox, db_connection) self.mucked_cards = MuckedCards(self.vbox, config, db_name)
self.mucked_list.mucked_cards = self.mucked_cards self.mucked_list.mucked_cards = self.mucked_cards
def update(self, new_hand_id): def update(self, new_hand_id):
self.mucked_list.update(new_hand_id) self.mucked_list.update(new_hand_id)
class MuckedList: class MuckedList:
def __init__(self, parent, db_connection): def __init__(self, parent, config, db_name):
self.parent = parent self.parent = parent
self.db_connection = db_connection self.config = config
self.db_name = db_name
# set up a scrolled window to hold the listbox # set up a scrolled window to hold the listbox
self.scrolled_window = gtk.ScrolledWindow() self.scrolled_window = gtk.ScrolledWindow()
@ -116,10 +118,11 @@ class MuckedList:
self.mucked_cards.update(new_hand_id) self.mucked_cards.update(new_hand_id)
class MuckedCards: class MuckedCards:
def __init__(self, parent, db_connection): def __init__(self, parent, config, db_name = 'fpdb'):
self.parent = parent #this is the parent of the mucked cards widget self.parent = parent #this is the parent of the mucked cards widget
self.db_connection = db_connection self.config = config
self.db_name = db_name
self.card_images = self.get_card_images() self.card_images = self.get_card_images()
self.seen_cards = {} self.seen_cards = {}
@ -173,7 +176,8 @@ class MuckedCards:
return old_cards return old_cards
def update(self, new_hand_id): def update(self, new_hand_id):
cards = self.db_connection.get_cards(new_hand_id) db_connection = Database.Database(self.config, 'fpdb', '')
cards = db_connection.get_cards(new_hand_id)
self.clear() self.clear()
cards = self.translate_cards(cards) cards = self.translate_cards(cards)
for c in cards.keys(): for c in cards.keys():
@ -185,7 +189,7 @@ class MuckedCards:
set_from_pixbuf(self.card_images[self.split_cards(cards[c][i[1]])]) set_from_pixbuf(self.card_images[self.split_cards(cards[c][i[1]])])
tips = [] tips = []
action = self.db_connection.get_action_from_hand(new_hand_id) action = db_connection.get_action_from_hand(new_hand_id)
for street in action: for street in action:
temp = '' temp = ''
for act in street: for act in street:
@ -209,6 +213,7 @@ class MuckedCards:
for round in range(1, len(tips)): for round in range(1, len(tips)):
for r in range(0, self.rows): for r in range(0, self.rows):
self.eb[(round_to_col[round], r)].set_tooltip_text(tips[round]) self.eb[(round_to_col[round], r)].set_tooltip_text(tips[round])
db_connection.close_connection()
def split_cards(self, card): def split_cards(self, card):
return (card[0], card[1].upper()) return (card[0], card[1].upper())
@ -248,12 +253,12 @@ if __name__== "__main__":
return(True) return(True)
config = Configuration.Config() config = Configuration.Config()
db_connection = Database.Database(config, 'fpdb', '') # db_connection = Database.Database(config, 'fpdb', '')
main_window = gtk.Window() main_window = gtk.Window()
main_window.set_keep_above(True) main_window.set_keep_above(True)
main_window.connect("destroy", destroy) main_window.connect("destroy", destroy)
m = Mucked(main_window, db_connection) m = Mucked(main_window, config, 'fpdb')
main_window.show_all() main_window.show_all()
s_id = gobject.io_add_watch(sys.stdin, gobject.IO_IN, process_new_hand) s_id = gobject.io_add_watch(sys.stdin, gobject.IO_IN, process_new_hand)