source: trunk/python/customgui_tkagg.py@ 2160

Last change on this file since 2160 was 2155, checked in by Kana Sugimoto, 14 years ago

New Development: Yes

JIRA Issue: No (reorganization of modules)

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: the modules casatoolbar, flagtoolbar, notaionwindow, were reorganized as customgui_base, customgui_tkagg, and customgui_qt4agg, based on backend

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...


File size: 25.8 KB
Line 
1import os
2import matplotlib, numpy
3from asap.logging import asaplog, asaplog_post_dec
4from matplotlib.patches import Rectangle
5from asap.parameters import rcParams
6from asap._asap import stmath
7from asap.customgui_base import *
8
9import Tkinter as Tk
10import tkMessageBox
11
12######################################
13## Add CASA custom toolbar ##
14######################################
15class CustomToolbarTkAgg(CustomToolbarCommon, Tk.Frame):
16 def __init__(self,parent):
17 from asap.asapplotter import asapplotter
18 if not isinstance(parent,asapplotter):
19 return False
20 if not parent._plotter:
21 return False
22 self._p = parent._plotter
23 self.figmgr = self._p.figmgr
24 self.canvas = self.figmgr.canvas
25 self.mode = ''
26 self.button = True
27 self.pagecount = None
28 CustomToolbarCommon.__init__(self,parent)
29 self.notewin = NotationWindowTkAgg(master=self.canvas)
30 self._add_custom_toolbar()
31
32 def _add_custom_toolbar(self):
33 Tk.Frame.__init__(self,master=self.figmgr.window)
34 #self.bSpec = self._NewButton(master=self,
35 # text='spec value',
36 # command=self.spec_show)
37 self.bNote = self._NewButton(master=self,
38 text='notation',
39 command=self.modify_note)
40
41 self.bStat = self._NewButton(master=self,
42 text='statistics',
43 command=self.stat_cal)
44 self.bQuit = self._NewButton(master=self,
45 text='Quit',
46 command=self.quit,
47 side=Tk.RIGHT)
48
49 # page change oparations
50 frPage = Tk.Frame(master=self,borderwidth=2,relief=Tk.GROOVE)
51 frPage.pack(ipadx=2,padx=10,side=Tk.RIGHT)
52 self.lPagetitle = Tk.Label(master=frPage,text='Page:',padx=5)
53 self.lPagetitle.pack(side=Tk.LEFT)
54 self.pagecount = Tk.StringVar(master=frPage)
55 self.lPagecount = Tk.Label(master=frPage,
56 textvariable=self.pagecount,
57 padx=5,bg='white')
58 self.lPagecount.pack(side=Tk.LEFT,padx=3)
59
60 self.bNext = self._NewButton(master=frPage,
61 text=' + ',
62 command=self.next_page)
63 self.bPrev = self._NewButton(master=frPage,
64 text=' - ',
65 command=self.prev_page)
66
67 if os.uname()[0] != 'Darwin':
68 self.bPrev.config(padx=5)
69 self.bNext.config(padx=5)
70
71 self.pack(side=Tk.BOTTOM,fill=Tk.BOTH)
72 self.pagecount.set(' '*4)
73
74 self.disable_button()
75 return #self
76
77 def _NewButton(self, master, text, command, side=Tk.LEFT):
78 if os.uname()[0] == 'Darwin':
79 b = Tk.Button(master=master, text=text, command=command)
80 else:
81 b = Tk.Button(master=master, text=text, padx=2, pady=2,
82 command=command)
83 b.pack(side=side)
84 return b
85
86 def show_pagenum(self,pagenum,formatstr):
87 self.pagecount.set(formatstr % (pagenum))
88
89 def spec_show(self):
90 if not self.figmgr.toolbar.mode == '' or not self.button: return
91 self.figmgr.toolbar.set_message('spec value: drag on a spec')
92 if self.mode == 'spec': return
93 #self.bStat.config(relief='raised')
94 #self.bSpec.config(relief='sunken')
95 #self.bNote.config(relief='raised')
96 self.mode = 'spec'
97 self.notewin.close_widgets()
98 self.__disconnect_event()
99 self._p.register('button_press',self._select_spectrum)
100
101 def stat_cal(self):
102 if not self.figmgr.toolbar.mode == '' or not self.button: return
103 self.figmgr.toolbar.set_message('statistics: select a region')
104 if self.mode == 'stat':
105 # go back to spec mode
106 self.bStat.config(relief='raised')
107 self.spec_show()
108 return
109 #self.bSpec.config(relief='raised')
110 self.bStat.config(relief='sunken')
111 self.bNote.config(relief='raised')
112 self.mode = 'stat'
113 self.notewin.close_widgets()
114 self.__disconnect_event()
115 self._p.register('button_press',self._single_mask)
116
117 def modify_note(self):
118 if not self.figmgr.toolbar.mode == '': return
119 self.figmgr.toolbar.set_message('text: select a position/text')
120 if self.mode == 'note':
121 self.bNote.config(relief='raised')
122 self.mode = 'none'
123 self.spec_show()
124 return
125 #self.bSpec.config(relief='raised')
126 self.bStat.config(relief='raised')
127 self.bNote.config(relief='sunken')
128 self.mode = 'note'
129 self.__disconnect_event()
130 self._p.register('button_press',self._mod_note)
131
132 def quit(self):
133 self.__disconnect_event()
134 #self.delete_bar()
135 self.disable_button()
136 self.figmgr.window.wm_withdraw()
137
138 def enable_button(self):
139 if self.button: return
140 #self.bSpec.config(state=Tk.NORMAL)
141 self.bStat.config(state=Tk.NORMAL)
142 self.button = True
143 self.spec_show()
144
145 def disable_button(self):
146 if not self.button: return
147 #self.bSpec.config(relief='raised', state=Tk.DISABLED)
148 self.bStat.config(relief='raised', state=Tk.DISABLED)
149 #self.bNext.config(state=Tk.DISABLED)
150 #self.bPrev.config(state=Tk.DISABLED)
151 self.button = False
152 self.mode = ''
153 self.__disconnect_event()
154
155 def enable_next(self):
156 self.bNext.config(state=Tk.NORMAL)
157
158 def disable_next(self):
159 self.bNext.config(state=Tk.DISABLED)
160
161 def enable_prev(self):
162 self.bPrev.config(state=Tk.NORMAL)
163
164 def disable_prev(self):
165 self.bPrev.config(state=Tk.DISABLED)
166
167 # pause buttons for slow operations
168 def _pause_buttons(self,operation="end",msg=""):
169 buttons = ["bStat","bNote","bQuit"]
170 if operation == "start":
171 state = Tk.DISABLED
172 else:
173 state = Tk.NORMAL
174 for btn in buttons:
175 getattr(self,btn).config(state=state)
176 self.figmgr.toolbar.set_message(msg)
177
178 def delete_bar(self):
179 self.__disconnect_event()
180 self.destroy()
181
182 def __disconnect_event(self):
183 self._p.register('button_press',None)
184 self._p.register('button_release',None)
185
186
187
188
189######################################
190## Notation box window ##
191######################################
192class NotationWindowTkAgg(NotationWindowCommon):
193 """
194 Backend based class to create widgets to add, modify, or delete
195 note on the plot.
196
197 Note:
198 Press LEFT-mouse button on the plot to ADD a note on the canvas.
199 A notation window will be loaded for specifying note string and
200 anchor. The note will be anchored on a position in whether figure-
201 (0-1 relative in a figure), panel- (0-1 relative in a plot axes),
202 or data-coordinate (data value in a plot axes).
203 Press RIGHT-mouse button on a note to MODIFY/DELETE it. A cascade
204 menu will be displayed and you can select an operation.
205 """
206 def __init__(self,master=None):
207 self.parent = master._tkcanvas
208 NotationWindowCommon.__init__(self,master=master)
209 self.anchval = None
210 self.textwin = self._create_textwindow(master=None)
211 self.menu = self._create_modmenu(master=self.parent)
212
213 ### Notation window widget
214 def _create_textwindow(self,master=None):
215 """Create notation window widget and iconfy it"""
216 twin = Tk.Toplevel(padx=3,pady=3)
217 twin.title("Notation")
218 twin.resizable(width=True,height=True)
219 self.textbox = self._NotationBox(parent=twin)
220 self.radio = self._AnchorRadio(parent=twin)
221 self.actionbs = self._ActionButtons(parent=twin)
222
223 self.textbox.pack(side=Tk.TOP,fill=Tk.BOTH,expand=True)
224 self.actionbs.pack(side=Tk.BOTTOM)
225 self.radio.pack(side=Tk.BOTTOM)
226 #twin.deiconify()
227 #twin.minsize(width=twin.winfo_width(),height=twin.winfo_height())
228 #twin.lift()
229 twin.withdraw()
230 return twin
231
232 def _NotationBox(self,parent=None):
233 textbox = Tk.Text(master=parent,background='white',
234 height=2,width=20,cursor="xterm",
235 padx=2,pady=2,undo=True,maxundo=10,
236 relief='sunken',borderwidth=3,
237 state=Tk.NORMAL,takefocus=1)
238 return textbox
239
240 def _AnchorRadio(self,parent=None):
241 radio = Tk.LabelFrame(master=parent,text="anchor",
242 labelanchor="nw",padx=5,pady=3)
243 self.anchval = Tk.IntVar(master=radio,value=0)
244 self.rFig = self._NewRadioButton(radio,"figure",state=Tk.NORMAL,
245 variable=self.anchval,value=0,
246 side=Tk.LEFT)
247 self.rAxis = self._NewRadioButton(radio,"panel",state=Tk.DISABLED,
248 variable=self.anchval,value=1,
249 side=Tk.LEFT)
250 self.rData = self._NewRadioButton(radio,"data",state=Tk.DISABLED,
251 variable=self.anchval,value=2,
252 side=Tk.LEFT)
253 # set initial selection "figure"
254 self.anchval.set(0)
255 return radio
256
257 def _NewRadioButton(self,parent,text,state=Tk.NORMAL,variable=None,value=None,side=Tk.LEFT):
258 rb = Tk.Radiobutton(master=parent,text=text,state=state,
259 variable=variable,value=value)
260 rb.pack(side=side)
261 return rb
262
263 def _enable_radio(self):
264 """Enable 'panel' and 'data' radio button"""
265 self.rAxis.config(state=Tk.NORMAL)
266 self.rData.config(state=Tk.NORMAL)
267 #self.rFig.config(state=Tk.NORMAL)
268 self.rFig.select()
269
270 def _reset_radio(self):
271 """Disable 'panel' and 'data' radio button"""
272 self.rAxis.config(state=Tk.DISABLED)
273 self.rData.config(state=Tk.DISABLED)
274 self.rFig.config(state=Tk.NORMAL)
275 self.rFig.select()
276
277 def _select_radio(self,selection):
278 """Select a specified radio button"""
279 if not selection in self.anchors:
280 return
281 if selection == "data":
282 self.rData.select()
283 elif selection == "axes":
284 self.rAxis.select()
285 else:
286 self.rFig.select()
287
288 def _get_anchval(self):
289 """Returns a integer of a selected radio button"""
290 return self.anchval.get()
291
292 def _get_note(self):
293 """Returns a note string specified in the text box"""
294 return self.textbox.get("1.0",Tk.END)
295
296 def _clear_textbox(self):
297 """Clear the text box"""
298 self.textbox.delete("1.0",Tk.END)
299
300 def _set_note(self,note=None):
301 """Set a note string to the text box"""
302 self._clear_textbox()
303 if len(note) >0:
304 self.textbox.insert("1.0",note)
305
306 def _ActionButtons(self,parent=None):
307 actbuts = Tk.Frame(master=parent)
308 bCancel = self._NewButton(actbuts,"cancel",self._cancel_text,side=Tk.LEFT)
309 bPrint = self._NewButton(actbuts,"print", self._print_text,side=Tk.LEFT)
310 return actbuts
311
312 def _NewButton(self, parent, text, command, side=Tk.LEFT):
313 if(os.uname()[0] == 'Darwin'):
314 b = Tk.Button(master=parent, text=text, command=command)
315 else:
316 b = Tk.Button(master=parent, text=text, padx=2, pady=2, command=command)
317 b.pack(side=side)
318 return b
319
320 def _cancel_text(self):
321 """
322 Cancel adding/modifying a note and close notaion window.
323 called when 'cancel' is selected.
324 """
325 self.close_textwindow()
326
327 def _print_text(self):
328 """
329 Add/Modify a note. Called when 'print' is selected on the
330 notation window.
331 """
332 self.print_text()
333 self.close_textwindow()
334
335 def load_textwindow(self,event):
336 """
337 Load text window at a event position to add a note on a plot.
338 Parameter:
339 event: an even object to specify the position to load
340 text window.
341 """
342 self.close_modmenu()
343 if event.canvas._tkcanvas != self.parent:
344 raise RuntimeError, "Got invalid event!"
345
346 self.event = event
347 is_ax = (event.inaxes != None)
348 (xpix, ypix) = self._disppix2screen(event.x, event.y)
349 offset = 5
350 self.show_textwindow(xpix+offset,ypix+offset,enableaxes=is_ax)
351
352 def show_textwindow(self,xpix,ypix,basetext=None,enableaxes=False):
353 """
354 Load text window at a position of screen to add a note on a plot.
355 Parameters:
356 xpix, ypix: a pixel position from Upper-left corner
357 of the screen.
358 basetext: None (default) or any string.
359 A string to be printed on text box when loaded.
360 enable axes: False (default) or True.
361 If True, 'panel' & 'data' radio button is enabled.
362 """
363 if not self.textwin: return
364 self._reset_radio()
365 if enableaxes:
366 self._enable_radio()
367 self.textwin.deiconify()
368 (w,h) = self.textwin.minsize()
369 if w*h <= 1:
370 self.textwin.minsize(width=self.textwin.winfo_width(),
371 height=self.textwin.winfo_height())
372 (w,h) = self.textwin.minsize()
373 self.textwin.geometry("%sx%s+%s+%s"%(w,h,xpix,ypix))
374 self.textwin.lift()
375
376 def close_textwindow(self):
377 """Close text window."""
378 self.seltext = {}
379 self._reset_radio()
380 self._clear_textbox()
381 self.textwin.withdraw()
382
383
384 ### Modify/Delete menu widget
385 def _create_modmenu(self,master=None):
386 """Create modify/delete menu widget"""
387 if master:
388 self.parent = master
389 if not self.parent:
390 return False
391 menu = Tk.Menu(master=self.parent,tearoff=False)
392 menu.add_command(label="Modify",command=self._modify_note)
393 menu.add_command(label="Delete",command=self._delnote_dialog)
394 return menu
395
396 def load_modmenu(self,event):
397 """
398 Load cascade menu at a event position to modify or delete
399 selected text.
400 Parameter:
401 event: an even object to specify the position to load
402 text window.
403 """
404 self.close_textwindow()
405 self.seltext = self._get_selected_text(event)
406 if len(self.seltext) == 3:
407 tkcanvas = event.canvas._tkcanvas
408 xpos = tkcanvas.winfo_rootx() + int(event.x)
409 ypos = tkcanvas.winfo_rooty() \
410 + tkcanvas.winfo_height() - int(event.y)
411 self.menu.post(xpos,ypos)
412
413 def close_modmenu(self):
414 """Close cascade menu."""
415 self.seltext = {}
416 self.menu.unpost()
417
418 ### load text window for modification
419 def _modify_note(self):
420 """helper function to load text window to modify selected note"""
421 #print "Modify selected!!"
422 textobj = self.seltext['textobj']
423 (xtx, ytx) = textobj._get_xy_display()
424 is_ax = (self.seltext['anchor'] != 'figure')
425 if not is_ax:
426 # previous anchor is figure
427 pos = textobj.get_position()
428 is_ax = (self._get_axes_from_pos(pos,self.canvas) != None)
429
430 (xpix, ypix) = self._disppix2screen(xtx,ytx)
431 offset = int(textobj.get_size())*2
432 self.show_textwindow(xpix,ypix+offset,basetext=textobj.get_text(),\
433 enableaxes=is_ax)
434 self._select_radio(self.seltext['anchor'])
435 self._set_note(textobj.get_text())
436
437 ### close all widgets
438 def close_widgets(self):
439 """Close note window and menu"""
440 self.close_textwindow()
441 self.close_modmenu()
442
443 ### dialog to confirm deleting note
444 def _delnote_dialog(self):
445 """Load dialog to confirm deletion of the text"""
446 remind = "Delete text?\n '"+self.seltext['textobj'].get_text()+"'"
447 answer = tkMessageBox.askokcancel(parent=self.parent,title="Delete?",
448 message=remind,
449 default=tkMessageBox.CANCEL)
450 if answer:
451 self.delete_note()
452 else:
453 self.cancel_delete()
454
455 ### helper functions
456 def _disppix2screen(self,xpixd,ypixd):
457 """
458 helper function to calculate a pixel position form Upper-left
459 corner of the SCREEN from a pixel position (xpixd, ypixd)
460 from Lower-left of the CANVAS (which, e.g., event.x/y returns)
461
462 Returns:
463 (x, y): pixel position from Upper-left corner of the SCREEN.
464 """
465 xpixs = self.parent.winfo_rootx() + xpixd
466 ypixs = self.parent.winfo_rooty() + self.parent.winfo_height() \
467 - ypixd
468 return (int(xpixs), int(ypixs))
469
470
471
472
473
474
475###########################################
476## Add CASA custom Flag toolbar ##
477###########################################
478class CustomFlagToolbarTkAgg(CustomFlagToolbarCommon, Tk.Frame):
479 def __init__(self,parent):
480 from asap.asapplotter import asapplotter
481 if not isinstance(parent,asapplotter):
482 return False
483 if not parent._plotter:
484 return False
485 self._p = parent._plotter
486 self.figmgr = self._p.figmgr
487 self.canvas = self.figmgr.canvas
488 self.mode = ''
489 self.button = True
490 self.pagecount = None
491 CustomFlagToolbarCommon.__init__(self,parent)
492 self.notewin=NotationWindowTkAgg(master=self.canvas)
493 self._add_custom_toolbar()
494
495 def _add_custom_toolbar(self):
496 Tk.Frame.__init__(self,master=self.figmgr.window)
497 #self.bSpec = self._NewButton(master=self,
498 # text='spec value',
499 # command=self.spec_show)
500
501 self.bRegion = self._NewButton(master=self,
502 text='region',
503 command=self.select_region)
504 self.bPanel = self._NewButton(master=self,
505 text='panel',
506 command=self.select_panel)
507 self.bClear = self._NewButton(master=self,
508 text='clear',
509 command=self.cancel_select)
510 self.bFlag = self._NewButton(master=self,
511 text='flag',
512 command=self.flag)
513 self.bUnflag = self._NewButton(master=self,
514 text='unflag',
515 command=self.unflag)
516
517 self.bStat = self._NewButton(master=self,
518 text='statistics',
519 command=self.stat_cal)
520
521 self.bNote = self._NewButton(master=self,
522 text='notation',
523 command=self.modify_note)
524
525 self.bQuit = self._NewButton(master=self,
526 text='Quit',
527 #file="stock_close.ppm",
528 command=self.quit,
529 side=Tk.RIGHT)
530
531 # page change oparations
532 frPage = Tk.Frame(master=self,borderwidth=2,relief=Tk.GROOVE)
533 frPage.pack(ipadx=2,padx=10,side=Tk.RIGHT)
534 self.lPagetitle = Tk.Label(master=frPage,text='Page:',padx=5)
535 #width=8,anchor=Tk.E,padx=5)
536 self.lPagetitle.pack(side=Tk.LEFT)
537 self.pagecount = Tk.StringVar(master=frPage)
538 self.lPagecount = Tk.Label(master=frPage,
539 textvariable=self.pagecount,
540 padx=5,bg='white')
541 self.lPagecount.pack(side=Tk.LEFT,padx=3)
542
543 self.bNext=self._NewButton(master=frPage,
544 text=' + ',
545 #file="hand.ppm",
546 command=self.next_page)
547 self.bPrev=self._NewButton(master=frPage,
548 text=' - ',
549 command=self.prev_page)
550
551 if os.uname()[0] != 'Darwin':
552 self.bPrev.config(padx=5)
553 self.bNext.config(padx=5)
554
555 self.pack(side=Tk.BOTTOM,fill=Tk.BOTH)
556 self.pagecount.set(' '*4)
557
558 self.disable_button()
559 return #self
560
561 def _NewButton(self, master, text, command, side=Tk.LEFT,file=None):
562 img = None
563 if file:
564 file = os.path.join(matplotlib.rcParams['datapath'], 'images', file)
565 img = Tk.PhotoImage(master=master, file=file)
566
567 if os.uname()[0] == 'Darwin':
568 b = Tk.Button(master=master, text=text, image=img,
569 command=command)
570 if img: b.image = img
571 else:
572 b = Tk.Button(master=master, text=text, image=img, padx=2, pady=2,
573 command=command)
574 if img: b.image = img
575 b.pack(side=side)
576 return b
577
578 def show_pagenum(self,pagenum,formatstr):
579 self.pagecount.set(formatstr % (pagenum))
580
581 def spec_show(self):
582 if not self.figmgr.toolbar.mode == '' or not self.button: return
583 self.figmgr.toolbar.set_message('spec value: drag on a spec')
584 if self.mode == 'spec': return
585 self.mode = 'spec'
586 self.notewin.close_widgets()
587 self.__disconnect_event()
588 self._p.register('button_press',self._select_spectrum)
589
590 def modify_note(self):
591 if not self.figmgr.toolbar.mode == '': return
592 self.figmgr.toolbar.set_message('text: select a position/text')
593 if self.mode == 'note':
594 self.bNote.config(relief='raised')
595 self.mode = 'none'
596 self.spec_show()
597 return
598 self.bNote.config(relief='sunken')
599 self.bRegion.config(relief='raised')
600 self.bPanel.config(relief='raised')
601 self.mode = 'note'
602 self.__disconnect_event()
603 self._p.register('button_press',self._mod_note)
604
605 def select_region(self):
606 if not self.figmgr.toolbar.mode == '' or not self.button: return
607 self.figmgr.toolbar.set_message('select rectangle regions')
608 if self.mode == 'region':
609 self.bRegion.config(relief='raised')
610 self.mode = 'none'
611 self.spec_show()
612 return
613 self.bNote.config(relief='raised')
614 self.bRegion.config(relief='sunken')
615 self.bPanel.config(relief='raised')
616 self.mode = 'region'
617 self.notewin.close_widgets()
618 self.__disconnect_event()
619 self._p.register('button_press',self._add_region)
620
621 def select_panel(self):
622 if not self.figmgr.toolbar.mode == '' or not self.button: return
623 self.figmgr.toolbar.set_message('select panels')
624 if self.mode == 'panel':
625 self.bPanel.config(relief='raised')
626 self.mode = 'none'
627 self.spec_show()
628 return
629 self.bNote.config(relief='raised')
630 self.bRegion.config(relief='raised')
631 self.bPanel.config(relief='sunken')
632 self.mode = 'panel'
633 self.notewin.close_widgets()
634 self.__disconnect_event()
635 self._p.register('button_press',self._add_panel)
636
637 def quit(self):
638 self.__disconnect_event()
639 self.disable_button()
640 self.figmgr.window.wm_withdraw()
641
642 def enable_button(self):
643 if self.button: return
644 self.bRegion.config(state=Tk.NORMAL)
645 self.bPanel.config(state=Tk.NORMAL)
646 self.bClear.config(state=Tk.NORMAL)
647 self.bFlag.config(state=Tk.NORMAL)
648 self.bUnflag.config(state=Tk.NORMAL)
649 self.bStat.config(state=Tk.NORMAL)
650 self.button = True
651 self.spec_show()
652
653 def disable_button(self):
654 ## disable buttons which don't work for plottp
655 if not self.button: return
656 self.bRegion.config(relief='raised')
657 self.bPanel.config(relief='raised')
658 self.bRegion.config(state=Tk.DISABLED)
659 self.bPanel.config(state=Tk.DISABLED)
660 self.bClear.config(state=Tk.DISABLED)
661 self.bFlag.config(state=Tk.DISABLED)
662 self.bUnflag.config(state=Tk.DISABLED)
663 self.bStat.config(state=Tk.DISABLED)
664 self.bNext.config(state=Tk.DISABLED)
665 self.bPrev.config(state=Tk.DISABLED)
666 self.button = False
667 self.mode = ''
668 self.notewin.close_widgets()
669 self.__disconnect_event()
670
671 def enable_next(self):
672 self.bNext.config(state=Tk.NORMAL)
673
674 def disable_next(self):
675 self.bNext.config(state=Tk.DISABLED)
676
677 def enable_prev(self):
678 self.bPrev.config(state=Tk.NORMAL)
679
680 def disable_prev(self):
681 self.bPrev.config(state=Tk.DISABLED)
682
683 # pause buttons for slow operations
684 def _pause_buttons(self,operation="end",msg=""):
685 buttons = ["bRegion","bPanel","bClear","bFlag","bUnflag","bStat",
686 "bNote","bQuit"]
687 if operation == "start":
688 state=Tk.DISABLED
689 else:
690 state=Tk.NORMAL
691 for btn in buttons:
692 getattr(self,btn).config(state=state)
693 self.figmgr.toolbar.set_message(msg)
694
695 def delete_bar(self):
696 self.__disconnect_event()
697 self.destroy()
698
699 def __disconnect_event(self):
700 self._p.register('button_press',None)
701 self._p.register('button_release',None)
702
703 def _draw_span(self,axes,x0,x1,**kwargs):
704 height = self._p.figure.bbox.height
705 y0 = height - axes.bbox.y0
706 y1 = height - axes.bbox.y1
707 return self._p.canvas._tkcanvas.create_rectangle(x0,y0,x1,y1,**kwargs)
708
709 def _remove_span(self,span):
710 self._p.canvas._tkcanvas.delete(span)
Note: See TracBrowser for help on using the repository browser.