Merge branch 'eric'

trivial conflict
This commit is contained in:
steffen123 2010-09-27 22:14:37 +02:00
commit 2ecee26d99
5 changed files with 64 additions and 47 deletions

View File

@ -40,6 +40,10 @@ from optparse import OptionParser
import Configuration import Configuration
import string import string
if os.name == "nt":
import win32console
class GuiAutoImport (threading.Thread): class GuiAutoImport (threading.Thread):
def __init__(self, settings, config, sql, parent): def __init__(self, settings, config, sql, parent):
self.importtimer = 0 self.importtimer = 0
@ -211,8 +215,10 @@ class GuiAutoImport (threading.Thread):
bs = 0 bs = 0
elif os.name == 'nt': elif os.name == 'nt':
path = sys.path[0].replace('\\','\\\\') path = sys.path[0].replace('\\','\\\\')
if win32console.GetConsoleWindow() == 0:
command = 'pythonw "'+path+'\\HUD_main.pyw" ' + self.settings['cl_options'] command = 'pythonw "'+path+'\\HUD_main.pyw" ' + self.settings['cl_options']
#command = 'python "'+path+'\\HUD_main.pyw" ' + self.settings['cl_options'] else:
command = 'python "'+path+'\\HUD_main.pyw" ' + self.settings['cl_options']
# uncomment above line if you want hud_main stdout to work ... and make sure you are running fpdb.py using python.exe not pythonw.exe # uncomment above line if you want hud_main stdout to work ... and make sure you are running fpdb.py using python.exe not pythonw.exe
bs = 0 bs = 0
else: else:
@ -222,11 +228,11 @@ class GuiAutoImport (threading.Thread):
try: try:
print _("opening pipe to HUD") print _("opening pipe to HUD")
if Configuration.FROZEN: if Configuration.FROZEN or (os.name == "nt" and win32console.GetConsoleWindow()) == 0:
self.pipe_to_hud = subprocess.Popen(command, bufsize=bs, self.pipe_to_hud = subprocess.Popen(command, bufsize=bs,
stdin=subprocess.PIPE, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, # only needed for py2exe stdout=subprocess.PIPE, # needed for pythonw / py2exe
stderr=subprocess.PIPE, # only needed for py2exe stderr=subprocess.PIPE, # needed for pythonw / py2exe
universal_newlines=True universal_newlines=True
) )
else: else:

View File

@ -64,14 +64,16 @@ import locale
lang = locale.getdefaultlocale()[0][0:2] lang = locale.getdefaultlocale()[0][0:2]
print "lang:", lang print "lang:", lang
if lang == "en": if lang == "en":
def _(string): return string def _(string):
return string
else: else:
import gettext import gettext
try: try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang]) trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install() trans.install()
except IOError: except IOError:
def _(string): return string def _(string):
return string
# get config and set up logger # get config and set up logger
c = Configuration.Config(file=options.config, dbname=options.dbname) c = Configuration.Config(file=options.config, dbname=options.dbname)
@ -295,8 +297,8 @@ class HUD_main(object):
self.db_connection.init_hud_stat_vars( self.hud_dict[temp_key].hud_params['hud_days'] self.db_connection.init_hud_stat_vars( self.hud_dict[temp_key].hud_params['hud_days']
, self.hud_dict[temp_key].hud_params['h_hud_days']) , self.hud_dict[temp_key].hud_params['h_hud_days'])
t2 = time.time() t2 = time.time()
stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, type, self.hud_dict[temp_key].hud_params stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, type, self.hud_dict[temp_key].hud_params,
,self.hero_ids[site_id], num_seats) self.hero_ids[site_id], num_seats)
t3 = time.time() t3 = time.time()
try: try:
@ -321,8 +323,8 @@ class HUD_main(object):
else: else:
# get stats using default params--also get cards # get stats using default params--also get cards
self.db_connection.init_hud_stat_vars( self.hud_params['hud_days'], self.hud_params['h_hud_days'] ) self.db_connection.init_hud_stat_vars( self.hud_params['hud_days'], self.hud_params['h_hud_days'] )
stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, type, self.hud_params stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, type, self.hud_params,
,self.hero_ids[site_id], num_seats) self.hero_ids[site_id], num_seats)
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) comm_cards = self.db_connection.get_common_cards(new_hand_id)
if comm_cards != {}: # stud! if comm_cards != {}: # stud!
@ -349,7 +351,8 @@ class HUD_main(object):
% (t6 - t0,t1 - t0,t2 - t0,t3 - t0,t4 - t0,t5 - t0,t6 - t0)) % (t6 - t0,t1 - t0,t2 - t0,t3 - t0,t4 - t0,t5 - t0,t6 - t0))
self.db_connection.connection.rollback() self.db_connection.connection.rollback()
if type == "tour": if type == "tour":
tablewindow.check_table_no() tablewindow.check_table_no(None)
# Ray!! tablewindow::check_table_no expects a HUD as an argument!
if __name__== "__main__": if __name__== "__main__":
# start the HUD_main object # start the HUD_main object

View File

@ -53,6 +53,7 @@ import Mucked
import Database import Database
#import HUD_main #import HUD_main
def importName(module_name, name): def importName(module_name, name):
"""Import a named object 'name' from module 'module_name'.""" """Import a named object 'name' from module 'module_name'."""
# Recipe 16.3 in the Python Cookbook, 2nd ed. Thanks!!!! # Recipe 16.3 in the Python Cookbook, 2nd ed. Thanks!!!!
@ -63,8 +64,8 @@ def importName(module_name, name):
return None return None
return(getattr(module, name)) return(getattr(module, name))
class Hud:
class Hud:
def __init__(self, parent, table, max, poker_game, config, db_connection): def __init__(self, parent, table, max, poker_game, config, db_connection):
# __init__ is (now) intended to be called from the stdin thread, so it # __init__ is (now) intended to be called from the stdin thread, so it
# cannot touch the gui # cannot touch the gui
@ -83,7 +84,6 @@ class Hud:
self.mw_created = False self.mw_created = False
self.hud_params = parent.hud_params self.hud_params = parent.hud_params
self.stat_windows = {} self.stat_windows = {}
self.popup_windows = {} self.popup_windows = {}
self.aux_windows = [] self.aux_windows = []
@ -472,17 +472,19 @@ class Hud:
return False 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? # 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: if self.table.gdkhandle is not None:
(x, y) = 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. (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.
if self.table.x != x or self.table.y != y: # If the current position does not equal the stored position, save the new position, and then move all the sub windows. #(x, y, width, height) = self.table.get_geometry()
self.table.x = x #print "self.table.get_geometry=",x,y,width,height
self.table.y = y 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.main_window.move(x + self.site_params['xshift'], y + self.site_params['yshift']) 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) adj = self.adj_seats(self.hand, self.config)
loc = self.config.get_locations(self.table.site, self.max) 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? # 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()): for i, w in enumerate(self.stat_windows.itervalues()):
(x, y) = loc[adj[i+1]] (oldx, oldy) = loc[adj[i+1]]
w.relocate(x, y) w.relocate(oldx, oldy)
# While we're at it, fix the positions of mucked cards too # While we're at it, fix the positions of mucked cards too
for aux in self.aux_windows: for aux in self.aux_windows:

View File

@ -141,6 +141,8 @@ class Table_Window(object):
self.height = geo['height'] self.height = geo['height']
self.x = geo['x'] self.x = geo['x']
self.y = geo['y'] self.y = geo['y']
self.oldx = self.x # attn ray: remove these two lines and update Hud.py::update_table_position()
self.oldy = self.y
self.game = self.get_game() self.game = self.get_game()
@ -184,7 +186,8 @@ class Table_Window(object):
mo = re.search(self.tableno_re, new_title) mo = re.search(self.tableno_re, new_title)
if mo is not None: if mo is not None:
return mo[1] print "get_table_no: mo=",mo.groups()
return mo.group(1)
return False return False
#################################################################### ####################################################################
@ -238,6 +241,7 @@ class Table_Window(object):
return "client_destroyed" return "client_destroyed"
if self.x != new_geo['x'] or self.y != new_geo['y']: # window moved if self.x != new_geo['x'] or self.y != new_geo['y']: # window moved
print self.x, self.y, new_geo['x'], new_geo['y']
self.x = new_geo['x'] self.x = new_geo['x']
self.y = new_geo['y'] self.y = new_geo['y']
return "client_moved" return "client_moved"
@ -247,6 +251,7 @@ class Table_Window(object):
result = self.get_table_no() result = self.get_table_no()
if result != False and result != self.table: if result != False and result != self.table:
self.table = result self.table = result
if hud is not None:
hud.main_window.emit("table_changed", hud) hud.main_window.emit("table_changed", hud)
return True return True

View File

@ -80,6 +80,7 @@ class Table(Table_Window):
try: try:
(x, y, width, height) = win32gui.GetWindowRect(self.number) (x, y, width, height) = win32gui.GetWindowRect(self.number)
#print "x=",x,"y=",y,"width=",width,"height=",height
width = width - x width = width - x
height = height - y height = height - y
return {'x' : int(x) + b_width, return {'x' : int(x) + b_width,