Changes in trunk/python/asaplotgui.py [2469:2170]
- File:
-
- 1 edited
-
trunk/python/asaplotgui.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asaplotgui.py
r2469 r2170 10 10 # Force use of the newfangled toolbar. 11 11 matplotlib.rcParams['toolbar'] = 'toolbar2' 12 from matplotlib import _pylab_helpers13 from asap.logging import asaplog, asaplog_post_dec14 12 15 13 class asaplotgui(asaplotbase): … … 29 27 30 28 asaplotbase.__init__(self, **v) 31 #matplotlib.rcParams["interactive"] = True 29 self.window = Tk.Tk() 30 def dest_callback(): 31 self.is_dead = True 32 self.window.destroy() 32 33 33 _pylab_helpers.Gcf.destroy(0) 34 self.window = Tk.Tk() 35 self.window.protocol("WM_DELETE_WINDOW", self.quit) 34 self.window.protocol("WM_DELETE_WINDOW", dest_callback) 36 35 self.canvas = FigureCanvasTkAgg(self.figure, master=self.window) 37 36 self.canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1) 38 37 # Simply instantiating this is enough to get a working toolbar. 39 self.figmgr = FigureManagerTkAgg(self.canvas, 0, self.window) 40 # Register this plot to matplotlib without activating it 41 #_pylab_helpers.Gcf.set_active(self.figmgr) 42 _pylab_helpers.Gcf.figs[self.figmgr.num] = self.figmgr 38 self.figmgr = FigureManagerTkAgg(self.canvas, 1, self.window) 43 39 self._set_window_title('ASAP Plotter - Tk') 44 self.canvas.show()45 40 41 self.events = {'button_press':None, 42 'button_release':None, 43 'motion_notify':None} 44 45 matplotlib.rcParams["interactive"] = True 46 #self.buffering = buffering 47 48 self.canvas.show() 46 49 47 50 def map(self): … … 50 53 window stack. 51 54 """ 52 if self.is_dead:53 raise RuntimeError( "No plotter to show. Not yet plotted or plotter is closed." )54 55 self.window.wm_deiconify() 55 56 self.window.lift() … … 60 61 """ 61 62 self.is_dead = True 62 if not self.figmgr: 63 return 64 #self.window.destroy() 65 _pylab_helpers.Gcf.destroy(self.figmgr.num) 66 del self.window, self.canvas, self.figmgr 67 self.window = None 68 self.canvas = None 69 self.figmgr = None 63 self.window.destroy() 70 64 71 65 def show(self, hardrefresh=True): … … 73 67 Show graphics dependent on the current buffering state. 74 68 """ 75 if self.is_dead:76 raise RuntimeError( "No plotter to show (not yet plotted or closed)." )77 69 if not self.buffering: 78 70 if hardrefresh: … … 85 77 Clear the figure. 86 78 """ 87 if not self.window:88 asaplog.push( "No plotter window to terminate." )89 asaplog.post( "WARN" )90 return91 79 self.window.destroy() 92 80 … … 95 83 Hide the ASAPlot graphics window. 96 84 """ 97 if not self.window:98 asaplog.push( "No plotter window to unmap." )99 asaplog.post( "WARN" )100 return101 85 self.window.wm_withdraw() 102 86
Note:
See TracChangeset
for help on using the changeset viewer.
