Add ability for Filters to hide() panes

Also add ability to register a callback and name 2 buttons on hte left
panel
This commit is contained in:
Worros 2009-04-17 12:44:43 +08:00
parent 1939979e3c
commit ee1186bd57
4 changed files with 69 additions and 17 deletions

View File

@ -30,7 +30,7 @@ import fpdb_db
import FpdbSQLQueries import FpdbSQLQueries
class Filters(threading.Thread): class Filters(threading.Thread):
def __init__(self, db, settings, config, qdict, debug=True): def __init__(self, db, settings, config, qdict, display = {},debug=True):
self.debug=debug self.debug=debug
#print "start of GraphViewer constructor" #print "start of GraphViewer constructor"
self.db=db self.db=db
@ -78,7 +78,7 @@ class Filters(threading.Thread):
gamesFrame.add(vbox) gamesFrame.add(vbox)
# Limits # Limits
limitsFrame = gtk.Frame("Games:") limitsFrame = gtk.Frame("Limits:")
limitsFrame.set_label_align(0.0, 0.0) limitsFrame.set_label_align(0.0, 0.0)
limitsFrame.show() limitsFrame.show()
vbox = gtk.VBox(False, 0) vbox = gtk.VBox(False, 0)
@ -94,23 +94,38 @@ class Filters(threading.Thread):
self.fillDateFrame(vbox) self.fillDateFrame(vbox)
dateFrame.add(vbox) dateFrame.add(vbox)
self.graphButton=gtk.Button("Generate Graph") self.Button1=gtk.Button("Unamed 1")
self.fig = None self.Button2=gtk.Button("Unamed 2")
self.exportButton=gtk.Button("Export to File")
#self.exportButton.connect("clicked", self.exportGraph, "show clicked") #self.exportButton.connect("clicked", self.exportGraph, "show clicked")
self.exportButton.set_sensitive(False) self.Button2.set_sensitive(False)
self.mainVBox.add(playerFrame) self.mainVBox.add(playerFrame)
self.mainVBox.add(sitesFrame) self.mainVBox.add(sitesFrame)
self.mainVBox.add(gamesFrame) self.mainVBox.add(gamesFrame)
self.mainVBox.add(limitsFrame) self.mainVBox.add(limitsFrame)
self.mainVBox.add(dateFrame) self.mainVBox.add(dateFrame)
self.mainVBox.add(self.graphButton) self.mainVBox.add(self.Button1)
self.mainVBox.add(self.exportButton) self.mainVBox.add(self.Button2)
self.mainVBox.show_all() self.mainVBox.show_all()
# Should do this cleaner
if display["Heroes"] == False:
playerFrame.hide()
if display["Sites"] == False:
sitesFrame.hide()
if display["Games"] == False:
gamesFrame.hide()
if display["Limits"] == False:
limitsFrame.hide()
if display["Dates"] == False:
dateFrame.hide()
if display["Button1"] == False:
self.Button1.hide()
if display["Button2"] == False:
self.Button2.hide()
def get_vbox(self): def get_vbox(self):
"""returns the vbox of this thread""" """returns the vbox of this thread"""
return self.mainVBox return self.mainVBox
@ -135,8 +150,17 @@ class Filters(threading.Thread):
def getDates(self): def getDates(self):
return self.__get_dates() return self.__get_dates()
def registerGraphCallback(self, callback): def registerButton1Name(self, title):
self.graphButton.connect("clicked", callback, "clicked") self.Button1.set_label(title)
def registerButton1Callback(self, callback):
self.Button1.connect("clicked", callback, "clicked")
def registerButton2Name(self, title):
self.Button2.set_label(title)
def registerButton2Callback(self, callback):
self.Button2.connect("clicked", callback, "clicked")
def cardCallback(self, widget, data=None): def cardCallback(self, widget, data=None):
print "DEBUG: %s was toggled %s" % (data, ("OFF", "ON")[widget.get_active()]) print "DEBUG: %s was toggled %s" % (data, ("OFF", "ON")[widget.get_active()])

View File

@ -53,8 +53,20 @@ class GuiGraphViewer (threading.Thread):
self.sql=querylist self.sql=querylist
self.conf = config self.conf = config
self.filters = Filters.Filters(db, settings, config, querylist) filters_display = { "Heroes" : True,
self.filters.registerGraphCallback(self.generateGraph) "Sites" : True,
"Games" : True,
"Limits" : True,
"Dates" : True,
"Button1" : True,
"Button2" : True
}
self.filters = Filters.Filters(db, settings, config, querylist, display = filters_display)
self.filters.registerButton1Name("Refresh Graph")
self.filters.registerButton1Callback(self.generateGraph)
self.filters.registerButton2Name("Export to File")
self.filters.registerButton2Callback(self.exportGraph)
self.mainHBox = gtk.HBox(False, 0) self.mainHBox = gtk.HBox(False, 0)
self.mainHBox.show() self.mainHBox.show()
@ -69,9 +81,7 @@ class GuiGraphViewer (threading.Thread):
self.mainHBox.add(self.hpane) self.mainHBox.add(self.hpane)
self.fig = None self.fig = None
self.exportButton=gtk.Button("Export to File") #self.exportButton.set_sensitive(False)
self.exportButton.connect("clicked", self.exportGraph, "show clicked")
self.exportButton.set_sensitive(False)
self.fig = Figure(figsize=(5,4), dpi=100) self.fig = Figure(figsize=(5,4), dpi=100)
self.canvas = None self.canvas = None

View File

@ -43,7 +43,16 @@ class GuiPlayerStats (threading.Thread):
settings.update(config.get_import_parameters()) settings.update(config.get_import_parameters())
settings.update(config.get_default_paths()) settings.update(config.get_default_paths())
self.filters = Filters.Filters(db, settings, config, querylist) filters_display = { "Heroes" : True,
"Sites" : True,
"Games" : False,
"Limits" : False,
"Dates" : False,
"Button1" : False,
"Button2" : False
}
self.filters = Filters.Filters(db, settings, config, querylist, display = filters_display)
self.stat_table = None self.stat_table = None
self.stats_frame = None self.stats_frame = None

View File

@ -43,7 +43,16 @@ class GuiPositionalStats (threading.Thread):
settings.update(config.get_import_parameters()) settings.update(config.get_import_parameters())
settings.update(config.get_default_paths()) settings.update(config.get_default_paths())
self.filters = Filters.Filters(db, settings, config, querylist) filters_display = { "Heroes" : True,
"Sites" : True,
"Games" : False,
"Limits" : False,
"Dates" : False,
"Button1" : False,
"Button2" : False
}
self.filters = Filters.Filters(db, settings, config, querylist, display = filters_display)
self.stat_table = None self.stat_table = None
self.stats_frame = None self.stats_frame = None