Changeset 2416 for trunk/python


Ignore:
Timestamp:
02/21/12 14:11:09 (13 years ago)
Author:
Kana Sugimoto
Message:

New Development: No

JIRA Issue: Yes (CAS-3749)

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs: an interactive test

  1. load casapy (or standalone asap)
  2. matplotlib.pyplot.show() ---> 2 plotters (ASAP plotter and matplotlib plotter) are displayed and casapy prompt is paused.
  3. close all plotter windows ---> casapy prompt should be back

Put in Release Notes: No

Module(s): sdplot, asap.plotter

Description:

Fixed a bug in asapplotter with Tk backend which caused scripts and python shells
freeze after the initial invocation of matplotlib.pyplot.show() (known as pl.show() on CASA).
plus minor fixes which handle backend dependencies.

Location:
trunk/python
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asaplotgui.py

    r2170 r2416  
    1010# Force use of the newfangled toolbar.
    1111matplotlib.rcParams['toolbar'] = 'toolbar2'
     12from matplotlib import _pylab_helpers
    1213
    1314class asaplotgui(asaplotbase):
     
    2829        asaplotbase.__init__(self, **v)
    2930        self.window = Tk.Tk()
    30         def dest_callback():
    31             self.is_dead = True
    32             self.window.destroy()
     31        #def dest_callback():
     32        #    print "dest_callback"
     33        #    self.is_dead = True
     34        #    self.window.destroy()
    3335
    34         self.window.protocol("WM_DELETE_WINDOW", dest_callback)
     36        self.window.protocol("WM_DELETE_WINDOW", self.quit)
    3537        self.canvas = FigureCanvasTkAgg(self.figure, master=self.window)
    3638        self.canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
    3739        # Simply instantiating this is enough to get a working toolbar.
    38         self.figmgr = FigureManagerTkAgg(self.canvas, 1, self.window)
     40        self.figmgr = FigureManagerTkAgg(self.canvas, 0, self.window)
     41        # Register this plot to matplotlib without activating it
     42        #_pylab_helpers.Gcf.set_active(self.figmgr)
     43        _pylab_helpers.Gcf.figs[self.figmgr.num] = self.figmgr
    3944        self._set_window_title('ASAP Plotter - Tk')
    4045
     
    6166        """
    6267        self.is_dead = True
    63         self.window.destroy()
     68        #self.window.destroy()
     69        _pylab_helpers.Gcf.destroy(self.figmgr.num)
     70        del self.window, self.canvas
     71        self.window = None
     72        self.canvas = None
     73       
    6474
    6575    def show(self, hardrefresh=True):
  • trunk/python/asaplotgui_qt4.py

    r2170 r2416  
    3232        self.canvas = FigureCanvasQTAgg(self.figure)
    3333        # Simply instantiating this is enough to get a working toolbar.
    34         self.figmgr = FigureManagerQTAgg(self.canvas, 1)
     34        self.figmgr = FigureManagerQTAgg(self.canvas, 0)
    3535        self.window = self.figmgr.window
    3636        self._set_window_title('ASAP Plotter - Qt4')
    37         # register this plot to matplotlib
    38         _pylab_helpers.Gcf.set_active(self.figmgr)
     37        # Register this plot to matplotlib without activating it
     38        #_pylab_helpers.Gcf.set_active(self.figmgr)
     39        _pylab_helpers.Gcf.figs[self.figmgr.num] = self.figmgr
    3940
    4041        #############
  • trunk/python/asapplotter.py

    r2290 r2416  
    12561256        PL.ion()
    12571257        PL.draw()
    1258         PL.gcf().show()
     1258        if matplotlib.get_backend() == 'Qt4Agg': PL.gcf().show()
    12591259        if (self._outfile is not None):
    12601260           PL.savefig(self._outfile)
     
    12951295        [xmin,xmax,ymin,ymax] = PL.axis()
    12961296        PL.axis([xmax,xmin,ymin,ymax])
    1297         #PL.ion()
     1297        PL.ion()
    12981298        PL.draw()
    1299         PL.gcf().show()
     1299        if matplotlib.get_backend() == 'Qt4Agg': PL.gcf().show()
    13001300        if (self._outfile is not None):
    13011301           PL.savefig(self._outfile)
  • trunk/python/customgui_tkagg.py

    r2174 r2416  
    135135        self.disable_button()
    136136        self.figmgr.window.wm_withdraw()
     137        self._p.quit()
    137138
    138139    def enable_button(self):
     
    147148        #self.bSpec.config(relief='raised', state=Tk.DISABLED)
    148149        self.bStat.config(relief='raised', state=Tk.DISABLED)
    149         #self.bNext.config(state=Tk.DISABLED)
    150         #self.bPrev.config(state=Tk.DISABLED)
     150        self.bNext.config(state=Tk.DISABLED)
     151        self.bPrev.config(state=Tk.DISABLED)
    151152        self.button = False
    152153        self.mode = ''
     
    647648        self.disable_button()
    648649        self.figmgr.window.wm_withdraw()
     650        self._p.quit()
    649651
    650652    def enable_button(self):
Note: See TracChangeset for help on using the changeset viewer.