From 66cbf49cdcc6059b4f8ae332393deaf72fff9b02 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Sat, 31 Jul 2010 20:55:29 +0100 Subject: [PATCH 1/2] store column info for cash stats in config. Can now enhance gui to let user change column choices --- pyfpdb/Configuration.py | 44 ++++++++++++++++++++++++++ pyfpdb/GuiPrefs.py | 2 +- pyfpdb/GuiRingPlayerStats.py | 61 +++++++++++++++++++----------------- 3 files changed, 77 insertions(+), 30 deletions(-) diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index 03858760..27190022 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -500,6 +500,41 @@ class General(dict): s = s + " %s = %s\n" % (k, self[k]) return(s) +class GUICashStats(list): + """ + + ... + + """ + def __init__(self): + super(GUICashStats, self).__init__() + + def add_elements(self, node): + # is this needed? + for child in node.childNodes: + if child.nodeType == child.ELEMENT_NODE: + col_name, col_title, disp_all, disp_posn, field_format, field_type, xalignment=None, None, True, True, "%s", "str", 0.0 + + if child.hasAttribute('col_name'): col_name = child.getAttribute('col_name') + if child.hasAttribute('col_title'): col_title = child.getAttribute('col_title') + if child.hasAttribute('disp_all'): disp_all = string_to_bool(child.getAttribute('disp_all')) + if child.hasAttribute('disp_posn'): disp_posn = string_to_bool(child.getAttribute('disp_posn')) + if child.hasAttribute('field_format'): field_format = child.getAttribute('field_format') + if child.hasAttribute('field_type'): field_type = child.getAttribute('field_type') + try: + if child.hasAttribute('xalignment'): xalignment = float(child.getAttribute('xalignment')) + except ValueError: + print "bad number in xalignment was ignored" + log.info("bad number in xalignment was ignored") + + self.append( [col_name, col_title, disp_all, disp_posn, field_format, field_type, xalignment] ) + +# def __str__(self): +# s = "" +# for l in self: +# s = s + " %s = %s\n" % (k, self[k]) +# return(s) + class Config: def __init__(self, file = None, dbname = ''): # "file" is a path to an xml file with the fpdb/HUD configuration @@ -555,10 +590,14 @@ class Config: self.db_selected = None # database the user would like to use self.tv = None self.general = General() + self.gui_cash_stats = GUICashStats() for gen_node in doc.getElementsByTagName("general"): self.general.add_elements(node=gen_node) # add/overwrite elements in self.general + for gcs_node in doc.getElementsByTagName("gui_cash_stats"): + self.gui_cash_stats.add_elements(node=gcs_node) # add/overwrite elements in self.gui_cash_stats + # s_sites = doc.getElementsByTagName("supported_sites") for site_node in doc.getElementsByTagName("site"): site = Site(node = site_node) @@ -1146,6 +1185,9 @@ class Config: def get_general_params(self): return( self.general ) + def get_gui_cash_stat_params(self): + return( self.gui_cash_stats ) + if __name__== "__main__": c = Config() @@ -1219,6 +1261,8 @@ if __name__== "__main__": print "start up path = ", c.execution_path("") + print "gui_cash_stats =", c.gui_cash_stats + try: from xml.dom.ext import PrettyPrint for site_node in c.doc.getElementsByTagName("site"): diff --git a/pyfpdb/GuiPrefs.py b/pyfpdb/GuiPrefs.py index 15ae7338..c706e88c 100755 --- a/pyfpdb/GuiPrefs.py +++ b/pyfpdb/GuiPrefs.py @@ -95,7 +95,7 @@ class GuiPrefs: if node.hasAttributes(): for i in xrange(node.attributes.length): self.configStore.append( iter, [node, node.attributes.item(i).localName, node.attributes.item(i).value] ) - if node.attributes.item(i).localName in ('site_name', 'game_name', 'stat_name', 'name', 'db_server', 'site'): + if node.attributes.item(i).localName in ('site_name', 'game_name', 'stat_name', 'name', 'db_server', 'site', 'col_name'): name = " " + node.attributes.item(i).value if name != "": self.configStore.set_value(iter, 1, setting+name) diff --git a/pyfpdb/GuiRingPlayerStats.py b/pyfpdb/GuiRingPlayerStats.py index 30643720..67bfd246 100644 --- a/pyfpdb/GuiRingPlayerStats.py +++ b/pyfpdb/GuiRingPlayerStats.py @@ -31,7 +31,9 @@ import Filters import Charset import GuiPlayerStats -colalias,colshowsumm,colshowposn,colheading,colxalign,colformat,coltype = 0,1,2,3,4,5,6 +#colalias,colshowsumm,colshowposn,colheading,colxalign,colformat,coltype = 0,1,2,3,4,5,6 +#new order in config file: +colalias,colheading,colshowsumm,colshowposn,colformat,coltype,colxalign = 0,1,2,3,4,5,6 ranks = {'x':0, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9, 'T':10, 'J':11, 'Q':12, 'K':13, 'A':14} class GuiRingPlayerStats (GuiPlayerStats.GuiPlayerStats): @@ -89,34 +91,35 @@ class GuiRingPlayerStats (GuiPlayerStats.GuiPlayerStats): # ToDo: create popup to adjust column config # columns to display, keys match column name returned by sql, values in tuple are: # is column displayed(summary then position), column heading, xalignment, formatting, celltype - self.columns = [ ["game", True, True, "Game", 0.0, "%s", "str"] - , ["hand", False, False, "Hand", 0.0, "%s", "str"] # true not allowed for this line - , ["plposition", False, False, "Posn", 1.0, "%s", "str"] # true not allowed for this line (set in code) - , ["pname", False, False, "Name", 0.0, "%s", "str"] # true not allowed for this line (set in code) - , ["n", True, True, "Hds", 1.0, "%1.0f", "str"] - , ["avgseats", False, False, "Seats", 1.0, "%3.1f", "str"] - , ["vpip", True, True, "VPIP", 1.0, "%3.1f", "str"] - , ["pfr", True, True, "PFR", 1.0, "%3.1f", "str"] - , ["pf3", True, True, "PF3", 1.0, "%3.1f", "str"] - , ["aggfac", True, True, "AggFac", 1.0, "%2.2f", "str"] - , ["aggfrq", True, True, "AggFreq", 1.0, "%3.1f", "str"] - , ["conbet", True, True, "ContBet", 1.0, "%3.1f", "str"] - , ["rfi", True, True, "RFI", 1.0, "%3.1f", "str"] - , ["steals", True, True, "Steals", 1.0, "%3.1f", "str"] - , ["saw_f", True, True, "Saw_F", 1.0, "%3.1f", "str"] - , ["sawsd", True, True, "SawSD", 1.0, "%3.1f", "str"] - , ["wtsdwsf", True, True, "WtSDwsF", 1.0, "%3.1f", "str"] - , ["wmsd", True, True, "W$SD", 1.0, "%3.1f", "str"] - , ["flafq", True, True, "FlAFq", 1.0, "%3.1f", "str"] - , ["tuafq", True, True, "TuAFq", 1.0, "%3.1f", "str"] - , ["rvafq", True, True, "RvAFq", 1.0, "%3.1f", "str"] - , ["pofafq", False, False, "PoFAFq", 1.0, "%3.1f", "str"] - , ["net", True, True, "Net($)", 1.0, "%6.2f", "cash"] - , ["bbper100", True, True, "bb/100", 1.0, "%4.2f", "str"] - , ["rake", True, True, "Rake($)", 1.0, "%6.2f", "cash"] - , ["bb100xr", True, True, "bbxr/100", 1.0, "%4.2f", "str"] - , ["variance", True, True, "Variance", 1.0, "%5.2f", "str"] - ] + self.columns = self.conf.get_gui_cash_stat_params() +# self.columns = [ ["game", True, True, "Game", 0.0, "%s", "str"] +# , ["hand", False, False, "Hand", 0.0, "%s", "str"] # initial setting ignored for this line (set in code) +# , ["plposition", False, False, "Posn", 1.0, "%s", "str"] # initial setting ignored for this line (set in code) +# , ["pname", False, False, "Name", 0.0, "%s", "str"] # initial setting ignored for this line (set in code) +# , ["n", True, True, "Hds", 1.0, "%1.0f", "str"] +# , ["avgseats", False, False, "Seats", 1.0, "%3.1f", "str"] +# , ["vpip", True, True, "VPIP", 1.0, "%3.1f", "str"] +# , ["pfr", True, True, "PFR", 1.0, "%3.1f", "str"] +# , ["pf3", True, True, "PF3", 1.0, "%3.1f", "str"] +# , ["aggfac", True, True, "AggFac", 1.0, "%2.2f", "str"] +# , ["aggfrq", True, True, "AggFreq", 1.0, "%3.1f", "str"] +# , ["conbet", True, True, "ContBet", 1.0, "%3.1f", "str"] +# , ["rfi", True, True, "RFI", 1.0, "%3.1f", "str"] +# , ["steals", True, True, "Steals", 1.0, "%3.1f", "str"] +# , ["saw_f", True, True, "Saw_F", 1.0, "%3.1f", "str"] +# , ["sawsd", True, True, "SawSD", 1.0, "%3.1f", "str"] +# , ["wtsdwsf", True, True, "WtSDwsF", 1.0, "%3.1f", "str"] +# , ["wmsd", True, True, "W$SD", 1.0, "%3.1f", "str"] +# , ["flafq", True, True, "FlAFq", 1.0, "%3.1f", "str"] +# , ["tuafq", True, True, "TuAFq", 1.0, "%3.1f", "str"] +# , ["rvafq", True, True, "RvAFq", 1.0, "%3.1f", "str"] +# , ["pofafq", False, False, "PoFAFq", 1.0, "%3.1f", "str"] +# , ["net", True, True, "Net($)", 1.0, "%6.2f", "cash"] +# , ["bbper100", True, True, "bb/100", 1.0, "%4.2f", "str"] +# , ["rake", True, True, "Rake($)", 1.0, "%6.2f", "cash"] +# , ["bb100xr", True, True, "bbxr/100", 1.0, "%4.2f", "str"] +# , ["variance", True, True, "Variance", 1.0, "%5.2f", "str"] +# ] # Detail filters: This holds the data used in the popup window, extra values are # added at the end of these lists during processing From a3e55ba3f51b092cd973269761a90419e5390df3 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Sat, 31 Jul 2010 21:38:52 +0100 Subject: [PATCH 2/2] smarten up names of displayed categories and settings --- pyfpdb/GuiPrefs.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/pyfpdb/GuiPrefs.py b/pyfpdb/GuiPrefs.py index c706e88c..b28f975d 100755 --- a/pyfpdb/GuiPrefs.py +++ b/pyfpdb/GuiPrefs.py @@ -26,6 +26,20 @@ import gobject import Configuration +rewrite = { 'general' : 'General', 'supported_databases' : 'Databases' + , 'import' : 'Import', 'hud_ui' : 'HUD' + , 'supported_sites' : 'Sites', 'supported_games' : 'Games' + , 'popup_windows' : 'Popup Windows', 'pu' : 'Window' + , 'pu_name' : 'Popup Name', 'pu_stat' : 'Stat' + , 'pu_stat_name' : 'Stat Name' + , 'aux_windows' : 'Auxiliary Windows', 'aw stud_mucked' : 'stud_mucked' + , 'aw mucked' : 'mucked', 'hhcs' : 'Hand History Converters' + , 'gui_cash_stats' : 'Ring Player Stats', 'field_type' : 'Field Type' + , 'col_title' : 'Column Heading', 'xalignment' : 'Left/Right Align' + , 'disp_all' : 'Show in Summaries', 'disp_posn' : 'Show in Position Stats' + , 'col_name' : 'Stat Name', 'field_format' : 'Format' + } + class GuiPrefs: def __init__(self, config, mainwin, dia, parentwin): @@ -78,6 +92,13 @@ class GuiPrefs: self.tree_box.show() self.dialog.show() + def rewriteText(self, s): + upd = False + if s in rewrite: + s = rewrite[s] + upd = True + return( (s,upd) ) + def addTreeRows(self, parent, node): if (node.nodeType == node.ELEMENT_NODE): (setting, value) = (node.nodeName, None) @@ -94,11 +115,15 @@ class GuiPrefs: iter = self.configStore.append( parent, [node, setting, value] ) if node.hasAttributes(): for i in xrange(node.attributes.length): - self.configStore.append( iter, [node, node.attributes.item(i).localName, node.attributes.item(i).value] ) + localName,updated = self.rewriteText( node.attributes.item(i).localName ) + self.configStore.append( iter, [node, localName, node.attributes.item(i).value] ) if node.attributes.item(i).localName in ('site_name', 'game_name', 'stat_name', 'name', 'db_server', 'site', 'col_name'): name = " " + node.attributes.item(i).value - if name != "": - self.configStore.set_value(iter, 1, setting+name) + + label,updated = self.rewriteText(setting+name) + if name != "" or updated: + self.configStore.set_value(iter, 1, label) + if node.hasChildNodes(): for elem in node.childNodes: self.addTreeRows(iter, elem)