source: branches/hpc33/python/asaplotgui.py@ 2386

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

New Development: No

JIRA Issue: No (minor fixes and improvements)

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs: interactive testing

Put in Release Notes: No

Module(s): asapplotter, asaplotbase, flagplotter, sdplot, and sdflag

Description:

Misc bug fixes and minor modifications:
+ fixed bug in customgui_base (scantable class referenced but not imported)
+ minor improvement of toolbar message in customgui_tkagg
+ added a new method _set_window_title(string title) to asaplotgui_qt4 and asaplotgui modules

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1"""
2ASAP plotting class based on matplotlib.
3"""
4
5from asap.asaplotbase import *
6import Tkinter as Tk
7import matplotlib
8from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, \
9 FigureManagerTkAgg
10# Force use of the newfangled toolbar.
11matplotlib.rcParams['toolbar'] = 'toolbar2'
12
13class asaplotgui(asaplotbase):
14 """
15 ASAP plotting class based on matplotlib.
16 """
17
18 def __init__(self, rows=1, cols=0, title='', size=None, buffering=False):
19 """
20 Create a new instance of the ASAPlot plotting class.
21
22 If rows < 1 then a separate call to set_panels() is required to define
23 the panel layout; refer to the doctext for set_panels().
24 """
25 v = vars()
26 del v['self']
27
28 asaplotbase.__init__(self, **v)
29 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.canvas = FigureCanvasTkAgg(self.figure, master=self.window)
36 self.canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
37 # Simply instantiating this is enough to get a working toolbar.
38 self.figmgr = FigureManagerTkAgg(self.canvas, 1, self.window)
39 self._set_window_title('ASAP Plotter - Tk')
40
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()
49
50 def map(self):
51 """
52 Reveal the ASAPlot graphics window and bring it to the top of the
53 window stack.
54 """
55 self.window.wm_deiconify()
56 self.window.lift()
57
58 def quit(self):
59 """
60 Destroy the ASAPlot graphics window.
61 """
62 self.is_dead = True
63 self.window.destroy()
64
65 def show(self, hardrefresh=True):
66 """
67 Show graphics dependent on the current buffering state.
68 """
69 if not self.buffering:
70 if hardrefresh:
71 asaplotbase.show(self)
72 self.window.wm_deiconify()
73 self.canvas.show()
74
75 def terminate(self):
76 """
77 Clear the figure.
78 """
79 self.window.destroy()
80
81 def unmap(self):
82 """
83 Hide the ASAPlot graphics window.
84 """
85 self.window.wm_withdraw()
86
87 def _set_window_title(self,title):
88 # Set title to main window title bar
89 self.window.wm_title(title)
Note: See TracBrowser for help on using the repository browser.