source: trunk/python/asaplotgui.py@ 2134

Last change on this file since 2134 was 1826, checked in by Malte Marquarding, 14 years ago

Tidy up of imports (now imported from asap.). Also fixed some whitespace/tab issues

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.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'
12
13class asaplotgui(asaplotbase):
14 """
15 ASAP plotting class based on matplotlib.
16 """
17
[1563]18 def __init__(self, rows=1, cols=0, title='', size=None, buffering=False):
[1826]19 """
20 Create a new instance of the ASAPlot plotting class.
[707]21
[1826]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 """
[707]25 v = vars()
26 del v['self']
[1153]27
[707]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)
[1153]39 self.window.wm_title('ASAP Plotter - Tk')
[707]40
41 self.events = {'button_press':None,
42 'button_release':None,
43 'motion_notify':None}
44
[1153]45 matplotlib.rcParams["interactive"] = True
46 #self.buffering = buffering
[707]47
48 self.canvas.show()
49
50 def map(self):
[1826]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()
[707]57
58 def quit(self):
[1826]59 """
60 Destroy the ASAPlot graphics window.
61 """
62 self.window.destroy()
[707]63
[1153]64 def show(self, hardrefresh=True):
[1826]65 """
66 Show graphics dependent on the current buffering state.
67 """
68 if not self.buffering:
[1153]69 if hardrefresh:
70 asaplotbase.show(self)
[1826]71 self.window.wm_deiconify()
72 self.canvas.show()
[707]73
74 def terminate(self):
[1826]75 """
76 Clear the figure.
77 """
78 self.window.destroy()
[707]79
80 def unmap(self):
[1826]81 """
82 Hide the ASAPlot graphics window.
83 """
84 self.window.wm_withdraw()
Note: See TracBrowser for help on using the repository browser.