From 17609ce71b135d6d061abe028c6582466e2514d5 Mon Sep 17 00:00:00 2001 From: Worros Date: Sat, 7 Mar 2009 18:23:30 +0900 Subject: [PATCH] Minor mods to Grapher to try and resolve issue with multiple plots being added --- pyfpdb/GuiGraphViewer.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pyfpdb/GuiGraphViewer.py b/pyfpdb/GuiGraphViewer.py index 82f6d4fa..5f9a8f61 100644 --- a/pyfpdb/GuiGraphViewer.py +++ b/pyfpdb/GuiGraphViewer.py @@ -46,9 +46,15 @@ class GuiGraphViewer (threading.Thread): return self.mainHBox #end def get_vbox + def clearGraphData(self): + self.fig.clf() + if self.canvas is not None: + self.canvas.destroy() + + self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea + def generateGraph(self, widget, data): - try: self.canvas.destroy() - except AttributeError: pass + self.clearGraphData() sitenos = [] playerids = [] @@ -72,7 +78,6 @@ class GuiGraphViewer (threading.Thread): print "No player ids found" return - self.fig = Figure(figsize=(5,4), dpi=100) #Set graph properties self.ax = self.fig.add_subplot(111) @@ -104,7 +109,6 @@ class GuiGraphViewer (threading.Thread): #Draw plot self.ax.plot(line,) - self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea self.graphBox.add(self.canvas) self.canvas.show() #end of def showClicked @@ -372,6 +376,9 @@ class GuiGraphViewer (threading.Thread): self.leftPanelBox.show() self.graphBox.show() + self.fig = Figure(figsize=(5,4), dpi=100) + self.canvas = None + ################################# # # self.db.cursor.execute("""select UNIX_TIMESTAMP(handStart) as time, id from Hands ORDER BY time""")