source: trunk/python/asaplotgui_gtk.py@ 2896

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

New Development: No

JIRA Issue: Yes (CAS-3749)

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs: unit tests of sdplot

Put in Release Notes: No

Module(s): sdplot, sdfit, sdstat, sdflag, sdcal, sdreduce

Description:

Made asapplotter not to generate plotter window at start-up, but the window is
only generated at the first invokation of plotting operation.


File size: 3.3 KB
Line 
1"""
2ASAP plotting class based on matplotlib.
3"""
4
5from asap.asaplotbase import *
6# Force use of the newfangled toolbar.
7import gtk
8import matplotlib
9from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas
10from matplotlib.backends.backend_gtkagg import FigureManagerGTKAgg
11matplotlib.use("GTkAgg")
12matplotlib.rcParams['toolbar'] = 'toolbar2'
13from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as NavigationToolbar
14from matplotlib import _pylab_helpers
15
16class asaplotgui(asaplotbase):
17 """
18 ASAP plotting class based on matplotlib.
19 """
20
21 def __init__(self, rows=1, cols=0, title='', size=None, buffering=False):
22 """
23 Create a new instance of the ASAPlot plotting class.
24
25 If rows < 1 then a separate call to set_panels() is required to define
26 the panel layout; refer to the doctext for set_panels().
27 """
28 v = vars()
29 del v['self']
30
31 asaplotbase.__init__(self, **v)
32 matplotlib.rcParams['interactive'] = True
33 matplotlib.interactive = True
34
35 _pylab_helpers.Gcf.destroy(0)
36 self.canvas = FigureCanvas(self.figure)
37 # Simply instantiating this is enough to get a working toolbar.
38 self.figmgr = FigureManagerGTKAgg(self.canvas, 1)
39 def dest_callback(val):
40 self.is_dead = True
41 self.figmgr.window.destroy()
42 self.window = self.figmgr.window
43 self.window.connect("destroy", dest_callback )
44 self.window.set_title('ASAP Plotter - GTK')
45 #self.canvas.set_size_request(800,600)
46 _pylab_helpers.Gcf.figs[self.figmgr.num] = self.figmgr
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 if self.is_dead:
56 raise RuntimeError( "No plotter to show. Not yet plotted or plotter is closed." )
57 self.window.deiconify()
58 #self.window.lift()
59
60 def quit(self):
61 """
62 Destroy the ASAPlot graphics window.
63 """
64 self.is_dead = True
65 if not self.figmgr:
66 return
67 #self.window.destroy()
68 _pylab_helpers.Gcf.destroy(self.figmgr.num)
69 del self.window, self.canvas, self.figmgr
70 self.window = None
71 self.canvas = None
72 self.figmgr = None
73
74 def show(self, hardrefresh=True):
75 """
76 Show graphics dependent on the current buffering state.
77 """
78 if self.is_dead:
79 raise RuntimeError( "No plotter to show (not yet plotted or closed)." )
80 if not self.buffering:
81 if hardrefresh:
82 asaplotbase.show(self, hardrefresh)
83 self.window.deiconify()
84 self.canvas.draw()
85 self.window.show_all()
86
87 def terminate(self):
88 """
89 Clear the figure.
90 """
91 if not self.window:
92 asaplog.push( "No plotter window to terminate." )
93 asaplog.post( "WARN" )
94 return
95 self.window.destroy()
96
97 def unmap(self):
98 """
99 Hide the ASAPlot graphics window.
100 """
101 if not self.window:
102 asaplog.push( "No plotter window to unmap." )
103 asaplog.post( "WARN" )
104 return
105 self.window.wm_withdraw()
Note: See TracBrowser for help on using the repository browser.