Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asaplotgui.py

    r2469 r2170  
    1010# Force use of the newfangled toolbar.
    1111matplotlib.rcParams['toolbar'] = 'toolbar2'
    12 from matplotlib import _pylab_helpers
    13 from asap.logging import asaplog, asaplog_post_dec
    1412
    1513class asaplotgui(asaplotbase):
     
    2927
    3028        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()
    3233
    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)
    3635        self.canvas = FigureCanvasTkAgg(self.figure, master=self.window)
    3736        self.canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
    3837        # 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)
    4339        self._set_window_title('ASAP Plotter - Tk')
    44         self.canvas.show()
    4540
     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()
    4649
    4750    def map(self):
     
    5053        window stack.
    5154        """
    52         if self.is_dead:
    53             raise RuntimeError( "No plotter to show. Not yet plotted or plotter is closed." )
    5455        self.window.wm_deiconify()
    5556        self.window.lift()
     
    6061        """
    6162        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()
    7064
    7165    def show(self, hardrefresh=True):
     
    7367        Show graphics dependent on the current buffering state.
    7468        """
    75         if self.is_dead:
    76             raise RuntimeError( "No plotter to show (not yet plotted or closed)." )
    7769        if not self.buffering:
    7870            if hardrefresh:
     
    8577        Clear the figure.
    8678        """
    87         if not self.window:
    88             asaplog.push( "No plotter window to terminate." )
    89             asaplog.post( "WARN" )
    90             return
    9179        self.window.destroy()
    9280
     
    9583        Hide the ASAPlot graphics window.
    9684        """
    97         if not self.window:
    98             asaplog.push( "No plotter window to unmap." )
    99             asaplog.post( "WARN" )
    100             return
    10185        self.window.wm_withdraw()
    10286
Note: See TracChangeset for help on using the changeset viewer.