diff --git a/pyfpdb/GuiPlayerStats.py b/pyfpdb/GuiPlayerStats.py index e51ff4a3..c12f16e1 100644 --- a/pyfpdb/GuiPlayerStats.py +++ b/pyfpdb/GuiPlayerStats.py @@ -79,30 +79,30 @@ class GuiPlayerStats (threading.Thread): # ToDo: store in config # ToDo: create popup to adjust column config # columns to display, keys match column name returned by sql, values in tuple are: - # is column displayed, column heading, xalignment, formatting - self.columns = [ ["game", True, "Game", 0.0, "%s"] - , ["hand", False, "Hand", 0.0, "%s"] # true not allowed for this line - , ["plposition", False, "Posn", 1.0, "%s"] # true not allowed for this line (set in code) - , ["pname", False, "Name", 0.0, "%s"] # true not allowed for this line (set in code) - , ["n", True, "Hds", 1.0, "%d"] - , ["avgseats", False, "Seats", 1.0, "%3.1f"] - , ["vpip", True, "VPIP", 1.0, "%3.1f"] - , ["pfr", True, "PFR", 1.0, "%3.1f"] - , ["pf3", True, "PF3", 1.0, "%3.1f"] - , ["steals", True, "Steals", 1.0, "%3.1f"] - , ["saw_f", True, "Saw_F", 1.0, "%3.1f"] - , ["sawsd", True, "SawSD", 1.0, "%3.1f"] - , ["wtsdwsf", True, "WtSDwsF", 1.0, "%3.1f"] - , ["wmsd", True, "W$SD", 1.0, "%3.1f"] - , ["flafq", True, "FlAFq", 1.0, "%3.1f"] - , ["tuafq", True, "TuAFq", 1.0, "%3.1f"] - , ["rvafq", True, "RvAFq", 1.0, "%3.1f"] - , ["pofafq", False, "PoFAFq", 1.0, "%3.1f"] - , ["net", True, "Net($)", 1.0, "%6.2f"] - , ["bbper100", True, "bb/100", 1.0, "%4.2f"] - , ["rake", True, "Rake($)", 1.0, "%6.2f"] - , ["bb100xr", True, "bbxr/100", 1.0, "%4.2f"] - , ["variance", True, "Variance", 1.0, "%5.2f"] + # is column displayed, column heading, xalignment, formatting, celltype + self.columns = [ ["game", True, "Game", 0.0, "%s", "str"] + , ["hand", False, "Hand", 0.0, "%s", "str"] # true not allowed for this line + , ["plposition", False, "Posn", 1.0, "%s", "str"] # true not allowed for this line (set in code) + , ["pname", False, "Name", 0.0, "%s", "str"] # true not allowed for this line (set in code) + , ["n", True, "Hds", 1.0, "%d", "str"] + , ["avgseats", False, "Seats", 1.0, "%3.1f", "str"] + , ["vpip", True, "VPIP", 1.0, "%3.1f", "str"] + , ["pfr", True, "PFR", 1.0, "%3.1f", "str"] + , ["pf3", True, "PF3", 1.0, "%3.1f", "str"] + , ["steals", True, "Steals", 1.0, "%3.1f", "str"] + , ["saw_f", True, "Saw_F", 1.0, "%3.1f", "str"] + , ["sawsd", True, "SawSD", 1.0, "%3.1f", "str"] + , ["wtsdwsf", True, "WtSDwsF", 1.0, "%3.1f", "str"] + , ["wmsd", True, "W$SD", 1.0, "%3.1f", "str"] + , ["flafq", True, "FlAFq", 1.0, "%3.1f", "str"] + , ["tuafq", True, "TuAFq", 1.0, "%3.1f", "str"] + , ["rvafq", True, "RvAFq", 1.0, "%3.1f", "str"] + , ["pofafq", False, "PoFAFq", 1.0, "%3.1f", "str"] + , ["net", True, "Net($)", 1.0, "%6.2f", "cash"] + , ["bbper100", True, "bb/100", 1.0, "%4.2f", "str"] + , ["rake", True, "Rake($)", 1.0, "%6.2f", "cash"] + , ["bb100xr", True, "bbxr/100", 1.0, "%4.2f", "str"] + , ["variance", True, "Variance", 1.0, "%5.2f", "str"] ] # Detail filters: This holds the data used in the popup window, extra values are @@ -235,10 +235,29 @@ class GuiPlayerStats (threading.Thread): print "Stats page displayed in %4.2f seconds" % (time() - starttime) #end def fillStatsFrame(self, vbox): + def reset_style_render_func(self, treeviewcolumn, cell, model, iter): + cell.set_property('foreground', 'black') + + def ledger_style_render_func(self, treeviewcolumn, cell, model, iter): + str = cell.get_property('text') + #Weird, if you set for one cell it affects all others unless you set explicitly + cell.set_property('foreground', 'black') + if '-' in str: + str = str.replace("-", "") + str = "(%s)" %(str) + cell.set_property('text', str) + cell.set_property('foreground', 'red') + else: + cell.set_property('foreground', 'green') + + return + + def addTable(self, vbox, query, flags, playerids, sitenos, limits, type, seats, groups, dates): + counter = 0 row = 0 sqlrow = 0 - colalias,colshow,colheading,colxalign,colformat = 0,1,2,3,4 + colalias,colshow,colheading,colxalign,colformat,coltype = 0,1,2,3,4,5 if not flags: holecards = False else: holecards = flags[0] @@ -285,6 +304,10 @@ class GuiPlayerStats (threading.Thread): listcols[col].add_attribute(numcell, 'text', col) listcols[col].set_expand(True) #listcols[col].set_alignment(column[colxalign]) # no effect? + if column[coltype] == 'cash': + listcols[col].set_cell_data_func(numcell, self.ledger_style_render_func) + else: + listcols[col].set_cell_data_func(numcell, self.reset_style_render_func) rows = len(result) # +1 for title row