Skip to content

Commit

Permalink
Tkinter slowness improvements
Browse files Browse the repository at this point in the history
previously, I had made lots of changes to, when a window is closed,
withdraw the dialog so that the user does not see the window being
destroyed piece by piece.  This is especially true for windows
containing matplotlib plots, which delete slowly and painfully.
This call was not being made when a window was destroyed by the
root window being destroyed, so I overload the tk destroy function
to withdraw the window invariably prior to destruction.
  • Loading branch information
PetePupalaikis committed Feb 3, 2019
1 parent 6fbf208 commit 2b32fe5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions SignalIntegrity/App/SParameterViewerWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ def onClosing(self):
self.withdraw()
self.destroy()

def destroy(self):
tk.Toplevel.withdraw(self)
tk.Toplevel.destroy(self)

def PlotSParameter(self):
import SignalIntegrity.Lib as si
self.topLeftPlot.cla()
Expand Down
11 changes: 7 additions & 4 deletions SignalIntegrity/App/SignalIntegrityApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,13 @@ def onResize(self,event):

self.deltaWidth=4
self.deltaHeight=50
self.Drawing.canvas.config(width=event.width-self.deltaWidth,height=event.height-self.deltaHeight)
SignalIntegrity.App.Project['Drawing.DrawingProperties.Width']=self.Drawing.canvas.winfo_width()
SignalIntegrity.App.Project['Drawing.DrawingProperties.Height']=self.Drawing.canvas.winfo_height()
SignalIntegrity.App.Project['Drawing.DrawingProperties.Geometry']=self.root.geometry()
try:
self.Drawing.canvas.config(width=event.width-self.deltaWidth,height=event.height-self.deltaHeight)
SignalIntegrity.App.Project['Drawing.DrawingProperties.Width']=self.Drawing.canvas.winfo_width()
SignalIntegrity.App.Project['Drawing.DrawingProperties.Height']=self.Drawing.canvas.winfo_height()
SignalIntegrity.App.Project['Drawing.DrawingProperties.Geometry']=self.root.geometry()
except tk.TclError:
pass

def onKey(self,event):
# print "pressed", repr(event.keycode), repr(event.keysym)
Expand Down
4 changes: 4 additions & 0 deletions SignalIntegrity/App/Simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ def onClosing(self):
self.withdraw()
self.destroy()

def destroy(self):
tk.Toplevel.withdraw(self)
tk.Toplevel.destroy(self)

def onAutoscale(self):
self.plt.autoscale(True)
self.f.canvas.draw()
Expand Down

0 comments on commit 2b32fe5

Please sign in to comment.