Merge branch 'master' of git://git.assembla.com/free_poker_tools

This commit is contained in:
Worros 2009-11-18 00:14:21 +08:00
commit 36fe5d2617
2 changed files with 61 additions and 28 deletions

View File

@ -82,18 +82,19 @@ if __name__=="__main__":
(tour_no, tab_no) = table_name.split(",", 1) (tour_no, tab_no) = table_name.split(",", 1)
tour_no = tour_no.rstrip() tour_no = tour_no.rstrip()
tab_no = tab_no.rstrip() tab_no = tab_no.rstrip()
table = Tables.Table(tournament = tour_no, table_number = tab_no) table = Tables.Table(None, tournament = tour_no, table_number = tab_no)
else: # not a tournament else: # not a tournament
print "cash game" print "cash game"
table_name = table_name.rstrip() table_name = table_name.rstrip()
table = Tables.Table(table_name = table_name) table = Tables.Table(None, table_name = table_name)
table.gdk_handle = gtk.gdk.window_foreign_new(table.number)
print "table =", table print "table =", table
print "game =", table.get_game() # print "game =", table.get_game()
fake = fake_hud(table) fake = fake_hud(table)
print "fake =", fake print "fake =", fake
gobject.timeout_add(100, check_on_table, table, fake) # gobject.timeout_add(100, check_on_table, table, fake)
print "calling main" print "calling main"
gtk.main() gtk.main()

View File

@ -25,6 +25,7 @@ of Table_Window objects representing the windows found.
# Standard Library modules # Standard Library modules
import re import re
import os
# pyGTK modules # pyGTK modules
import pygtk import pygtk
@ -40,39 +41,70 @@ from TableWindow import Table_Window
# We might as well do this once and make them globals # We might as well do this once and make them globals
disp = Xlib.display.Display() disp = Xlib.display.Display()
root = disp.screen().root root = disp.screen().root
name_atom = disp.get_atom("WM_NAME", 1)
class Table(Table_Window): class Table(Table_Window):
def find_table_parameters(self, search_string): def find_table_parameters(self, search_string):
self.window = None # self.window = None
done_looping = False # done_looping = False
for outside in root.query_tree().children: # for outside in root.query_tree().children:
for inside in outside.query_tree().children: # for inside in outside.query_tree().children:
if done_looping: break # if done_looping: break
if inside.get_wm_name() and re.search(search_string, inside.get_wm_name()): # prop = inside.get_property(name_atom, Xlib.Xatom.STRING, 0, 1000)
if self.check_bad_words(inside.get_wm_name()): continue # print prop
self.window = inside # if prop is None: continue
self.parent = outside # if prop.value and re.search(search_string, prop.value):
done_looping = True # if self.check_bad_words(prop.value): continue
break ## if inside.get_wm_name() and re.search(search_string, inside.get_wm_name()):
## if self.check_bad_words(inside.get_wm_name()):
## print "bad word =", inside.get_wm_name()
## continue
# self.window = inside
# self.parent = outside
# done_looping = True
# break
if self.window == None or self.parent == None: window_number = None
for listing in os.popen('xwininfo -root -tree').readlines():
if re.search(search_string, listing):
print listing
mo = re.match('\s+([\dxabcdef]+) (.+):\s\(\"([a-zA-Z.]+)\".+ (\d+)x(\d+)\+\d+\+\d+ \+(\d+)\+(\d+)', listing)
self.number = int( mo.group(1), 0)
self.width = int( mo.group(4) )
self.height = int( mo.group(5) )
self.x = int( mo.group(6) )
self.y = int( mo.group(7) )
self.title = re.sub('\"', '', mo.group(2))
self.exe = "" # not used?
self.hud = None
# done_looping = False
# for outside in root.query_tree().children:
# for inside in outside.query_tree().children:
# if done_looping: break
# if inside.id == window_number:
# self.window = inside
# self.parent = outside
# done_looping = True
# break
if window_number is None:
print "Window %s not found. Skipping." % search_string print "Window %s not found. Skipping." % search_string
return None return None
my_geo = self.window.get_geometry() # my_geo = self.window.get_geometry()
pa_geo = self.parent.get_geometry() # pa_geo = self.parent.get_geometry()
#
# self.x = pa_geo.x + my_geo.x
# self.y = pa_geo.y + my_geo.y
# self.width = my_geo.width
# self.height = my_geo.height
# self.exe = self.window.get_wm_class()[0]
# self.title = self.window.get_wm_name()
# self.site = ""
# self.hud = None
self.x = pa_geo.x + my_geo.x # window_string = str(self.window)
self.y = pa_geo.y + my_geo.y
self.width = my_geo.width
self.height = my_geo.height
self.exe = self.window.get_wm_class()[0]
self.title = self.window.get_wm_name()
self.site = ""
self.hud = None
window_string = str(self.window)
mo = re.match('Xlib\.display\.Window\(([\dxabcdef]+)', window_string) mo = re.match('Xlib\.display\.Window\(([\dxabcdef]+)', window_string)
if not mo: if not mo:
print "Not matched" print "Not matched"