fix problem when using more recent gtk libraries (each refresh was adding an extra chart to the existing one)
This commit is contained in:
parent
6de41be9c9
commit
0850721ecc
|
@ -72,20 +72,19 @@ class GuiGraphViewer (threading.Thread):
|
||||||
self.mainHBox.show()
|
self.mainHBox.show()
|
||||||
|
|
||||||
self.leftPanelBox = self.filters.get_vbox()
|
self.leftPanelBox = self.filters.get_vbox()
|
||||||
self.graphBox = gtk.VBox(False, 0)
|
|
||||||
self.graphBox.show()
|
|
||||||
|
|
||||||
self.hpane = gtk.HPaned()
|
self.hpane = gtk.HPaned()
|
||||||
self.hpane.pack1(self.leftPanelBox)
|
self.hpane.pack1(self.leftPanelBox)
|
||||||
|
self.mainHBox.add(self.hpane)
|
||||||
|
# hierarchy: self.mainHBox / self.hpane / self.graphBox / self.canvas / self.fig / self.ax
|
||||||
|
|
||||||
|
self.graphBox = gtk.VBox(False, 0)
|
||||||
|
self.graphBox.show()
|
||||||
self.hpane.pack2(self.graphBox)
|
self.hpane.pack2(self.graphBox)
|
||||||
self.hpane.show()
|
self.hpane.show()
|
||||||
|
|
||||||
self.mainHBox.add(self.hpane)
|
|
||||||
|
|
||||||
self.fig = None
|
self.fig = None
|
||||||
#self.exportButton.set_sensitive(False)
|
#self.exportButton.set_sensitive(False)
|
||||||
|
|
||||||
self.fig = Figure(figsize=(5,4), dpi=100)
|
|
||||||
self.canvas = None
|
self.canvas = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,14 +124,31 @@ class GuiGraphViewer (threading.Thread):
|
||||||
#end def get_vbox
|
#end def get_vbox
|
||||||
|
|
||||||
def clearGraphData(self):
|
def clearGraphData(self):
|
||||||
|
|
||||||
|
try:
|
||||||
|
try:
|
||||||
|
if self.canvas:
|
||||||
|
self.graphBox.remove(self.canvas)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if self.fig != None:
|
||||||
self.fig.clear()
|
self.fig.clear()
|
||||||
|
self.fig = Figure(figsize=(5,4), dpi=100)
|
||||||
if self.canvas is not None:
|
if self.canvas is not None:
|
||||||
self.canvas.destroy()
|
self.canvas.destroy()
|
||||||
|
|
||||||
self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea
|
self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea
|
||||||
|
except:
|
||||||
|
err = traceback.extract_tb(sys.exc_info()[2])[-1]
|
||||||
|
print "***Error: "+err[2]+"("+str(err[1])+"): "+str(sys.exc_info()[1])
|
||||||
|
raise
|
||||||
|
|
||||||
def generateGraph(self, widget, data):
|
def generateGraph(self, widget, data):
|
||||||
|
print "generateGraph: start"
|
||||||
|
try:
|
||||||
self.clearGraphData()
|
self.clearGraphData()
|
||||||
|
print "after cleardata"
|
||||||
|
|
||||||
sitenos = []
|
sitenos = []
|
||||||
playerids = []
|
playerids = []
|
||||||
|
@ -141,6 +157,7 @@ class GuiGraphViewer (threading.Thread):
|
||||||
heroes = self.filters.getHeroes()
|
heroes = self.filters.getHeroes()
|
||||||
siteids = self.filters.getSiteIds()
|
siteids = self.filters.getSiteIds()
|
||||||
limits = self.filters.getLimits()
|
limits = self.filters.getLimits()
|
||||||
|
print "got filter data"
|
||||||
# Which sites are selected?
|
# Which sites are selected?
|
||||||
for site in sites:
|
for site in sites:
|
||||||
if sites[site] == True:
|
if sites[site] == True:
|
||||||
|
@ -164,10 +181,12 @@ class GuiGraphViewer (threading.Thread):
|
||||||
return
|
return
|
||||||
|
|
||||||
#Set graph properties
|
#Set graph properties
|
||||||
|
print "add_subplot"
|
||||||
self.ax = self.fig.add_subplot(111)
|
self.ax = self.fig.add_subplot(111)
|
||||||
|
|
||||||
#Get graph data from DB
|
#Get graph data from DB
|
||||||
starttime = time()
|
starttime = time()
|
||||||
|
print "get line: playerids =", playerids, "sitenos =", sitenos, "limits =", limits
|
||||||
line = self.getRingProfitGraph(playerids, sitenos, limits)
|
line = self.getRingProfitGraph(playerids, sitenos, limits)
|
||||||
print "Graph generated in: %s" %(time() - starttime)
|
print "Graph generated in: %s" %(time() - starttime)
|
||||||
|
|
||||||
|
@ -198,6 +217,10 @@ class GuiGraphViewer (threading.Thread):
|
||||||
self.canvas.show()
|
self.canvas.show()
|
||||||
self.canvas.draw()
|
self.canvas.draw()
|
||||||
#self.exportButton.set_sensitive(True)
|
#self.exportButton.set_sensitive(True)
|
||||||
|
except:
|
||||||
|
err = traceback.extract_tb(sys.exc_info()[2])[-1]
|
||||||
|
print "***Error: "+err[2]+"("+str(err[1])+"): "+str(sys.exc_info()[1])
|
||||||
|
|
||||||
#end of def showClicked
|
#end of def showClicked
|
||||||
|
|
||||||
def getRingProfitGraph(self, names, sites, limits):
|
def getRingProfitGraph(self, names, sites, limits):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user