source: trunk/python/asaplotgui_qt4.py@ 2241

Last change on this file since 2241 was 2170, checked in by Kana Sugimoto, 14 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

File size: 2.7 KB
Line 
1"""
2ASAP plotting class based on matplotlib.
3"""
4
5from asap.asaplotbase import *
6import PyQt4 as qt
7from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg, \
8 FigureManagerQTAgg
9from matplotlib import _pylab_helpers
10# Force use of the newfangled toolbar.
11import matplotlib
12#matplotlib.use("Qt4Agg")
13matplotlib.rcParams['toolbar'] = 'toolbar2'
14
15class asaplotgui(asaplotbase):
16 """
17 ASAP plotting class based on matplotlib.
18 """
19
20 def __init__(self, rows=1, cols=0, title='', size=None, buffering=False):
21 """
22 Create a new instance of the ASAPlot plotting class.
23
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 """
27 v = vars()
28 del v['self']
29
30 asaplotbase.__init__(self, **v)
31
32 self.canvas = FigureCanvasQTAgg(self.figure)
33 # Simply instantiating this is enough to get a working toolbar.
34 self.figmgr = FigureManagerQTAgg(self.canvas, 1)
35 self.window = self.figmgr.window
36 self._set_window_title('ASAP Plotter - Qt4')
37 # register this plot to matplotlib
38 _pylab_helpers.Gcf.set_active(self.figmgr)
39
40 #############
41 ### DO WE HAVE TO DO SOMETHING FOR WINDOW CLOSE CALL?
42 #############
43 def dest_callback():
44 try:
45 self.is_dead = True
46 except NameError:
47 pass
48
49 qt.QtCore.QObject.connect(self.window, qt.QtCore.SIGNAL('destroyed()'),dest_callback)
50
51 self.events = {'button_press':None,
52 'button_release':None,
53 'motion_notify':None}
54
55 matplotlib.rcParams["interactive"] = True
56 self.buffering = buffering
57
58 self.unmap()
59 #self.canvas.show()
60
61 def map(self):
62 """
63 Reveal the ASAPlot graphics window and bring it to the top of the
64 window stack.
65 """
66 self.window.activateWindow()
67 #To raise this window to the top of the stacking order
68 self.window.raise_()
69 self.window.show()
70
71 def quit(self):
72 """
73 Destroy the ASAPlot graphics window.
74 """
75 self.is_dead = True
76 try: self.window.close()
77 except RuntimeError: pass # the window may already be closed by user
78
79 def show(self, hardrefresh=True):
80 """
81 Show graphics dependent on the current buffering state.
82 """
83 if not self.buffering:
84 if hardrefresh:
85 asaplotbase.show(self)
86 self.window.activateWindow()
87 self.canvas.draw()
88 #self.canvas.show()
89 self.window.show()
90
91 def terminate(self):
92 """
93 Clear the figure.
94 """
95 self.window.close()
96
97 def unmap(self):
98 """
99 Hide the ASAPlot graphics window.
100 """
101 self.window.hide()
102
103 def _set_window_title(self,title):
104 # Set title to main window title bar
105 self.window.setWindowTitle(title)
Note: See TracBrowser for help on using the repository browser.