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 string
if os.name == "nt":
import win32console
class GuiAutoImport (threading.Thread):
def __init__(self, settings, config, sql, parent):
self.importtimer = 0
@ -211,8 +215,10 @@ class GuiAutoImport (threading.Thread):
bs = 0
elif os.name == 'nt':
path = sys.path[0].replace('\\','\\\\')
if win32console.GetConsoleWindow() == 0:
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
bs = 0
else:
@ -222,11 +228,11 @@ class GuiAutoImport (threading.Thread):
try:
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,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE, # only needed for py2exe
stderr=subprocess.PIPE, # only needed for py2exe
stdout=subprocess.PIPE, # needed for pythonw / py2exe
stderr=subprocess.PIPE, # needed for pythonw / py2exe
universal_newlines=True
)
else:

View File

@ -64,14 +64,16 @@ import locale
lang = locale.getdefaultlocale()[0][0:2]
print "lang:", lang
if lang == "en":
def _(string): return string
def _(string):
return string
else:
import gettext
try:
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
trans.install()
except IOError:
def _(string): return string
def _(string):
return string
# get config and set up logger
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.hud_dict[temp_key].hud_params['h_hud_days'])
t2 = time.time()
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)
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)
t3 = time.time()
try:
@ -321,8 +323,8 @@ class HUD_main(object):
else:
# 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'] )
stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, type, self.hud_params
,self.hero_ids[site_id], num_seats)
stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, type, self.hud_params,
self.hero_ids[site_id], num_seats)
cards = self.db_connection.get_cards(new_hand_id)
comm_cards = self.db_connection.get_common_cards(new_hand_id)
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))
self.db_connection.connection.rollback()
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__":
# start the HUD_main object

View File

@ -53,6 +53,7 @@ import Mucked
import Database
#import HUD_main
def importName(module_name, name):
"""Import a named object 'name' from module 'module_name'."""
# Recipe 16.3 in the Python Cookbook, 2nd ed. Thanks!!!!
@ -63,8 +64,8 @@ def importName(module_name, name):
return None
return(getattr(module, name))
class Hud:
class Hud:
def __init__(self, parent, table, max, poker_game, config, db_connection):
# __init__ is (now) intended to be called from the stdin thread, so it
# cannot touch the gui
@ -83,7 +84,6 @@ class Hud:
self.mw_created = False
self.hud_params = parent.hud_params
self.stat_windows = {}
self.popup_windows = {}
self.aux_windows = []
@ -472,17 +472,19 @@ class Hud:
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:
(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.
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.
self.table.x = x
self.table.y = y
self.main_window.move(x + self.site_params['xshift'], y + self.site_params['yshift'])
(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()):
(x, y) = loc[adj[i+1]]
w.relocate(x, y)
(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:

View File

@ -141,6 +141,8 @@ class Table_Window(object):
self.height = geo['height']
self.x = geo['x']
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()
@ -184,7 +186,8 @@ class Table_Window(object):
mo = re.search(self.tableno_re, new_title)
if mo is not None:
return mo[1]
print "get_table_no: mo=",mo.groups()
return mo.group(1)
return False
####################################################################
@ -238,6 +241,7 @@ class Table_Window(object):
return "client_destroyed"
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.y = new_geo['y']
return "client_moved"
@ -247,6 +251,7 @@ class Table_Window(object):
result = self.get_table_no()
if result != False and result != self.table:
self.table = result
if hud is not None:
hud.main_window.emit("table_changed", hud)
return True

View File

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