From b1e41a54ec95716c69b66edbf8b029c4e140a129 Mon Sep 17 00:00:00 2001 From: steffen123 Date: Sat, 10 Jul 2010 05:19:50 +0200 Subject: [PATCH] intermediate commit on the way to tourney stats --- pyfpdb/Database.py | 8 + pyfpdb/Filters.py | 12 +- pyfpdb/GuiPlayerStats.py | 5 +- pyfpdb/GuiTourneyPlayerStats.py | 303 ++++++++++++++++++++++++++++++-- pyfpdb/SQL.py | 9 + pyfpdb/TourneyFilters.py | 159 +++++++++++++++-- 6 files changed, 461 insertions(+), 35 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 0c1cf85c..e0f522b9 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -2042,6 +2042,14 @@ class Database: tourneysPlayersIds.append(self.get_last_insert_id(cursor)) return tourneysPlayersIds #end def createOrUpdateTourneysPlayers + + def getTourneyTypesIds(self): + c = self.connection.cursor() + c.execute(self.sql.query['getTourneyTypesIds']) + result = c.fetchall() + print "DB.getTourneyTypesIds result:",result + return result + #end def getTourneyTypesIds #end class Database # Class used to hold all the data needed to write a hand to the db diff --git a/pyfpdb/Filters.py b/pyfpdb/Filters.py index 2cb6bcd6..d744c7bf 100644 --- a/pyfpdb/Filters.py +++ b/pyfpdb/Filters.py @@ -226,18 +226,22 @@ class Filters(threading.Thread): def getNumHands(self): return self.numHands + #end def getNumHands def getSites(self): return self.sites + #end def getSites def getGames(self): return self.games def getSiteIds(self): return self.siteid + #end def getSiteIds def getHeroes(self): return self.heroes + #end def getHeroes def getLimits(self): ltuple = [] @@ -255,12 +259,14 @@ class Filters(threading.Thread): if 'to' in self.sbSeats: self.seats['to'] = self.sbSeats['to'].get_value_as_int() return self.seats + #end def getSeats def getGroups(self): return self.groups def getDates(self): return self.__get_dates() + #end def getDates def registerButton1Name(self, title): self.Button1.set_label(title) @@ -323,7 +329,8 @@ class Filters(threading.Thread): self.numHands = int(w.get_text()) except: self.numHands = 0 -# log.debug("setting numHands:", self.numHands) + #log.debug("setting numHands:", self.numHands) + #end def __set_num_hands def createSiteLine(self, hbox, site): cb = gtk.CheckButton(site) @@ -354,6 +361,7 @@ class Filters(threading.Thread): #print w.get_active() self.games[game] = w.get_active() log.debug("self.games[%s] set to %s" %(game, self.games[game])) + #end def __set_game_select def __set_limit_select(self, w, limit): #print w.get_active() @@ -600,6 +608,7 @@ class Filters(threading.Thread): else: print "INFO: No games returned from database" log.info("No games returned from database") + #end def fillGamesFrame def fillLimitsFrame(self, vbox, display): top_hbox = gtk.HBox(False, 0) @@ -899,6 +908,7 @@ class Filters(threading.Thread): log.info("t1="+t1+" adj_t1="+adj_t1+'.') return (adj_t1, adj_t2) + #end def __get_dates def __get_date(self, widget, calendar, entry, win): # year and day are correct, month is 0..11 diff --git a/pyfpdb/GuiPlayerStats.py b/pyfpdb/GuiPlayerStats.py index 586e55ea..13f898d2 100644 --- a/pyfpdb/GuiPlayerStats.py +++ b/pyfpdb/GuiPlayerStats.py @@ -442,8 +442,7 @@ class GuiPlayerStats (threading.Thread): sqlrow += 1 row += 1 vbox.show_all() - - #end def addGrid(self, query, vars, playerids, sitenos, limits, type, seats, groups, dates): + #end def addGrid def refineQuery(self, query, flags, playerids, sitenos, limits, type, seats, groups, dates, games): having = '' @@ -609,7 +608,7 @@ class GuiPlayerStats (threading.Thread): #print "query =\n", query return(query) - #end def refineQuery(self, query, playerids, sitenos, limits): + #end def refineQuery def showDetailFilter(self, widget, data): detailDialog = gtk.Dialog(title="Detailed Filters", parent=self.main_window diff --git a/pyfpdb/GuiTourneyPlayerStats.py b/pyfpdb/GuiTourneyPlayerStats.py index a8f2b840..3a89c16d 100644 --- a/pyfpdb/GuiTourneyPlayerStats.py +++ b/pyfpdb/GuiTourneyPlayerStats.py @@ -22,12 +22,12 @@ pygtk.require('2.0') import gtk #import os #import sys -#from time import time, strftime +from time import time, strftime #import Card #import fpdb_import #import Database -#import Charset +import Charset import TourneyFilters class GuiTourneyPlayerStats (threading.Thread): @@ -41,7 +41,7 @@ class GuiTourneyPlayerStats (threading.Thread): self.liststore = [] # gtk.ListStore[] stores the contents of the grids self.listcols = [] # gtk.TreeViewColumn[][] stores the columns in the grids - filters_display = { "Heroes" : True, + filters_display = { "Heroes" : False, "Sites" : True, #"Games" : True, #"Limits" : True, @@ -67,6 +67,23 @@ class GuiTourneyPlayerStats (threading.Thread): #self.filters.registerButton1Callback(self.showDetailFilter) self.filters.registerButton2Name("_Refresh Stats") self.filters.registerButton2Callback(self.refreshStats) + + # 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, celltype + self.columns = [ ["tourneyTypeId", True, "TTypeId", 0.0, "%s", "str"] + , ["tourney", False, "Tourney", 0.0, "%s", "str"] # true not allowed for this line + #, ["pname", False, "Name", 0.0, "%s", "str"] # true not allowed for this line (set in code) + , ["tourneyCount", True, "#", 1.0, "%1.0f", "str"] + , ["1st", False, "1st", 1.0, "%3.1f", "str"] + , ["2nd", True, "2nd", 1.0, "%3.1f", "str"] + , ["3rd", True, "3rd", 1.0, "%3.1f", "str"] + , ["unknownRank", True, "unknown", 1.0, "%3.1f", "str"] + , ["itm", True, "ITM", 1.0, "%2.2f", "str"] + , ["roi", True, "ROI", 1.0, "%3.1f", "str"] + , ["profitPerTourney", True, "$/T", 1.0, "%3.1f", "str"]] + self.stats_frame = gtk.Frame() self.stats_frame.show() @@ -82,8 +99,119 @@ class GuiTourneyPlayerStats (threading.Thread): self.main_hbox.show() #end def __init__ - def createStatsTable(self, vbox, playerids, sitenos, limits, type, seats, groups, dates, games): - starttime = time() + def addGrid(self, vbox, query, flags, tourneyTypes, playerids, sitenos, seats, dates): + counter = 0 + row = 0 + sqlrow = 0 + if not flags: holecards,grid = False,0 + else: holecards,grid = flags[0],flags[2] + + tmp = self.sql.query[query] + tmp = self.refineQuery(tmp, flags, tourneyTypes, playerids, sitenos, seats, dates) + self.cursor.execute(tmp) + result = self.cursor.fetchall() + colnames = [desc[0].lower() for desc in self.cursor.description] + + # pre-fetch some constant values: + self.cols_to_show = [x for x in self.columns if x[colshow]] + hgametypeid_idx = colnames.index('hgametypeid') + + assert len(self.liststore) == grid, "len(self.liststore)="+str(len(self.liststore))+" grid-1="+str(grid) + self.liststore.append( gtk.ListStore(*([str] * len(self.cols_to_show))) ) + view = gtk.TreeView(model=self.liststore[grid]) + view.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH) + #vbox.pack_start(view, expand=False, padding=3) + vbox.add(view) + textcell = gtk.CellRendererText() + textcell50 = gtk.CellRendererText() + textcell50.set_property('xalign', 0.5) + numcell = gtk.CellRendererText() + numcell.set_property('xalign', 1.0) + assert len(self.listcols) == grid + self.listcols.append( [] ) + + # Create header row eg column: ("game", True, "Game", 0.0, "%s") + for col, column in enumerate(self.cols_to_show): + if column[colalias] == 'game' and holecards: + s = [x for x in self.columns if x[colalias] == 'hand'][0][colheading] + else: + s = column[colheading] + self.listcols[grid].append(gtk.TreeViewColumn(s)) + view.append_column(self.listcols[grid][col]) + if column[colformat] == '%s': + if column[colxalign] == 0.0: + self.listcols[grid][col].pack_start(textcell, expand=True) + self.listcols[grid][col].add_attribute(textcell, 'text', col) + cellrend = textcell + else: + self.listcols[grid][col].pack_start(textcell50, expand=True) + self.listcols[grid][col].add_attribute(textcell50, 'text', col) + cellrend = textcell50 + self.listcols[grid][col].set_expand(True) + else: + self.listcols[grid][col].pack_start(numcell, expand=True) + self.listcols[grid][col].add_attribute(numcell, 'text', col) + self.listcols[grid][col].set_expand(True) + cellrend = numcell + #self.listcols[grid][col].set_alignment(column[colxalign]) # no effect? + self.listcols[grid][col].set_clickable(True) + self.listcols[grid][col].connect("clicked", self.sortcols, (col,grid)) + if col == 0: + self.listcols[grid][col].set_sort_order(gtk.SORT_DESCENDING) + self.listcols[grid][col].set_sort_indicator(True) + if column[coltype] == 'cash': + self.listcols[grid][col].set_cell_data_func(numcell, self.ledger_style_render_func) + else: + self.listcols[grid][col].set_cell_data_func(cellrend, self.reset_style_render_func) + + rows = len(result) # +1 for title row + + while sqlrow < rows: + treerow = [] + for col,column in enumerate(self.cols_to_show): + if column[colalias] in colnames: + value = result[sqlrow][colnames.index(column[colalias])] + if column[colalias] == 'plposition': + if value == 'B': + value = 'BB' + elif value == 'S': + value = 'SB' + elif value == '0': + value = 'Btn' + else: + if column[colalias] == 'game': + if holecards: + value = Card.twoStartCardString( result[sqlrow][hgametypeid_idx] ) + else: + minbb = result[sqlrow][colnames.index('minbigblind')] + maxbb = result[sqlrow][colnames.index('maxbigblind')] + value = result[sqlrow][colnames.index('limittype')] + ' ' \ + + result[sqlrow][colnames.index('category')].title() + ' ' \ + + result[sqlrow][colnames.index('name')] + ' $' + if 100 * int(minbb/100.0) != minbb: + value += '%.2f' % (minbb/100.0) + else: + value += '%.0f' % (minbb/100.0) + if minbb != maxbb: + if 100 * int(maxbb/100.0) != maxbb: + value += ' - $' + '%.2f' % (maxbb/100.0) + else: + value += ' - $' + '%.0f' % (maxbb/100.0) + else: + continue + if value and value != -999: + treerow.append(column[colformat] % value) + else: + treerow.append(' ') + iter = self.liststore[grid].append(treerow) + #print treerow + sqlrow += 1 + row += 1 + vbox.show_all() + #end def addGrid + + def createStatsTable(self, vbox, tourneyTypes, playerids, sitenos, seats, dates): + startTime = time() show_detail = True # Scrolled window for summary table @@ -97,9 +225,9 @@ class GuiTourneyPlayerStats (threading.Thread): # holecards - whether to display card breakdown (True/False) # numhands - min number hands required when displaying all players # gridnum - index for grid data structures - flags = [False, self.filters.getNumHands(), 0] - self.addGrid(swin, 'playerDetailedStats', flags, playerids - ,sitenos, limits, type, seats, groups, dates, games) + flags = [False, self.filters.getNumTourneys(), 0] + self.addGrid(swin, 'playerDetailedStats', flags, tourneyTypes, playerids + ,sitenos, seats, dates) if 'allplayers' in groups and groups['allplayers']: # can't currently do this combination so skip detailed table @@ -123,20 +251,20 @@ class GuiTourneyPlayerStats (threading.Thread): # Detailed table flags[0] = True flags[2] = 1 - self.addGrid(swin, 'playerDetailedStats', flags, playerids - ,sitenos, limits, type, seats, groups, dates, games) + self.addGrid(swin, 'playerDetailedStats', flags, playerids, sitenos, seats, dates) self.db.rollback() - print "Stats page displayed in %4.2f seconds" % (time() - starttime) + print "Stats page displayed in %4.2f seconds" % (time() - startTime) #end def createStatsTable def fillStatsFrame(self, vbox): + tourneyTypes = self.filters.getTourneyTypes() + #tourneys = self.tourneys.getTourneys() sites = self.filters.getSites() heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() seats = self.filters.getSeats() dates = self.filters.getDates() - games = self.filters.getGames() sitenos = [] playerids = [] @@ -156,11 +284,8 @@ class GuiTourneyPlayerStats (threading.Thread): if not playerids: print "No player ids found" return - if not limits: - print "No limits found" - return - - self.createStatsTable(vbox, playerids, sitenos, limits, type, seats, groups, dates, games) + + self.createStatsTable(vbox, tourneyTypes, playerids, sitenos, seats, dates) #end def fillStatsFrame def get_vbox(self): @@ -168,6 +293,150 @@ class GuiTourneyPlayerStats (threading.Thread): return self.main_hbox #end def get_vbox + def refineQuery(self, query, flags, tourneyTypes, playerids, sitenos, seats, dates): + having = '' + holecards = flags[0] + numTourneys = flags[1] + + #if 'allplayers' in groups and groups['allplayers']: + nametest = "(hp.playerId)" + pname = "p.name" + # set flag in self.columns to show player name column + [x for x in self.columns if x[0] == 'pname'][0][1] = True + if numTourneys: + having = ' and count(1) > %d ' % (numTourneys,) + query = query.replace("", nametest) + query = query.replace("", pname) + query = query.replace("", having) + + gametest = "" + q = [] + for m in self.filters.display.items(): + if m[0] == 'Games' and m[1]: + for n in games: + if games[n]: + q.append(n) + if len(q) > 0: + gametest = str(tuple(q)) + gametest = gametest.replace("L", "") + gametest = gametest.replace(",)",")") + gametest = gametest.replace("u'","'") + gametest = "and gt.category in %s" % gametest + else: + gametest = "and gt.category IS NULL" + query = query.replace("", gametest) + + sitetest = "" + q = [] + for m in self.filters.display.items(): + if m[0] == 'Sites' and m[1]: + for n in sitenos: + q.append(n) + if len(q) > 0: + sitetest = str(tuple(q)) + sitetest = sitetest.replace("L", "") + sitetest = sitetest.replace(",)",")") + sitetest = sitetest.replace("u'","'") + sitetest = "and gt.siteId in %s" % sitetest + else: + sitetest = "and gt.siteId IS NULL" + query = query.replace("", sitetest) + + if seats: + query = query.replace('', 'between ' + str(seats['from']) + ' and ' + str(seats['to'])) + if 'show' in seats and seats['show']: + query = query.replace('', ',h.seats') + query = query.replace('', ',h.seats') + else: + query = query.replace('', '') + query = query.replace('', '') + else: + query = query.replace('', 'between 0 and 100') + query = query.replace('', '') + query = query.replace('', '') + + lims = [int(x) for x in limits if x.isdigit()] + potlims = [int(x[0:-2]) for x in limits if len(x) > 2 and x[-2:] == 'pl'] + nolims = [int(x[0:-2]) for x in limits if len(x) > 2 and x[-2:] == 'nl'] + bbtest = "and ( (gt.limitType = 'fl' and gt.bigBlind in " + # and ( (limit and bb in()) or (nolimit and bb in ()) ) + if lims: + blindtest = str(tuple(lims)) + blindtest = blindtest.replace("L", "") + blindtest = blindtest.replace(",)",")") + bbtest = bbtest + blindtest + ' ) ' + else: + bbtest = bbtest + '(-1) ) ' + bbtest = bbtest + " or (gt.limitType = 'pl' and gt.bigBlind in " + if potlims: + blindtest = str(tuple(potlims)) + blindtest = blindtest.replace("L", "") + blindtest = blindtest.replace(",)",")") + bbtest = bbtest + blindtest + ' ) ' + else: + bbtest = bbtest + '(-1) ) ' + bbtest = bbtest + " or (gt.limitType = 'nl' and gt.bigBlind in " + if nolims: + blindtest = str(tuple(nolims)) + blindtest = blindtest.replace("L", "") + blindtest = blindtest.replace(",)",")") + bbtest = bbtest + blindtest + ' ) )' + else: + bbtest = bbtest + '(-1) ) )' + if type == 'ring': + bbtest = bbtest + " and gt.type = 'ring' " + elif type == 'tour': + bbtest = " and gt.type = 'tour' " + query = query.replace("", bbtest) + + if holecards: # re-use level variables for hole card query + query = query.replace("", "hp.startcards") + query = query.replace("" + , ",case when floor((hp.startcards-1)/13) >= mod((hp.startcards-1),13) then hp.startcards + 0.1 " + + " else 13*mod((hp.startcards-1),13) + floor((hp.startcards-1)/13) + 1 " + + " end desc ") + else: + query = query.replace("", "") + groupLevels = "show" not in str(limits) + if groupLevels: + query = query.replace("", "p.name") # need to use p.name for sqlite posn stats to work + else: + query = query.replace("", "h.gameTypeId") + + # process self.detailFilters (a list of tuples) + flagtest = '' + #self.detailFilters = [('h.seats', 5, 6)] # for debug + if self.detailFilters: + for f in self.detailFilters: + if len(f) == 3: + # X between Y and Z + flagtest += ' and %s between %s and %s ' % (f[0], str(f[1]), str(f[2])) + query = query.replace("", flagtest) + + # allow for differences in sql cast() function: + if self.db.backend == self.MYSQL_INNODB: + query = query.replace("", 'signed ') + else: + query = query.replace("", '') + + # Filter on dates + query = query.replace("", " between '" + dates[0] + "' and '" + dates[1] + "'") + + # Group by position? + if groups['posn']: + #query = query.replace("", "case hp.position when '0' then 'Btn' else hp.position end") + query = query.replace("", "hp.position") + # set flag in self.columns to show posn column + [x for x in self.columns if x[0] == 'plposition'][0][1] = True + else: + query = query.replace("", "gt.base") + # unset flag in self.columns to hide posn column + [x for x in self.columns if x[0] == 'plposition'][0][1] = False + + #print "query =\n", query + return(query) + #end def refineQuery + def refreshStats(self, widget, data): self.last_pos = self.stats_vbox.get_position() try: self.stats_vbox.destroy() diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 48fb9260..644ab0a3 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -92,6 +92,8 @@ class Sql: self.query['getLimits'] = """SELECT DISTINCT bigBlind from Gametypes ORDER by bigBlind DESC""" + self.query['getTourneyTypesIds'] = "SELECT id FROM TourneyTypes" + ################################ # Create Settings ################################ @@ -3834,9 +3836,16 @@ class Sql: %s )""" + ################################ + # Counts for DB stats window + ################################ self.query['getHandCount'] = "SELECT COUNT(id) FROM Hands" + self.query['getTourneyCount'] = "SELECT COUNT(id) FROM Tourneys" + ################################ + # placeholders and substitution stuff + ################################ if db_server == 'mysql': self.query['placeholder'] = u'%s' elif db_server == 'postgresql': diff --git a/pyfpdb/TourneyFilters.py b/pyfpdb/TourneyFilters.py index e536f0ea..e1829830 100644 --- a/pyfpdb/TourneyFilters.py +++ b/pyfpdb/TourneyFilters.py @@ -23,7 +23,7 @@ import gobject #import os #import sys #from optparse import OptionParser -#from time import * +from time import gmtime, mktime, strftime, strptime #import pokereval import logging #logging has been set up in fpdb.py or HUD_main.py, use their settings: @@ -45,8 +45,14 @@ class TourneyFilters(threading.Thread): self.display = display self.filterText = {'playerstitle':'Hero:', 'sitestitle':'Sites:', 'seatstitle':'Number of Players:', - 'seatsbetween':'Between:', 'seatsand':'And:', 'datestitle':'Date:'} + 'seatsbetween':'Between:', 'seatsand':'And:', 'datestitle':'Date:', + 'tourneyTypesTitle':'Tourney Type'} + gen = self.conf.get_general_params() + self.day_start = 0 + if 'day_start' in gen: + self.day_start = float(gen['day_start']) + # Outer Packing box self.mainVBox = gtk.VBox(False, 0) @@ -79,19 +85,44 @@ class TourneyFilters(threading.Thread): self.end_date.set_text('') #end def __clear_dates + def __get_dates(self): + # self.day_start gives user's start of day in hours + offset = int(self.day_start * 3600) # calc day_start in seconds + + t1 = self.start_date.get_text() + t2 = self.end_date.get_text() + + if t1 == '': + t1 = '1970-01-02' + if t2 == '': + t2 = '2020-12-12' + + s1 = strptime(t1, "%Y-%m-%d") # make time_struct + s2 = strptime(t2, "%Y-%m-%d") + e1 = mktime(s1) + offset # s1 is localtime, but returned time since epoch is UTC, then add the + e2 = mktime(s2) + offset # s2 is localtime, but returned time since epoch is UTC + e2 = e2 + 24 * 3600 - 1 # date test is inclusive, so add 23h 59m 59s to e2 + + adj_t1 = strftime("%Y-%m-%d %H:%M:%S", gmtime(e1)) # make adjusted string including time + adj_t2 = strftime("%Y-%m-%d %H:%M:%S", gmtime(e2)) + log.info("t1="+t1+" adj_t1="+adj_t1+'.') + + return (adj_t1, adj_t2) + #end def __get_dates + def __refresh(self, widget, entry): for w in self.mainVBox.get_children(): w.destroy() self.make_filter() #end def __refresh - def __set_hero_name(self, w, site): - _name = w.get_text() - #get_text() returns a str but we want internal variables to be unicode: - _guiname = unicode(_name) - self.heroes[site] = _guiname - #log.debug("setting heroes[%s]: %s"%(site, self.heroes[site])) - #end def __set_hero_name + def __set_num_tourneys(self, w, val): + try: + self.numTourneys = int(w.get_text()) + except: + self.numTourneys = 0 + print "setting numTourneys:", self.numTourneys + #end def __set_num_tourneys def __set_seat_select(self, w, seat): #print "__set_seat_select: seat =", seat, "active =", w.get_active() @@ -105,6 +136,12 @@ class TourneyFilters(threading.Thread): log.debug("self.sites[%s] set to %s" %(site, self.sites[site])) #end def __set_site_select + def __set_tourney_type_select(self, w, tourneyType): + #print w.get_active() + self.tourneyTypes[tourneyType] = w.get_active() + log.debug("self.tourney_types[%s] set to %s" %(tourneyType, self.tourneyTypes[tourneyType])) + #end def __set_tourney_type_select + def __toggle_box(self, widget, entry): if self.boxes[entry].props.visible: self.boxes[entry].hide() @@ -123,7 +160,7 @@ class TourneyFilters(threading.Thread): pname.set_text(player) pname.set_width_chars(20) hbox.pack_start(pname, False, True, 0) - pname.connect("changed", self.__set_hero_name, site) + #pname.connect("changed", self.__set_hero_name, site) # Added EntryCompletion but maybe comboBoxEntry is more flexible? (e.g. multiple choices) completion = gtk.EntryCompletion() @@ -137,7 +174,7 @@ class TourneyFilters(threading.Thread): _nt = (_n, ) liststore.append(_nt) - self.__set_hero_name(pname, site) + #self.__set_hero_name(pname, site) #end def createPlayerLine def createSiteLine(self, hbox, site): @@ -146,6 +183,13 @@ class TourneyFilters(threading.Thread): cb.set_active(True) hbox.pack_start(cb, False, False, 0) #end def createSiteLine + + def createTourneyTypeLine(self, hbox, tourneyType): + cb = gtk.CheckButton(str(tourneyType)) + cb.connect('clicked', self.__set_tourney_type_select, tourneyType) + hbox.pack_start(cb, False, False, 0) + cb.set_active(True) + #end def createTourneyTypeLine def fillDateFrame(self, vbox): # Hat tip to Mika Bostrom - calendar code comes from PokerStats @@ -216,7 +260,25 @@ class TourneyFilters(threading.Thread): player = self.conf.supported_sites[site].screen_name _pname = Charset.to_gui(player) self.createPlayerLine(hBox, site, _pname) + + hbox = gtk.HBox(False, 0) + vbox1.pack_start(hbox, False, False, 0) + #cb = gtk.CheckButton(self.filterText['groupsall']) + #cb.connect('clicked', self.__set_group_select, 'allplayers') + #hbox.pack_start(cb, False, False, 0) + #self.sbGroups['allplayers'] = cb + #self.groups['allplayers'] = False + #lbl = gtk.Label('Min # Hands:') + #lbl.set_alignment(xalign=1.0, yalign=0.5) + #hbox.pack_start(lbl, expand=True, padding=3) + + #phands = gtk.Entry() + #phands.set_text('0') + #phands.set_width_chars(8) + #hbox.pack_start(phands, False, False, 0) + #phands.connect("changed", self.__set_num_hands, site) + top_hbox.pack_start(showb, expand=False, padding=1) #end def fillPlayerFrame @@ -279,17 +341,77 @@ class TourneyFilters(threading.Thread): self.createSiteLine(hbox, site) #end def fillSitesFrame + def fillTourneyTypesFrame(self, vbox): + top_hbox = gtk.HBox(False, 0) + vbox.pack_start(top_hbox, False, False, 0) + lbl_title = gtk.Label(self.filterText['tourneyTypesTitle']) + lbl_title.set_alignment(xalign=0.0, yalign=0.5) + top_hbox.pack_start(lbl_title, expand=True, padding=3) + showb = gtk.Button(label="hide", stock=None, use_underline=True) + showb.set_alignment(xalign=1.0, yalign=0.5) + showb.connect('clicked', self.__toggle_box, 'tourneyTypes') + top_hbox.pack_start(showb, expand=False, padding=1) + + vbox1 = gtk.VBox(False, 0) + vbox.pack_start(vbox1, False, False, 0) + self.boxes['tourneyTypes'] = vbox1 + + result = self.db.getTourneyTypesIds() + if len(result) >= 1: + for line in result: + hbox = gtk.HBox(False, 0) + vbox1.pack_start(hbox, False, True, 0) + self.createTourneyTypeLine(hbox, line[0]) + else: + print "INFO: No tourney types returned from database" + log.info("No tourney types returned from database") + #end def fillTourneyTypesFrame + + def getDates(self): + return self.__get_dates() + #end def getDates + + def getHeroes(self): + return self.heroes + #end def getHeroes + + def getNumTourneys(self): + return self.numTourneys + #end def getNumTourneys + + def getSeats(self): + if 'from' in self.sbSeats: + self.seats['from'] = self.sbSeats['from'].get_value_as_int() + if 'to' in self.sbSeats: + self.seats['to'] = self.sbSeats['to'].get_value_as_int() + return self.seats + #end def getSeats + + def getSiteIds(self): + return self.siteid + #end def getSiteIds + + def getSites(self): + return self.sites + #end def getSites + + def getTourneyTypes(self): + return self.tourneyTypes + #end def getTourneyTypes + def get_vbox(self): """returns the vbox of this thread""" return self.mainVBox #end def get_vbox def make_filter(self): - self.sites = {} - self.seats = {} + self.tourneyTypes = {} + #self.tourneys = {} + self.sites = {} + self.seats = {} self.siteid = {} self.heroes = {} - self.boxes = {} + self.boxes = {} for site in self.conf.get_supported_sites(): #Get db site id for filtering later @@ -324,6 +446,15 @@ class TourneyFilters(threading.Thread): self.fillSitesFrame(vbox) sitesFrame.add(vbox) + # Tourney types + tourneyTypesFrame = gtk.Frame() + tourneyTypesFrame.set_label_align(0.0, 0.0) + tourneyTypesFrame.show() + vbox = gtk.VBox(False, 0) + + self.fillTourneyTypesFrame(vbox) + tourneyTypesFrame.add(vbox) + # Seats seatsFrame = gtk.Frame() seatsFrame.show()