source: trunk/python/customgui_tkagg.py@ 2608

Last change on this file since 2608 was 2603, checked in by Kana Sugimoto, 12 years ago

New Development: No

JIRA Issue: No (bug fixes and a minor improvement)

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs: interactive test needed.

Put in Release Notes: No

Module(s): asapplotter, flagplotter, and sdplot (CASA)

Description:

Fixed bugs in asapplotter and flagplotter which prevented users from exiting
from notation mode, when the other buttons in the additional toolbar is not active.
Consintently use 'self._data' in asapplotter.plotgrid() instead of 'scan'.


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