source: trunk/python/asaplotgui.py@ 2484

Last change on this file since 2484 was 2469, checked in by Kana Sugimoto, 13 years ago

New Development: No

JIRA Issue: No (a bug fix)

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s): asapplotter

Description: putting back a line to merge CASA stable branch.


  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
RevLine 
[707]1"""
2ASAP plotting class based on matplotlib.
3"""
4
5from asap.asaplotbase import *
6import Tkinter as Tk
[1422]7import matplotlib
[707]8from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, \
9 FigureManagerTkAgg
10# Force use of the newfangled toolbar.
11matplotlib.rcParams['toolbar'] = 'toolbar2'
[2416]12from matplotlib import _pylab_helpers
[2451]13from asap.logging import asaplog, asaplog_post_dec
[707]14
15class asaplotgui(asaplotbase):
16 """
17 ASAP plotting class based on matplotlib.
18 """
19
[1563]20 def __init__(self, rows=1, cols=0, title='', size=None, buffering=False):
[1826]21 """
22 Create a new instance of the ASAPlot plotting class.
[707]23
[1826]24 If rows < 1 then a separate call to set_panels() is required to define
25 the panel layout; refer to the doctext for set_panels().
26 """
[707]27 v = vars()
28 del v['self']
[1153]29
[707]30 asaplotbase.__init__(self, **v)
[2451]31 #matplotlib.rcParams["interactive"] = True
32
[2469]33 _pylab_helpers.Gcf.destroy(0)
[707]34 self.window = Tk.Tk()
[2416]35 self.window.protocol("WM_DELETE_WINDOW", self.quit)
[707]36 self.canvas = FigureCanvasTkAgg(self.figure, master=self.window)
37 self.canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
38 # Simply instantiating this is enough to get a working toolbar.
[2416]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
[2170]43 self._set_window_title('ASAP Plotter - Tk')
[2451]44 self.canvas.show()
[707]45
46
47 def map(self):
[1826]48 """
49 Reveal the ASAPlot graphics window and bring it to the top of the
50 window stack.
51 """
[2451]52 if self.is_dead:
53 raise RuntimeError( "No plotter to show. Not yet plotted or plotter is closed." )
[1826]54 self.window.wm_deiconify()
55 self.window.lift()
[707]56
57 def quit(self):
[1826]58 """
59 Destroy the ASAPlot graphics window.
60 """
[2149]61 self.is_dead = True
[2451]62 if not self.figmgr:
63 return
[2416]64 #self.window.destroy()
65 _pylab_helpers.Gcf.destroy(self.figmgr.num)
[2451]66 del self.window, self.canvas, self.figmgr
[2416]67 self.window = None
68 self.canvas = None
[2451]69 self.figmgr = None
[707]70
[1153]71 def show(self, hardrefresh=True):
[1826]72 """
73 Show graphics dependent on the current buffering state.
74 """
[2451]75 if self.is_dead:
76 raise RuntimeError( "No plotter to show (not yet plotted or closed)." )
[1826]77 if not self.buffering:
[1153]78 if hardrefresh:
79 asaplotbase.show(self)
[1826]80 self.window.wm_deiconify()
81 self.canvas.show()
[707]82
83 def terminate(self):
[1826]84 """
85 Clear the figure.
86 """
[2451]87 if not self.window:
88 asaplog.push( "No plotter window to terminate." )
89 asaplog.post( "WARN" )
90 return
[1826]91 self.window.destroy()
[707]92
93 def unmap(self):
[1826]94 """
95 Hide the ASAPlot graphics window.
96 """
[2451]97 if not self.window:
98 asaplog.push( "No plotter window to unmap." )
99 asaplog.post( "WARN" )
100 return
[1826]101 self.window.wm_withdraw()
[2170]102
103 def _set_window_title(self,title):
104 # Set title to main window title bar
105 self.window.wm_title(title)
Note: See TracBrowser for help on using the repository browser.