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