Merge branch 'master' of git://git.assembla.com/fpdb-eric

This commit is contained in:
Ray 2009-06-23 10:25:12 -04:00
commit 2f8918ebc9
4 changed files with 75 additions and 55 deletions

View File

@ -339,30 +339,30 @@ class Hud:
Stats.do_tip(window.e_box[r][c], tip) Stats.do_tip(window.e_box[r][c], tip)
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."""
#
def windowEnumerationHandler(hwnd, resultList): # def windowEnumerationHandler(hwnd, resultList):
'''Callback for win32gui.EnumWindows() to generate list of window handles.''' # '''Callback for win32gui.EnumWindows() to generate list of window handles.'''
resultList.append((hwnd, win32gui.GetWindowText(hwnd))) # resultList.append((hwnd, win32gui.GetWindowText(hwnd)))
# unique_name = 'unique name for finding this window'
unique_name = 'unique name for finding this window' # real_name = window.get_title()
real_name = window.get_title() # window.set_title(unique_name)
window.set_title(unique_name) # tl_windows = []
tl_windows = [] # win32gui.EnumWindows(windowEnumerationHandler, tl_windows)
win32gui.EnumWindows(windowEnumerationHandler, tl_windows) #
# for w in tl_windows:
for w in tl_windows: # if w[1] == unique_name:
if w[1] == unique_name:
self.main_window.parentgdkhandle = gtk.gdk.window_foreign_new(long(self.table.number)) self.main_window.parentgdkhandle = gtk.gdk.window_foreign_new(long(self.table.number))
self.main_window.gdkhandle = gtk.gdk.window_foreign_new(w[0]) # self.main_window.gdkhandle = gtk.gdk.window_foreign_new(w[0])
self.main_window.gdkhandle = self.main_window.window
self.main_window.gdkhandle.set_transient_for(self.main_window.parentgdkhandle) self.main_window.gdkhandle.set_transient_for(self.main_window.parentgdkhandle)
style = win32gui.GetWindowLong(self.table.number, win32con.GWL_EXSTYLE) style = win32gui.GetWindowLong(self.table.number, win32con.GWL_EXSTYLE)
style |= win32con.WS_CLIPCHILDREN style |= win32con.WS_CLIPCHILDREN
win32gui.SetWindowLong(self.table.number, win32con.GWL_EXSTYLE, style) win32gui.SetWindowLong(self.table.number, win32con.GWL_EXSTYLE, style)
break # break
window.set_title(real_name) # window.set_title(real_name)
class Stat_Window: class Stat_Window:
@ -473,6 +473,7 @@ class Popup_window:
def __init__(self, parent, stat_window): def __init__(self, parent, stat_window):
self.sb_click = 0 self.sb_click = 0
self.stat_window = stat_window self.stat_window = stat_window
self.parent = parent
# create the popup window # create the popup window
self.window = gtk.Window() self.window = gtk.Window()
@ -532,11 +533,15 @@ class Popup_window:
# db_connection.close_connection() # db_connection.close_connection()
stat_dict = stat_window.parent.stat_dict stat_dict = stat_window.parent.stat_dict
pu_text = "" pu_text = ""
mo_text = ""
for s in stat_list: for s in stat_list:
number = Stats.do_stat(stat_dict, player = int(stat_window.player_id), stat = s) 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" pu_text += number[3] + "\n"
self.lab.set_text(pu_text) self.lab.set_text(pu_text)
Stats.do_tip(self.lab, mo_text)
self.window.show_all() self.window.show_all()
self.window.set_transient_for(stat_window.window) self.window.set_transient_for(stat_window.window)
@ -572,25 +577,25 @@ class Popup_window:
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."""
def windowEnumerationHandler(hwnd, resultList): # def windowEnumerationHandler(hwnd, resultList):
'''Callback for win32gui.EnumWindows() to generate list of window handles.''' # '''Callback for win32gui.EnumWindows() to generate list of window handles.'''
resultList.append((hwnd, win32gui.GetWindowText(hwnd))) # resultList.append((hwnd, win32gui.GetWindowText(hwnd)))
unique_name = 'unique name for finding this window' # unique_name = 'unique name for finding this window'
real_name = window.get_title() # real_name = window.get_title()
window.set_title(unique_name) # window.set_title(unique_name)
tl_windows = [] # tl_windows = []
win32gui.EnumWindows(windowEnumerationHandler, tl_windows) # win32gui.EnumWindows(windowEnumerationHandler, tl_windows)
for w in tl_windows: # for w in tl_windows:
if w[1] == unique_name: # if w[1] == unique_name:
window.set_transient_for(self.parent.main_window) window.set_transient_for(self.parent.main_window)
style = win32gui.GetWindowLong(self.table.number, win32con.GWL_EXSTYLE) style = win32gui.GetWindowLong(self.table.number, win32con.GWL_EXSTYLE)
style |= win32con.WS_CLIPCHILDREN style |= win32con.WS_CLIPCHILDREN
win32gui.SetWindowLong(self.table.number, win32con.GWL_EXSTYLE, style) win32gui.SetWindowLong(self.table.number, win32con.GWL_EXSTYLE, style)
break # break
window.set_title(real_name) # window.set_title(real_name)
if __name__== "__main__": if __name__== "__main__":
main_window = gtk.Window() main_window = gtk.Window()

View File

@ -314,6 +314,10 @@ def get_site_from_exe(c, exe):
return params['site_name'] return params['site_name']
return None return None
def everleaf_decode_table(tw):
# 2 - Tournament ID: 573256 - NL Hold'em - 150/300 blinds - Good luck <username>! - [Connection is ...]
pass
def pokerstars_decode_table(tw): def pokerstars_decode_table(tw):
# Extract poker information from the window title. This is not needed for # Extract poker information from the window title. This is not needed for
# fpdb, since all that information is available in the db via new_hand_number. # fpdb, since all that information is available in the db via new_hand_number.

View File

@ -92,6 +92,8 @@ if __name__=="__main__":
print "game =", table.get_game() print "game =", table.get_game()
fake = fake_hud(table) fake = fake_hud(table)
print "fake =", fake
gobject.timeout_add(100, check_on_table, table, fake) gobject.timeout_add(100, check_on_table, table, fake)
print "calling main"
gtk.main() gtk.main()

View File

@ -65,8 +65,11 @@ class Table(Table_Window):
print "x = %s y = %s width = %s height = %s" % (x, y, width, height) print "x = %s y = %s width = %s height = %s" % (x, y, width, height)
self.x = int(x) + b_width self.x = int(x) + b_width
self.y = int(y) + tb_height self.y = int(y) + tb_height
self.height = int(height) - b_width - tb_height self.width = width - x
self.width = int(width) - 2*b_width self.height = height - y
print "x = %s y = %s width = %s height = %s" % (self.x, self.y, self.width, self.height)
#self.height = int(height) - b_width - tb_height
#self.width = int(width) - 2*b_width
self.exe = self.get_nt_exe(hwnd) self.exe = self.get_nt_exe(hwnd)
self.title = titles[hwnd] self.title = titles[hwnd]
@ -76,12 +79,13 @@ class Table(Table_Window):
self.gdkhandle = gtk.gdk.window_foreign_new(long(self.window)) self.gdkhandle = gtk.gdk.window_foreign_new(long(self.window))
def get_geometry(self): def get_geometry(self):
if not win32gui.IsWindow(self.number): # window closed
if not win32gui.IsWindow(self.window): # window closed
return None return None
try: try:
(x, y, width, height) = win32gui.GetWindowRect(hwnd) (x, y, width, height) = win32gui.GetWindowRect(self.number)
width = width - x
height = height - y
return {'x' : int(x) + b_width, return {'x' : int(x) + b_width,
'y' : int(y) + tb_height, 'y' : int(y) + tb_height,
'width' : int(height) - b_width - tb_height, 'width' : int(height) - b_width - tb_height,
@ -116,27 +120,32 @@ class Table(Table_Window):
def topify(self, hud): def topify(self, hud):
"""Set the specified gtk window to stayontop in MS Windows.""" """Set the specified gtk window to stayontop in MS Windows."""
def windowEnumerationHandler(hwnd, resultList): # def windowEnumerationHandler(hwnd, resultList):
'''Callback for win32gui.EnumWindows() to generate list of window handles.''' # '''Callback for win32gui.EnumWindows() to generate list of window handles.'''
resultList.append((hwnd, win32gui.GetWindowText(hwnd))) # resultList.append((hwnd, win32gui.GetWindowText(hwnd)))
#
unique_name = 'unique name for finding this window' # unique_name = 'unique name for finding this window'
real_name = hud.main_window.get_title() # real_name = hud.main_window.get_title()
hud.main_window.set_title(unique_name) # hud.main_window.set_title(unique_name)
tl_windows = [] # tl_windows = []
win32gui.EnumWindows(windowEnumerationHandler, tl_windows) # win32gui.EnumWindows(windowEnumerationHandler, tl_windows)
#
for w in tl_windows: # for w in tl_windows:
if w[1] == unique_name: # if w[1] == unique_name:
hud.main_window.gdkhandle = gtk.gdk.window_foreign_new(w[0]) # hud.main_window.gdkhandle = gtk.gdk.window_foreign_new(w[0])
hud.main_window.gdkhandle.set_transient_for(self.gdkhandle) hud.main_window.gdkhandle = hud.main_window.window
hud.main_window.gdkhandle.set_transient_for(self.gdkhandle)
rect = self.gdkhandle.get_frame_extents()
(innerx, innery) = self.gdkhandle.get_origin()
b_width = rect.x - innerx
tb_height = rect.y - innery
# #
# style = win32gui.GetWindowLong(self.number, win32con.GWL_EXSTYLE) # style = win32gui.GetWindowLong(self.number, win32con.GWL_EXSTYLE)
# style |= win32con.WS_CLIPCHILDREN # style |= win32con.WS_CLIPCHILDREN
# win32gui.SetWindowLong(self.number, win32con.GWL_EXSTYLE, style) # win32gui.SetWindowLong(self.number, win32con.GWL_EXSTYLE, style)
break # break
hud.main_window.set_title(real_name) # hud.main_window.set_title(real_name)
def win_enum_handler(hwnd, titles): def win_enum_handler(hwnd, titles):
titles[hwnd] = win32gui.GetWindowText(hwnd) titles[hwnd] = win32gui.GetWindowText(hwnd)