Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asaplotgui.py

    r2170 r2469  
    1010# Force use of the newfangled toolbar.
    1111matplotlib.rcParams['toolbar'] = 'toolbar2'
     12from matplotlib import _pylab_helpers
     13from asap.logging import asaplog, asaplog_post_dec
    1214
    1315class asaplotgui(asaplotbase):
     
    2729
    2830        asaplotbase.__init__(self, **v)
     31        #matplotlib.rcParams["interactive"] = True
     32
     33        _pylab_helpers.Gcf.destroy(0)
    2934        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)
    3536        self.canvas = FigureCanvasTkAgg(self.figure, master=self.window)
    3637        self.canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
    3738        # 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
    3943        self._set_window_title('ASAP Plotter - Tk')
     44        self.canvas.show()
    4045
    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()
    4946
    5047    def map(self):
     
    5350        window stack.
    5451        """
     52        if self.is_dead:
     53            raise RuntimeError( "No plotter to show. Not yet plotted or plotter is closed." )
    5554        self.window.wm_deiconify()
    5655        self.window.lift()
     
    6160        """
    6261        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
    6470
    6571    def show(self, hardrefresh=True):
     
    6773        Show graphics dependent on the current buffering state.
    6874        """
     75        if self.is_dead:
     76            raise RuntimeError( "No plotter to show (not yet plotted or closed)." )
    6977        if not self.buffering:
    7078            if hardrefresh:
     
    7785        Clear the figure.
    7886        """
     87        if not self.window:
     88            asaplog.push( "No plotter window to terminate." )
     89            asaplog.post( "WARN" )
     90            return
    7991        self.window.destroy()
    8092
     
    8395        Hide the ASAPlot graphics window.
    8496        """
     97        if not self.window:
     98            asaplog.push( "No plotter window to unmap." )
     99            asaplog.post( "WARN" )
     100            return
    85101        self.window.wm_withdraw()
    86102
Note: See TracChangeset for help on using the changeset viewer.