Merge branch 'new_hud' of /home/reb402/workspace/free_poker_tools

This commit is contained in:
Eratosthenes 2011-01-30 16:51:00 -05:00
commit 36cdc9f35a
4 changed files with 184 additions and 490 deletions

4
pyfpdb/HUD_main.pyw Executable file → Normal file
View File

@ -357,8 +357,8 @@ def idle_create(hud_main, new_hand_id, table, temp_key, max, poker_game, type, s
for m in hud_main.hud_dict[temp_key].aux_windows:
m.create()
m.update_gui(new_hand_id)
hud_main.hud_dict[temp_key].update(new_hand_id, hud_main.config)
hud_main.hud_dict[temp_key].reposition_windows()
# hud_main.hud_dict[temp_key].update(new_hand_id, hud_main.config)
# hud_main.hud_dict[temp_key].reposition_windows()
except:
log.exception(_("Error creating HUD for hand %s.") % new_hand_id)
finally:

View File

@ -372,17 +372,17 @@ class Hud:
self.main_window.show_all()
self.topify_window(self.main_window)
def change_max_seats(self, widget):
if self.max != widget.ms:
#print 'change_max_seats', widget.ms
self.max = widget.ms
try:
self.kill()
self.create(*self.creation_attrs)
self.update(self.hand, self.config)
except Exception, e:
log.error("Exception:",str(e))
pass
# def change_max_seats(self, widget):
# if self.max != widget.ms:
# #print 'change_max_seats', widget.ms
# self.max = widget.ms
# try:
# self.kill()
# self.create(*self.creation_attrs)
# self.update(self.hand, self.config)
# except Exception, e:
# log.error("Exception:",str(e))
# pass
def set_aggregation(self, widget, val):
(player_opp, num) = val
@ -456,69 +456,69 @@ class Hud:
getattr(self, prefix+'hudStyleOptionS').set_active(False)
log.debug("setting self.hud_params[%s] = %s" % (param, style))
def update_table_position(self):
# get table's X/Y position on the desktop, and relocate all of our child windows to accomodate
# In Windows, we can verify the existence of a Window, with win32gui.IsWindow(). In Linux, there doesn't seem to be a
# way to verify the existence of a Window, without trying to access it, which if it doesn't exist anymore, results in a
# big giant X trap and crash.
# People tell me this is a bad idea, because theoretically, IsWindow() could return true now, but not be true when we actually
# use it, but accessing a dead window doesn't result in a complete windowing system shutdown in Windows, whereas it does
# in X. - Eric
if os.name == 'nt':
if not win32gui.IsWindow(self.table.number):
self.parent.kill_hud(self, self.table.name)
self.parent.kill_hud(self, self.table.name.split(" ")[0])
#table.name is only a valid handle for ring games ! we are not killing tourney tables here.
return False
# anyone know how to do this in unix, or better yet, trap the X11 error that is triggered when executing the get_origin() for a closed window?
if self.table.gdkhandle is not None:
(oldx, oldy) = self.table.gdkhandle.get_origin() # In Windows, this call returns (0,0) if it's an invalid window. In X, the X server is immediately killed.
#(x, y, width, height) = self.table.get_geometry()
#print "self.table.get_geometry=",x,y,width,height
if self.table.oldx != oldx or self.table.oldy != oldy: # If the current position does not equal the stored position, save the new position, and then move all the sub windows.
self.table.oldx = oldx
self.table.oldy = oldy
self.main_window.move(oldx + self.site_params['xshift'], oldy + self.site_params['yshift'])
adj = self.adj_seats(self.hand, self.config)
loc = self.config.get_locations(self.table.site, self.max)
# TODO: is stat_windows getting converted somewhere from a list to a dict, for no good reason?
for i, w in enumerate(self.stat_windows.itervalues()):
(oldx, oldy) = loc[adj[i+1]]
w.relocate(oldx, oldy)
# def update_table_position(self):
# # get table's X/Y position on the desktop, and relocate all of our child windows to accomodate
# # In Windows, we can verify the existence of a Window, with win32gui.IsWindow(). In Linux, there doesn't seem to be a
# # way to verify the existence of a Window, without trying to access it, which if it doesn't exist anymore, results in a
# # big giant X trap and crash.
# # People tell me this is a bad idea, because theoretically, IsWindow() could return true now, but not be true when we actually
# # use it, but accessing a dead window doesn't result in a complete windowing system shutdown in Windows, whereas it does
# # in X. - Eric
# if os.name == 'nt':
# if not win32gui.IsWindow(self.table.number):
# self.parent.kill_hud(self, self.table.name)
# self.parent.kill_hud(self, self.table.name.split(" ")[0])
# #table.name is only a valid handle for ring games ! we are not killing tourney tables here.
# return False
# # anyone know how to do this in unix, or better yet, trap the X11 error that is triggered when executing the get_origin() for a closed window?
# if self.table.gdkhandle is not None:
# (oldx, oldy) = self.table.gdkhandle.get_origin() # In Windows, this call returns (0,0) if it's an invalid window. In X, the X server is immediately killed.
# #(x, y, width, height) = self.table.get_geometry()
# #print "self.table.get_geometry=",x,y,width,height
# if self.table.oldx != oldx or self.table.oldy != oldy: # If the current position does not equal the stored position, save the new position, and then move all the sub windows.
# self.table.oldx = oldx
# self.table.oldy = oldy
# self.main_window.move(oldx + self.site_params['xshift'], oldy + self.site_params['yshift'])
# adj = self.adj_seats(self.hand, self.config)
# loc = self.config.get_locations(self.table.site, self.max)
# # TODO: is stat_windows getting converted somewhere from a list to a dict, for no good reason?
# for i, w in enumerate(self.stat_windows.itervalues()):
# (oldx, oldy) = loc[adj[i+1]]
# w.relocate(oldx, oldy)
#
# # While we're at it, fix the positions of mucked cards too
# for aux in self.aux_windows:
# aux.update_card_positions()
#
# self.reposition_windows()
# # call reposition_windows, which apparently moves even hidden windows, where this function does not, even though they do the same thing, afaict
#
# return True
# While we're at it, fix the positions of mucked cards too
for aux in self.aux_windows:
aux.update_card_positions()
# def up_update_table_position(self):
## callback for table moved
#
## move the stat windows
# adj = self.adj_seats(self.hand, self.config)
# loc = self.config.get_locations(self.table.site, self.max)
# for i, w in enumerate(self.stat_windows.itervalues()):
# (x, y) = loc[adj[i+1]]
# w.relocate(x, y)
## move the main window
# self.main_window.move(self.table.x + self.site_params['xshift'], self.table.y + self.site_params['yshift'])
## and move any auxs
# for aux in self.aux_windows:
# aux.update_card_positions()
# return True
self.reposition_windows()
# call reposition_windows, which apparently moves even hidden windows, where this function does not, even though they do the same thing, afaict
return True
def up_update_table_position(self):
# callback for table moved
# move the stat windows
adj = self.adj_seats(self.hand, self.config)
loc = self.config.get_locations(self.table.site, self.max)
for i, w in enumerate(self.stat_windows.itervalues()):
(x, y) = loc[adj[i+1]]
w.relocate(x, y)
# move the main window
self.main_window.move(self.table.x + self.site_params['xshift'], self.table.y + self.site_params['yshift'])
# and move any auxs
for aux in self.aux_windows:
aux.update_card_positions()
return True
def on_button_press(self, widget, event):
if event.button == 1: # if primary button, start movement
self.main_window.begin_move_drag(event.button, int(event.x_root), int(event.y_root), event.time)
return True
if event.button == 3: # if secondary button, popup our main popup window
widget.popup(None, None, None, event.button, event.time)
return True
return False
# def on_button_press(self, widget, event):
# if event.button == 1: # if primary button, start movement
# self.main_window.begin_move_drag(event.button, int(event.x_root), int(event.y_root), event.time)
# return True
# if event.button == 3: # if secondary button, popup our main popup window
# widget.popup(None, None, None, event.button, event.time)
# return True
# return False
def kill(self, *args):
# kill all stat_windows, popups and aux_windows in this HUD
@ -536,46 +536,46 @@ class Hud:
aux.destroy()
self.aux_windows = []
def resize_windows(self, *args):
for w in self.stat_windows.itervalues():
if type(w) == int:
continue
rel_x = (w.x - self.table.x) * self.table.width / self.table.oldwidth
rel_y = (w.y - self.table.y) * self.table.height / self.table.oldheight
w.x = self.table.x + rel_x
w.y = self.table.y + rel_y
w.window.move(w.x, w.y)
# def resize_windows(self, *args):
# for w in self.stat_windows.itervalues():
# if type(w) == int:
# continue
# rel_x = (w.x - self.table.x) * self.table.width / self.table.oldwidth
# rel_y = (w.y - self.table.y) * self.table.height / self.table.oldheight
# w.x = self.table.x + rel_x
# w.y = self.table.y + rel_y
# w.window.move(w.x, w.y)
#
# def reposition_windows(self, *args):
# self.update_table_position()
# for w in self.stat_windows.itervalues():
# if type(w) == int:
## print "in reposition, w =", w
# continue
## print "in reposition, w =", w, w.x, w.y
# w.window.move(w.x, w.y)
# return True
def reposition_windows(self, *args):
self.update_table_position()
for w in self.stat_windows.itervalues():
if type(w) == int:
# print "in reposition, w =", w
continue
# print "in reposition, w =", w, w.x, w.y
w.window.move(w.x, w.y)
return True
def debug_stat_windows(self, *args):
# print self.table, "\n", self.main_window.window.get_transient_for()
for w in self.stat_windows:
try:
print self.stat_windows[w].window.window.get_transient_for()
except AttributeError:
print "this window doesnt have get_transient_for"
def save_layout(self, *args):
new_layout = [(0, 0)] * self.max
for sw in self.stat_windows:
loc = self.stat_windows[sw].window.get_position()
new_loc = (loc[0] - self.table.x, loc[1] - self.table.y)
new_layout[self.stat_windows[sw].adj - 1] = new_loc
self.config.edit_layout(self.table.site, self.max, locations=new_layout)
# ask each aux to save its layout back to the config object
[aux.save_layout() for aux in self.aux_windows]
# save the config object back to the file
print _("Updating config file")
self.config.save()
# def debug_stat_windows(self, *args):
## print self.table, "\n", self.main_window.window.get_transient_for()
# for w in self.stat_windows:
# try:
# print self.stat_windows[w].window.window.get_transient_for()
# except AttributeError:
# print "this window doesnt have get_transient_for"
#
# def save_layout(self, *args):
# new_layout = [(0, 0)] * self.max
# for sw in self.stat_windows:
# loc = self.stat_windows[sw].window.get_position()
# new_loc = (loc[0] - self.table.x, loc[1] - self.table.y)
# new_layout[self.stat_windows[sw].adj - 1] = new_loc
# self.config.edit_layout(self.table.site, self.max, locations=new_layout)
## ask each aux to save its layout back to the config object
# [aux.save_layout() for aux in self.aux_windows]
## save the config object back to the file
# print _("Updating config file")
# self.config.save()
def adj_seats(self, hand, config):
# determine how to adjust seating arrangements, if a "preferred seat" is set in the hud layout configuration
@ -616,367 +616,68 @@ class Hud:
self.creation_attrs = hand, config, stat_dict, cards
self.hand = hand
if not self.mw_created:
self.create_mw()
# if not self.mw_created:
# self.create_mw()
self.stat_dict = stat_dict
self.cards = cards
log.info(_('Creating hud from hand ')+str(hand))
adj = self.adj_seats(hand, config)
loc = self.config.get_locations(self.table.site, self.max)
if loc is None and self.max != 10:
loc = self.config.get_locations(self.table.site, 10)
if loc is None and self.max != 9:
loc = self.config.get_locations(self.table.site, 9)
# create the stat windows
for i in xrange(1, self.max + 1):
(x, y) = loc[adj[i]]
if i in self.stat_windows:
self.stat_windows[i].relocate(x, y)
else:
self.stat_windows[i] = Stat_Window(game = config.supported_games[self.poker_game],
parent = self,
table = self.table,
x = x,
y = y,
seat = i,
adj = adj[i],
player_id = 'fake',
font = self.font)
self.stats = []
game = config.supported_games[self.poker_game]
for i in xrange(0, game.rows + 1):
row_list = [''] * game.cols
self.stats.append(row_list)
for stat in game.stats:
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
# if os.name == "nt": # we call update_table_position() regularly in Windows to see if we're moving around. See comments on that function for why this isn't done in X.
# gobject.timeout_add(500, self.update_table_position)
def update(self, hand, config):
self.hand = hand # this is the last hand, so it is available later
if os.name == 'nt':
if self.update_table_position() == False: # we got killed by finding our table was gone
return
self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudfgcolor']))
for s in self.stat_dict:
try:
statd = self.stat_dict[s]
except KeyError:
log.error(_("KeyError at the start of the for loop in update in hud_main. How this can possibly happen is totally beyond my comprehension. Your HUD may be about to get really weird. -Eric"))
log.error(_("(btw, the key was %s and statd is %s") % (s, statd))
continue
try:
self.stat_windows[statd['seat']].player_id = statd['player_id']
#self.stat_windows[self.stat_dict[s]['seat']].player_id = self.stat_dict[s]['player_id']
except KeyError: # omg, we have more seats than stat windows .. damn poker sites with incorrect max seating info .. let's force 10 here
self.max = 10
self.create(hand, config, self.stat_dict, self.cards)
self.stat_windows[statd['seat']].player_id = statd['player_id']
for r in xrange(0, config.supported_games[self.poker_game].rows):
for c in xrange(0, config.supported_games[self.poker_game].cols):
this_stat = config.supported_games[self.poker_game].stats[self.stats[r][c]]
number = Stats.do_stat(self.stat_dict, player = statd['player_id'], stat = self.stats[r][c])
statstring = "%s%s%s" % (this_stat.hudprefix, str(number[1]), this_stat.hudsuffix)
window = self.stat_windows[statd['seat']]
if this_stat.hudcolor != "":
window.label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(this_stat.hudcolor))
else:
window.label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudfgcolor']))
if this_stat.stat_loth != "":
if number[0] < (float(this_stat.stat_loth)/100):
window.label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(this_stat.stat_locolor))
if this_stat.stat_hith != "":
if number[0] > (float(this_stat.stat_hith)/100):
window.label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(this_stat.stat_hicolor))
window.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?
unhidewindow = True
tip = "%s\n%s\n%s, %s" % (statd['screen_name'], number[5], number[3], number[4])
Stats.do_tip(window.e_box[r][c], tip)
if unhidewindow: #and not window.window.visible: # there is no "visible" attribute in gtk.Window, although the docs seem to indicate there should be
window.window.show_all()
unhidewindow = False
def topify_window(self, window):
window.set_focus_on_map(False)
window.set_accept_focus(False)
if not self.table.gdkhandle:
self.table.gdkhandle = gtk.gdk.window_foreign_new(int(self.table.number)) # gtk handle to poker window
window.window.set_transient_for(self.table.gdkhandle)
class Stat_Window:
def button_press_cb(self, widget, event, *args):
# This handles all callbacks from button presses on the event boxes in
# the stat windows. There is a bit of an ugly kludge to separate single-
# and double-clicks.
self.window.show() #_all()
if event.button == 3: # right button event
newpopup = Popup_window(self.window, self)
#print "added popup", newpopup
# TODO: how should we go about making sure it doesn't open a dozen popups if you click?
self.popups.append(newpopup)
return True
if event.button == 2: # middle button event
self.window.hide()
return True
if event.button == 1: # left button event
# close on double click for a stat window
# for those that don't have a mouse with middle button
if event.type == gtk.gdk._2BUTTON_PRESS:
self.window.hide()
return True
# TODO: make position saving save sizes as well?
if event.state & gtk.gdk.SHIFT_MASK:
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)
return True
return False
def noop(self, arga=None, argb=None): # i'm going to try to connect the focus-in and focus-out events here, to see if that fixes any of the focus problems.
return True
def kill_popup(self, popup):
#print "remove popup", popup
self.popups.remove(popup)
popup.window.destroy()
def kill_popups(self):
map(lambda x: x.window.destroy(), self.popups)
self.popups = { }
def relocate(self, x, y):
self.x = x + self.table.x
self.y = y + self.table.y
self.window.move(self.x, self.y)
def __init__(self, parent, game, table, seat, adj, x, y, player_id, font):
self.parent = parent # Hud object that this stat window belongs to
self.game = game # Configuration object for the curren
self.table = table # Table object where this is going
self.seat = seat # seat number of his player
self.adj = adj # the adjusted seat number for this player
self.x = x + table.x # table.x and y are the location of the table
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()
self.window.set_decorated(0)
self.window.set_property("skip-taskbar-hint", True)
self.window.set_gravity(gtk.gdk.GRAVITY_STATIC)
self.window.set_title("%s" % seat)
self.window.set_focus(None) # set gtk default focus widget for this window to None
self.window.set_focus_on_map(False)
self.window.set_accept_focus(False)
grid = gtk.Table(rows = game.rows, columns = game.cols, homogeneous = False)
self.grid = grid
self.window.add(grid)
self.window.modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor)
self.e_box = []
self.frame = []
self.label = []
usegtkframes = self.useframes
e_box = self.e_box
label = self.label
for r in xrange(game.rows):
if usegtkframes:
self.frame.append([])
e_box.append([])
label.append([])
for c in xrange(game.cols):
if usegtkframes:
self.frame[r].append( gtk.Frame() )
e_box[r].append( gtk.EventBox() )
e_box[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor)
e_box[r][c].modify_fg(gtk.STATE_NORMAL, parent.foregroundcolor)
Stats.do_tip(e_box[r][c], 'stuff')
if usegtkframes:
grid.attach(self.frame[r][c], c, c+1, r, r+1, xpadding = game.xpad, ypadding = game.ypad)
self.frame[r][c].add(e_box[r][c])
else:
grid.attach(e_box[r][c], c, c+1, r, r+1, xpadding = game.xpad, ypadding = game.ypad)
label[r].append( gtk.Label('xxx') )
if usegtkframes:
self.frame[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor)
label[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor)
label[r][c].modify_fg(gtk.STATE_NORMAL, parent.foregroundcolor)
e_box[r][c].add(self.label[r][c])
e_box[r][c].connect("button_press_event", self.button_press_cb)
e_box[r][c].connect("focus-in-event", self.noop)
e_box[r][c].connect("focus", self.noop)
e_box[r][c].connect("focus-out-event", self.noop)
label[r][c].modify_font(font)
self.window.set_opacity(parent.colors['hudopacity'])
self.window.connect("focus", self.noop)
self.window.connect("focus-in-event", self.noop)
self.window.connect("focus-out-event", self.noop)
self.window.connect("button_press_event", self.button_press_cb)
self.window.set_focus_on_map(False)
self.window.set_accept_focus(False)
self.window.move(self.x, self.y)
self.window.realize() # window must be realized before it has a gdkwindow so we can attach it to the table window..
self.topify_window(self.window)
self.window.hide()
def topify_window(self, window):
window.set_focus_on_map(False)
window.set_accept_focus(False)
if not self.table.gdkhandle:
self.table.gdkhandle = gtk.gdk.window_foreign_new(int(self.table.number)) # gtk handle to poker window
# window.window.reparent(self.table.gdkhandle, 0, 0)
window.window.set_transient_for(self.table.gdkhandle)
# window.present()
def destroy(*args): # call back for terminating the main eventloop
gtk.main_quit()
class Popup_window:
def __init__(self, parent, stat_window):
self.sb_click = 0
self.stat_window = stat_window
self.parent = parent
# create the popup window
self.window = gtk.Window()
self.window.set_decorated(0)
self.window.set_gravity(gtk.gdk.GRAVITY_STATIC)
self.window.set_title("popup")
self.window.set_property("skip-taskbar-hint", True)
self.window.set_focus_on_map(False)
self.window.set_accept_focus(False)
self.window.set_transient_for(parent.get_toplevel())
self.window.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
self.ebox = gtk.EventBox()
self.ebox.connect("button_press_event", self.button_press_cb)
self.lab = gtk.Label("stuff\nstuff\nstuff")
# need an event box so we can respond to clicks
self.window.add(self.ebox)
self.ebox.add(self.lab)
self.ebox.modify_bg(gtk.STATE_NORMAL, stat_window.parent.backgroundcolor)
self.ebox.modify_fg(gtk.STATE_NORMAL, stat_window.parent.foregroundcolor)
self.window.modify_bg(gtk.STATE_NORMAL, stat_window.parent.backgroundcolor)
self.window.modify_fg(gtk.STATE_NORMAL, stat_window.parent.foregroundcolor)
self.lab.modify_bg(gtk.STATE_NORMAL, stat_window.parent.backgroundcolor)
self.lab.modify_fg(gtk.STATE_NORMAL, stat_window.parent.foregroundcolor)
# figure out the row, col address of the click that activated the popup
row = 0
col = 0
for r in xrange(0, stat_window.game.rows):
for c in xrange(0, stat_window.game.cols):
if stat_window.e_box[r][c] == parent:
row = r
col = c
break
# figure out what popup format we're using
popup_format = "default"
for stat in stat_window.game.stats:
if stat_window.game.stats[stat].row == row and stat_window.game.stats[stat].col == col:
popup_format = stat_window.game.stats[stat].popup
break
# get the list of stats to be presented from the config
stat_list = []
for w in stat_window.parent.config.popup_windows:
if w == popup_format:
stat_list = stat_window.parent.config.popup_windows[w].pu_stats
break
# get a database connection
# db_connection = Database.Database(stat_window.parent.config, stat_window.parent.db_name, 'temp')
# calculate the stat_dict and then create the text for the pu
# stat_dict = db_connection.get_stats_from_hand(stat_window.parent.hand, stat_window.player_id)
# stat_dict = self.db_connection.get_stats_from_hand(stat_window.parent.hand)
# db_connection.close_connection()
stat_dict = stat_window.parent.stat_dict
pu_text = ""
mo_text = ""
for s in stat_list:
number = Stats.do_stat(stat_dict, player = int(stat_window.player_id), stat = s)
mo_text += number[5] + " " + number[4] + "\n"
pu_text += number[3] + "\n"
self.lab.set_text(pu_text)
Stats.do_tip(self.lab, mo_text)
self.window.show_all()
self.window.set_transient_for(stat_window.window)
def button_press_cb(self, widget, event, *args):
# This handles all callbacks from button presses on the event boxes in
# the popup windows. There is a bit of an ugly kludge to separate single-
# and double-clicks. This is the same code as in the Stat_window class
if event.button == 1: # left button event
pass
if event.button == 2: # middle button event
pass
if event.button == 3: # right button event
self.stat_window.kill_popup(self)
return True
# self.window.destroy()
return False
def toggle_decorated(self, widget):
top = widget.get_toplevel()
(x, y) = top.get_position()
if top.get_decorated():
top.set_decorated(0)
top.move(x, y)
else:
top.set_decorated(1)
top.move(x, y)
def topify_window(self, window):
window.set_focus_on_map(False)
window.set_accept_focus(False)
if not self.table.gdkhandle:
self.table.gdkhandle = gtk.gdk.window_foreign_new(int(self.table.number)) # gtk handle to poker window
# window.window.reparent(self.table.gdkhandle, 0, 0)
window.window.set_transient_for(self.table.gdkhandle)
# window.present()
# if os.name == 'nt':
# if self.update_table_position() == False: # we got killed by finding our table was gone
# return
#
# self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudfgcolor']))
# for s in self.stat_dict:
# try:
# statd = self.stat_dict[s]
# except KeyError:
# log.error(_("KeyError at the start of the for loop in update in hud_main. How this can possibly happen is totally beyond my comprehension. Your HUD may be about to get really weird. -Eric"))
# log.error(_("(btw, the key was %s and statd is %s") % (s, statd))
# continue
# try:
# self.stat_windows[statd['seat']].player_id = statd['player_id']
# #self.stat_windows[self.stat_dict[s]['seat']].player_id = self.stat_dict[s]['player_id']
# except KeyError: # omg, we have more seats than stat windows .. damn poker sites with incorrect max seating info .. let's force 10 here
# self.max = 10
# self.create(hand, config, self.stat_dict, self.cards)
# self.stat_windows[statd['seat']].player_id = statd['player_id']
#
# for r in xrange(0, config.supported_games[self.poker_game].rows):
# for c in xrange(0, config.supported_games[self.poker_game].cols):
# this_stat = config.supported_games[self.poker_game].stats[self.stats[r][c]]
# number = Stats.do_stat(self.stat_dict, player = statd['player_id'], stat = self.stats[r][c])
# statstring = "%s%s%s" % (this_stat.hudprefix, str(number[1]), this_stat.hudsuffix)
# window = self.stat_windows[statd['seat']]
#
# if this_stat.hudcolor != "":
# window.label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(this_stat.hudcolor))
# else:
# window.label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudfgcolor']))
#
# if this_stat.stat_loth != "":
# if number[0] < (float(this_stat.stat_loth)/100):
# window.label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(this_stat.stat_locolor))
#
# if this_stat.stat_hith != "":
# if number[0] > (float(this_stat.stat_hith)/100):
# window.label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(this_stat.stat_hicolor))
#
# window.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?
# unhidewindow = True
# tip = "%s\n%s\n%s, %s" % (statd['screen_name'], number[5], number[3], number[4])
# Stats.do_tip(window.e_box[r][c], tip)
# if unhidewindow: #and not window.window.visible: # there is no "visible" attribute in gtk.Window, although the docs seem to indicate there should be
# window.window.show_all()
# unhidewindow = False
#
# def topify_window(self, window):
# window.set_focus_on_map(False)
# window.set_accept_focus(False)
#
# if not self.table.gdkhandle:
# self.table.gdkhandle = gtk.gdk.window_foreign_new(int(self.table.number)) # gtk handle to poker window
# window.window.set_transient_for(self.table.gdkhandle)

View File

@ -25,17 +25,12 @@ Mucked cards display for FreePokerTools HUD.
# to do
# Standard Library modules
#import sys
#import pprint
# pyGTK modules
#import pygtk
import gtk
import gobject
# FreePokerTools modules
#import Configuration
#import Database
import Card
class Aux_Window(object):
@ -390,8 +385,9 @@ class Aux_Seats(Aux_Window):
self.m_windows[i] = self.aw_window_type(self)
self.m_windows[i].set_decorated(False)
self.m_windows[i].set_property("skip-taskbar-hint", True)
self.m_windows[i].set_transient_for(self.hud.main_window) # FIXME: shouldn't this be the table window??
self.m_windows[i].set_focus_on_map(False)
self.m_windows[i].set_focus(None)
self.m_windows[i].set_accept_focus(False)
self.m_windows[i].connect("configure_event", self.configure_event_cb, i)
self.positions[i] = self.card_positions((x * width) / 1000, self.hud.table.x, (y * height) /1000, self.hud.table.y)
self.m_windows[i].move(self.positions[i][0], self.positions[i][1])
@ -401,6 +397,8 @@ class Aux_Seats(Aux_Window):
# the create_contents method is supplied by the subclass
self.create_contents(self.m_windows[i], i)
self.m_windows[i].realize()
self.hud.table.topify(self.m_windows[i])
self.m_windows[i].show_all()
if self.uses_timer:
self.m_windows[i].hide()

View File

@ -67,19 +67,6 @@ class Table(Table_Window):
return None
(self.window, self.parent) = self.get_window_from_xid(self.number)
# def get_window_from_xid(self, id):
# for outside in root.query_tree().children:
# if outside.id == id:
# return (outside, outside.query_tree().parent)
# for inside in outside.query_tree().children:
# if inside.id == id: # GNOME, Xfce
# return (inside, inside.query_tree().parent)
# for wayinside in inside.query_tree().children:
# if wayinside.id == id: # KDE
# parent = wayinside.query_tree().parent
# return (wayinside, parent.query_tree().parent)
# return (None, None)
def get_window_from_xid(self, id):
for top_level in root.query_tree().children:
if top_level.id == id:
@ -120,8 +107,16 @@ class Table(Table_Window):
# as the argument. This should keep the HUD window on top of the table window, as if
# the hud window was a dialog belonging to the table.
# This is the gdkhandle for the HUD window
# X doesn't like calling the foreign_new function in XTables.
# Nope don't know why. Moving it here seems to make X happy.
if self.gdkhandle is None:
self.gdkhandle = gtk.gdk.window_foreign_new(int(self.number))
# This is the gdkhandle for the HUD window
gdkwindow = gtk.gdk.window_foreign_new(window.window.xid)
# Then call set_transient_for on the gdk handle of the HUD window
# with the gdk handle of the table window as the argument.
gdkwindow.set_transient_for(self.gdkhandle)
def treewalk(parent):