Changeset 2173
- Timestamp:
- 05/18/11 15:03:16 (14 years ago)
- Location:
- trunk/python
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapplotter.py
r2168 r2173 47 47 self._plotter = self._newplotter(**kwargs) 48 48 # additional tool bar 49 self._plotter.figmgr.casabar=self._new casabar()49 self._plotter.figmgr.casabar=self._new_custombar() 50 50 51 51 self._panelling = None … … 88 88 return new_asaplot(self._visible,**kwargs) 89 89 90 def _new casabar(self):90 def _new_custombar(self): 91 91 backend=matplotlib.get_backend() 92 92 if not self._visible: … … 95 95 from asap.customgui_tkagg import CustomToolbarTkAgg 96 96 return CustomToolbarTkAgg(self) 97 #from asap.casatoolbar import CustomFlagToolbarTkAgg98 #return CustomFlagToolbarTkAgg(self)99 97 elif backend == "Qt4Agg": 100 98 from asap.customgui_qt4agg import CustomToolbarQT4Agg … … 128 126 del self._plotter.figmgr.casabar 129 127 self._plotter = self._newplotter() 130 self._plotter.figmgr.casabar=self._new casabar()128 self._plotter.figmgr.casabar=self._new_custombar() 131 129 if self.casabar_exists(): 132 130 self._plotter.figmgr.casabar.set_pagecounter(1) … … 1311 1309 del self._plotter.figmgr.casabar 1312 1310 self._plotter = self._newplotter() 1313 self._plotter.figmgr.casabar=self._new casabar()1311 self._plotter.figmgr.casabar=self._new_custombar() 1314 1312 self._plotter.hold() 1315 1313 self._plotter.clear() -
trunk/python/customgui_qt4agg.py
r2172 r2173 93 93 def spec_show(self): 94 94 if not self.figmgr.toolbar.mode == '' or not self.button: return 95 self.figmgr.toolbar.set_message( 'spec value: drag on a spec')95 self.figmgr.toolbar.set_message("spec value: drag on a spec") 96 96 if self.mode == 'spec': return 97 97 self.mode = 'spec' … … 111 111 self.spec_show() 112 112 return 113 self.figmgr.toolbar.set_message( 'statistics: select a region')113 self.figmgr.toolbar.set_message("statistics: click at start and end channels") 114 114 self.bStat.setChecked(True) 115 115 self.bStat.setToolTip("Back to spec value mode") … … 126 126 self.bNote.setChecked(not self.bNote.isChecked()) 127 127 return 128 self.figmgr.toolbar.set_message('text: select a position/text')129 128 if self.mode == 'note': 130 129 self.bNote.setChecked(False) … … 133 132 self.spec_show() 134 133 return 134 self.figmgr.toolbar.set_message("text: select a position/text") 135 135 self.bStat.setChecked(False) 136 136 self.bStat.setToolTip("calculate statistics") … … 202 202 203 203 def _remove_span(self,span): 204 # Nothing to do with remove. just refresh (call only for)204 # Nothing to do with remove. just refresh (call only once) 205 205 self.canvas.draw() 206 206 … … 530 530 ## Add CASA custom Flag toolbar ## 531 531 ########################################### 532 # class CustomFlagToolbarQT4Agg(CustomFlagToolbarCommon, qt.QtGui.QToolBar): 533 # def __init__(self,parent): 534 # from asap.asapplotter import asapplotter 535 # if not isinstance(parent,asapplotter): 536 # return False 537 # if not parent._plotter: 538 # return False 539 # self._p = parent._plotter 540 # self.figmgr = self._p.figmgr 541 # self.canvas = self.figmgr.canvas 542 # self.mode = '' 543 # self.button = True 544 # self.pagecount = None 545 # CustomFlagToolbarCommon.__init__(self,parent) 546 # self.notewin=NotationWindowQT4Agg(master=self.canvas) 547 # self._add_custom_toolbar() 548 549 # def _add_custom_toolbar(self): 550 # qt.QtGui.QToolBar.__init__(self,parent=self.figmgr.window) 551 # self.figmgr.window.addToolBar(qt.QtCore.Qt.BottomToolBarArea,self) 552 # # Tk.Frame.__init__(self,master=self.figmgr.window) 553 # self.bRegion = self._NewButton(master=self, 554 # text='region', 555 # command=self.select_region, 556 # balloon="select channel regions") 557 # self.bRegion.setCheckable(True) 532 class CustomFlagToolbarQT4Agg(CustomFlagToolbarCommon, qt.QtGui.QToolBar): 533 def __init__(self,parent): 534 from asap.asapplotter import asapplotter 535 if not isinstance(parent,asapplotter): 536 return False 537 if not parent._plotter: 538 return False 539 self._p = parent._plotter 540 self.figmgr = self._p.figmgr 541 self.canvas = self.figmgr.canvas 542 self.mode = '' 543 self.button = True 544 self.pagecount = None 545 CustomFlagToolbarCommon.__init__(self,parent) 546 self.notewin=NotationWindowQT4Agg(master=self.canvas) 547 self._add_custom_toolbar() 548 549 def _add_custom_toolbar(self): 550 qt.QtGui.QToolBar.__init__(self,parent=self.figmgr.window) 551 self.figmgr.window.addToolBar(qt.QtCore.Qt.BottomToolBarArea,self) 552 self.bRegion = self._NewButton(master=self, 553 text='region', 554 command=self.select_region, 555 balloon="select channel regions") 556 self.bRegion.setCheckable(True) 558 557 559 # self.bPanel = self._NewButton(master=self, 560 # text='panel', 561 # command=self.select_panel, 562 # balloon="select subplots") 563 # self.bPanel.setCheckable(True) 564 565 # self.bClear = self._NewButton(master=self, 566 # text='clear', 567 # command=self.cancel_select, 568 # balloon="clear selections") 569 570 # self.bFlag = self._NewButton(master=self, 571 # text='flag', 572 # command=self.flag, 573 # balloon="flag selections") 574 575 # self.bUnflag = self._NewButton(master=self, 576 # text='unflag', 577 # command=self.unflag, 578 # balloon="unflag selections") 579 580 # self.bStat = self._NewButton(master=self, 581 # text='statistics', 582 # command=self.stat_cal, 583 # balloon="print statistics of selections") 584 585 # self.bNote = self._NewButton(master=self, 586 # text='notation', 587 # command=self.modify_note, 588 # balloon="add note on plot") 589 # self.bNote.setCheckable(True) 590 591 # # page change oparations 592 # frPage = qt.QtGui.QWidget(parent=self,flags=qt.QtCore.Qt.Tool) 593 # loPage = qt.QtGui.QHBoxLayout(self) 594 # loPage.addStretch(1) 595 # self.lPagetitle = qt.QtGui.QLabel('Page:',parent=frPage) 596 # self.lPagetitle.setMargin(5) 597 # loPage.addWidget(self.lPagetitle) 598 # self.pagecount = qt.QtGui.QLabel(parent=frPage) 599 # self.pagecount.setStyleSheet("background-color: white") 600 # self.pagecount.setMargin(3) 601 # self.pagecount.setText(' 1') 602 # loPage.addWidget(self.pagecount) 603 # # frPage = Tk.Frame(master=self,borderwidth=2,relief=Tk.GROOVE) 604 # # frPage.pack(ipadx=2,padx=10,side=Tk.RIGHT) 605 # # self.lPagetitle = Tk.Label(master=frPage,text='Page:',padx=5) 606 # # #width=8,anchor=Tk.E,padx=5) 607 # # self.lPagetitle.pack(side=Tk.LEFT) 608 # # self.pagecount = Tk.StringVar(master=frPage) 609 # # self.lPagecount = Tk.Label(master=frPage, 610 # # textvariable=self.pagecount, 611 # # padx=5,bg='white') 612 # # self.lPagecount.pack(side=Tk.LEFT,padx=3) 613 614 # self.bNext = self._NewButton(master=frPage, 615 # text='+', 616 # command=self.next_page, 617 # addit=False, 618 # balloon="plot next page") 619 # loPage.addWidget(self.bNext) 620 # self.bPrev = self._NewButton(master=frPage, 621 # text='-', 622 # command=self.prev_page, 623 # addit=False, 624 # balloon="plot previous page") 625 # loPage.addWidget(self.bPrev) 626 # frPage.setLayout(loPage) 627 # self.addWidget(frPage) 628 629 # # self.bNext=self._NewButton(master=frPage, 630 # # text=' + ', 631 # # #imagename="hand.ppm", 632 # # command=self.next_page) 633 # # self.bPrev=self._NewButton(master=frPage, 634 # # text=' - ', 635 # # command=self.prev_page) 636 637 # self.bQuit = self._NewButton(master=self, 638 # text='Quit', 639 # #imagename="stock_close.ppm", 640 # command=self.quit, 641 # balloon="Close window") 642 643 # # if os.uname()[0] != 'Darwin': 644 # # self.bPrev.config(padx=5) 645 # # self.bNext.config(padx=5) 646 647 # self.pagecount.setText(' '*4) 648 # # self.pack(side=Tk.BOTTOM,fill=Tk.BOTH) 649 # # self.pagecount.set(' '*4) 650 651 # self.disable_button() 652 # return 653 654 # def _NewButton(self, master, text, command, balloon=None,addit=True,imagename=None): 655 # # def _NewButton(self, master, text, command, side=Tk.LEFT,imagename=None): 656 # img = None 657 # if imagename: 658 # imagename = os.path.join(matplotlib.rcParams['datapath'], 'images', imagename) 659 # # img = Tk.PhotoImage(master=master, file=imagename) 660 661 # b = qt.QtGui.QPushButton(text,parent=master) 662 # if balloon: b.setToolTip(balloon) 663 # if addit: master.addWidget(b) 664 # master.connect(b,qt.QtCore.SIGNAL('clicked()'),command) 665 # # if os.uname()[0] == 'Darwin': 666 # # b = Tk.Button(master=master, text=text, image=img, 667 # # command=command) 668 # # if img: b.image = img 669 # # else: 670 # # b = Tk.Button(master=master, text=text, image=img, padx=2, pady=2, 671 # # command=command) 672 # # if img: b.image = img 673 # # b.pack(side=side) 674 # return b 675 676 # def show_pagenum(self,pagenum,formatstr): 677 # self.pagecount.setText(formatstr % (pagenum)) 678 # # self.pagecount.set(formatstr % (pagenum)) 679 680 # def spec_show(self): 681 # if not self.figmgr.toolbar.mode == '' or not self.button: return 682 # self.figmgr.toolbar.set_message('spec value: drag on a spec') 683 # if self.mode == 'spec': return 684 # self.mode = 'spec' 685 # self.notewin.close_widgets() 686 # self.__disconnect_event() 687 # self._p.register('button_press',self._select_spectrum) 688 689 # def modify_note(self): 690 # if not self.figmgr.toolbar.mode == '': 691 # # Get back button status BEFORE clicked 692 # self.bNote.setChecked(not self.bNote.isChecked()) 693 # return 694 # self.figmgr.toolbar.set_message('text: select a position/text') 695 # if self.mode == 'note': 696 # self.bNote.setChecked(False) 697 # self.bNote.setToolTip("add note on plot") 698 # # self.bNote.config(relief='raised') 699 # self.mode = 'none' 700 # self.spec_show() 701 # return 702 # self.bNote.setChecked(True) 703 # self.bNote.setToolTip("Back to spec value mode") 704 # self.bRegion.setChecked(False) 705 # self.bRegion.setToolTip("select channel regions") 706 # self.bPanel.setChecked(False) 707 # self.bPanel.setToolTip("select subplots") 708 # # self.bNote.config(relief='sunken') 709 # # self.bRegion.config(relief='raised') 710 # # self.bPanel.config(relief='raised') 711 # self.mode = 'note' 712 # self.__disconnect_event() 713 # self._p.register('button_press',self._mod_note) 714 715 # def select_region(self): 716 # if not self.figmgr.toolbar.mode == '' or not self.button: 717 # # Get back button status BEFORE clicked 718 # self.bRegion.setChecked(not self.bRegion.isChecked()) 719 # self.figmgr.toolbar.set_message('select regions: click at start and end channels') 720 # if self.mode == 'region': 721 # self.bRegion.setChecked(False) 722 # self.bRegion.setToolTip("select channel regions") 723 # # self.bRegion.config(relief='raised') 724 # self.mode = 'none' 725 # self.spec_show() 726 # return 727 # self.bNote.setChecked(False) 728 # self.bNote.setToolTip("add note on plot") 729 # self.bRegion.setChecked(True) 730 # self.bRegion.setToolTip("Back to spec value mode") 731 # self.bPanel.setChecked(False) 732 # self.bPanel.setToolTip("select subplots") 733 # # self.bNote.config(relief='raised') 734 # # self.bRegion.config(relief='sunken') 735 # # self.bPanel.config(relief='raised') 736 # self.mode = 'region' 737 # self.notewin.close_widgets() 738 # self.__disconnect_event() 739 # self._p.register('button_press',self._add_region) 740 741 # def select_panel(self): 742 # if not self.figmgr.toolbar.mode == '' or not self.button: 743 # # Get back button status BEFORE clicked 744 # self.bPanel.setChecked(not self.bPanel.isChecked()) 745 # return 746 # self.figmgr.toolbar.set_message('select spectra: click on subplots') 747 # if self.mode == 'panel': 748 # self.bPanel.setChecked(False) 749 # self.bPanel.setToolTip("select subplots") 750 # # self.bPanel.config(relief='raised') 751 # self.mode = 'none' 752 # self.spec_show() 753 # return 754 # self.bNote.setChecked(False) 755 # self.bNote.setToolTip("add note on plot") 756 # self.bRegion.setChecked(False) 757 # self.bRegion.setToolTip("select channel regions") 758 # self.bPanel.setChecked(True) 759 # self.bPanel.setToolTip("Back to spec value mode") 760 # # self.bNote.config(relief='raised') 761 # # self.bRegion.config(relief='raised') 762 # # self.bPanel.config(relief='sunken') 763 # self.mode = 'panel' 764 # self.notewin.close_widgets() 765 # self.__disconnect_event() 766 # self._p.register('button_press',self._add_panel) 767 768 # def quit(self): 769 # self.__disconnect_event() 770 # self.disable_button() 771 # self._p.unmap() 772 # # self.figmgr.window.wm_withdraw() 773 774 # def enable_button(self): 775 # if self.button: return 776 # self.bRegion.setEnabled(True) 777 # self.bPanel.setEnabled(True) 778 # self.bClear.setEnabled(True) 779 # self.bFlag.setEnabled(True) 780 # self.bUnflag.setEnabled(True) 781 # self.bStat.setEnabled(True) 782 # # self.bRegion.config(state=Tk.NORMAL) 783 # # self.bPanel.config(state=Tk.NORMAL) 784 # # self.bClear.config(state=Tk.NORMAL) 785 # # self.bFlag.config(state=Tk.NORMAL) 786 # # self.bUnflag.config(state=Tk.NORMAL) 787 # # self.bStat.config(state=Tk.NORMAL) 788 # self.button = True 789 # self.spec_show() 790 791 # def disable_button(self): 792 # ## disable buttons which don't work for plottp 793 # if not self.button: return 794 # self.bRegion.setChecked(False) 795 # self.bRegion.setToolTip("select channel regions") 796 # self.bPanel.setChecked(False) 797 # self.bPanel.setToolTip("select subplots") 798 # # self.bRegion.config(relief='raised') 799 # # self.bPanel.config(relief='raised') 800 # self.bRegion.setDisabled(True) 801 # self.bPanel.setDisabled(True) 802 # self.bClear.setDisabled(True) 803 # self.bFlag.setDisabled(True) 804 # self.bUnflag.setDisabled(True) 805 # self.bStat.setDisabled(True) 806 # self.bNext.setDisabled(True) 807 # self.bPrev.setDisabled(True) 808 # # self.bRegion.config(state=Tk.DISABLED) 809 # # self.bPanel.config(state=Tk.DISABLED) 810 # # self.bClear.config(state=Tk.DISABLED) 811 # # self.bFlag.config(state=Tk.DISABLED) 812 # # self.bUnflag.config(state=Tk.DISABLED) 813 # # self.bStat.config(state=Tk.DISABLED) 814 # # self.bNext.config(state=Tk.DISABLED) 815 # # self.bPrev.config(state=Tk.DISABLED) 816 # self.button = False 817 # self.mode = '' 818 # self.notewin.close_widgets() 819 # self.__disconnect_event() 820 821 # def enable_next(self): 822 # self.bNext.setEnabled(True) 823 # # self.bNext.config(state=Tk.NORMAL) 824 825 # def disable_next(self): 826 # self.bNext.setDisabled(True) 827 # # self.bNext.config(state=Tk.DISABLED) 828 829 # def enable_prev(self): 830 # self.bPrev.setEnabled(True) 831 # # self.bPrev.config(state=Tk.NORMAL) 832 833 # def disable_prev(self): 834 # self.bPrev.setDisabled(True) 835 # # self.bPrev.config(state=Tk.DISABLED) 836 837 # # pause buttons for slow operations 838 # def _pause_buttons(self,operation="end",msg=""): 839 # buttons = ["bRegion","bPanel","bClear","bFlag","bUnflag","bStat", 840 # "bNote","bQuit"] 841 # if operation == "start": 842 # enable = False 843 # # state=Tk.DISABLED 844 # else: 845 # enable = True 846 # # state=Tk.NORMAL 847 # for btn in buttons: 848 # getattr(self,btn).setEnabled(enable) 849 # # getattr(self,btn).config(state=state) 850 # self.figmgr.toolbar.set_message(msg) 851 852 # def delete_bar(self): 853 # self.__disconnect_event() 854 # self.destroy() 855 856 # def __disconnect_event(self): 857 # self._p.register('button_press',None) 858 # self._p.register('button_release',None) 859 860 # def _draw_span(self,axes,x0,x1,**kwargs): 861 # height = self._p.figure.bbox.height 862 # y1 = height - axes.bbox.y1 863 # h = axes.bbox.height 864 # w = abs(x1 - x0) 865 # rect = [ int(val) for val in min(x0,x1), y1, w, h ] 866 # self._p.canvas.drawRectangle( rect ) 867 # # nothing is returned by drawRectangle 868 # return None 869 # # return self._p.canvas._tkcanvas.create_rectangle(x0,y0,x1,y1,**kwargs) 870 871 # def _remove_span(self,span): 872 # # Nothing to do with remove 873 # pass 874 # # self._p.canvas._tkcanvas.delete(span) 558 self.bPanel = self._NewButton(master=self, 559 text='panel', 560 command=self.select_panel, 561 balloon="select a whole spectrum") 562 self.bPanel.setCheckable(True) 563 564 self.bClear = self._NewButton(master=self, 565 text='clear', 566 command=self.cancel_select, 567 balloon="clear selections") 568 569 self.bFlag = self._NewButton(master=self, 570 text='flag', 571 command=self.flag, 572 balloon="flag selections") 573 574 self.bUnflag = self._NewButton(master=self, 575 text='unflag', 576 command=self.unflag, 577 balloon="unflag selections") 578 579 self.bStat = self._NewButton(master=self, 580 text='statistics', 581 command=self.stat_cal, 582 balloon="print statistics of selections") 583 584 self.bNote = self._NewButton(master=self, 585 text='notation', 586 command=self.modify_note, 587 balloon="add note on plot") 588 self.bNote.setCheckable(True) 589 590 # page change oparations 591 frPage = qt.QtGui.QWidget(parent=self,flags=qt.QtCore.Qt.Tool) 592 loPage = qt.QtGui.QHBoxLayout(self) 593 loPage.addStretch(1) 594 self.lPagetitle = qt.QtGui.QLabel('Page:',parent=frPage) 595 self.lPagetitle.setMargin(5) 596 loPage.addWidget(self.lPagetitle) 597 self.pagecount = qt.QtGui.QLabel(parent=frPage) 598 self.pagecount.setStyleSheet("background-color: white") 599 self.pagecount.setMargin(3) 600 self.pagecount.setText(' 1') 601 loPage.addWidget(self.pagecount) 602 603 self.bNext = self._NewButton(master=frPage, 604 text='+', 605 #imagename="hand.ppm", 606 command=self.next_page, 607 addit=False, 608 balloon="plot next page") 609 loPage.addWidget(self.bNext) 610 self.bPrev = self._NewButton(master=frPage, 611 text='-', 612 command=self.prev_page, 613 addit=False, 614 balloon="plot previous page") 615 loPage.addWidget(self.bPrev) 616 frPage.setLayout(loPage) 617 self.addWidget(frPage) 618 619 self.bQuit = self._NewButton(master=self, 620 text='Quit', 621 #imagename="stock_close.ppm", 622 command=self.quit, 623 balloon="Close window") 624 625 self.pagecount.setText(' '*4) 626 self.disable_button() 627 return 628 629 def _NewButton(self, master, text, command, balloon=None,addit=True,imagename=None): 630 img = None 631 if imagename: 632 imagename = os.path.join(matplotlib.rcParams['datapath'], 'images', imagename) 633 # img = Tk.PhotoImage(master=master, file=imagename) 634 635 b = qt.QtGui.QPushButton(text,parent=master) 636 if balloon: b.setToolTip(balloon) 637 if addit: master.addWidget(b) 638 master.connect(b,qt.QtCore.SIGNAL('clicked()'),command) 639 # if img: b.image = img 640 return b 641 642 def show_pagenum(self,pagenum,formatstr): 643 self.pagecount.setText(formatstr % (pagenum)) 644 645 def spec_show(self): 646 if not self.figmgr.toolbar.mode == '' or not self.button: return 647 self.figmgr.toolbar.set_message('spec value: drag on a spec') 648 if self.mode == 'spec': return 649 self.mode = 'spec' 650 self.notewin.close_widgets() 651 self.__disconnect_event() 652 self._p.register('button_press',self._select_spectrum) 653 654 def modify_note(self): 655 if not self.figmgr.toolbar.mode == '': 656 # Get back button status BEFORE clicked 657 self.bNote.setChecked(not self.bNote.isChecked()) 658 return 659 if self.mode == 'note': 660 self.bNote.setChecked(False) 661 self.bNote.setToolTip("add note on plot") 662 self.mode = 'none' 663 self.spec_show() 664 return 665 self.figmgr.toolbar.set_message('text: select a position/text') 666 self.bNote.setChecked(True) 667 self.bNote.setToolTip("Back to spec value mode") 668 self.bRegion.setChecked(False) 669 self.bRegion.setToolTip("select channel regions") 670 self.bPanel.setChecked(False) 671 self.bPanel.setToolTip("select a whole spectrum") 672 self.mode = 'note' 673 self.__disconnect_event() 674 self._p.register('button_press',self._mod_note) 675 676 def select_region(self): 677 if not self.figmgr.toolbar.mode == '' or not self.button: 678 # Get back button status BEFORE clicked 679 self.bRegion.setChecked(not self.bRegion.isChecked()) 680 if self.mode == 'region': 681 self.bRegion.setChecked(False) 682 self.bRegion.setToolTip("select channel regions") 683 self.mode = 'none' 684 self.spec_show() 685 return 686 self.figmgr.toolbar.set_message('select regions: click at start and end channels') 687 self.bNote.setChecked(False) 688 self.bNote.setToolTip("add note on plot") 689 self.bRegion.setChecked(True) 690 self.bRegion.setToolTip("Back to spec value mode") 691 self.bPanel.setChecked(False) 692 self.bPanel.setToolTip("select a whole spectrum") 693 self.mode = 'region' 694 self.notewin.close_widgets() 695 self.__disconnect_event() 696 self._p.register('button_press',self._add_region) 697 698 def select_panel(self): 699 if not self.figmgr.toolbar.mode == '' or not self.button: 700 # Get back button status BEFORE clicked 701 self.bPanel.setChecked(not self.bPanel.isChecked()) 702 return 703 if self.mode == 'panel': 704 self.bPanel.setChecked(False) 705 self.bPanel.setToolTip("select subplots") 706 self.mode = 'none' 707 self.spec_show() 708 return 709 self.figmgr.toolbar.set_message('select spectra: click on subplots') 710 self.bNote.setChecked(False) 711 self.bNote.setToolTip("add note on plot") 712 self.bRegion.setChecked(False) 713 self.bRegion.setToolTip("select channel regions") 714 self.bPanel.setChecked(True) 715 self.bPanel.setToolTip("Back to spec value mode") 716 self.mode = 'panel' 717 self.notewin.close_widgets() 718 self.__disconnect_event() 719 self._p.register('button_press',self._add_panel) 720 721 def quit(self): 722 self.__disconnect_event() 723 self.disable_button() 724 self._p.unmap() 725 726 def enable_button(self): 727 if self.button: return 728 self.bRegion.setEnabled(True) 729 self.bPanel.setEnabled(True) 730 self.bClear.setEnabled(True) 731 self.bFlag.setEnabled(True) 732 self.bUnflag.setEnabled(True) 733 self.bStat.setEnabled(True) 734 self.button = True 735 self.spec_show() 736 737 def disable_button(self): 738 ## disable buttons which don't work for plottp 739 if not self.button: return 740 self.bRegion.setChecked(False) 741 self.bRegion.setToolTip("select channel regions") 742 self.bPanel.setChecked(False) 743 self.bPanel.setToolTip("select subplots") 744 745 self.bRegion.setDisabled(True) 746 self.bPanel.setDisabled(True) 747 self.bClear.setDisabled(True) 748 self.bFlag.setDisabled(True) 749 self.bUnflag.setDisabled(True) 750 self.bStat.setDisabled(True) 751 self.bNext.setDisabled(True) 752 self.bPrev.setDisabled(True) 753 self.button = False 754 self.mode = '' 755 self.notewin.close_widgets() 756 self.__disconnect_event() 757 758 def enable_next(self): 759 self.bNext.setEnabled(True) 760 761 def disable_next(self): 762 self.bNext.setDisabled(True) 763 764 def enable_prev(self): 765 self.bPrev.setEnabled(True) 766 767 def disable_prev(self): 768 self.bPrev.setDisabled(True) 769 770 # pause buttons for slow operations 771 def _pause_buttons(self,operation="end",msg=""): 772 buttons = ["bRegion","bPanel","bClear","bFlag","bUnflag","bStat", 773 "bNote","bQuit"] 774 if operation == "start": 775 enable = False 776 else: 777 enable = True 778 for btn in buttons: 779 getattr(self,btn).setEnabled(enable) 780 self.figmgr.toolbar.set_message(msg) 781 782 def delete_bar(self): 783 self.__disconnect_event() 784 self.destroy() 785 786 def __disconnect_event(self): 787 self._p.register('button_press',None) 788 self._p.register('button_release',None) 789 790 def _draw_span(self,axes,x0,x1,**kwargs): 791 height = self._p.figure.bbox.height 792 y1 = height - axes.bbox.y1 793 h = axes.bbox.height 794 w = abs(x1 - x0) 795 rect = [ int(val) for val in min(x0,x1), y1, w, h ] 796 self._p.canvas.drawRectangle( rect ) 797 # nothing is returned by drawRectangle 798 return None 799 800 def _remove_span(self,span): 801 # Nothing to do with remove. 802 pass -
trunk/python/flagplotter.py
r2155 r2173 27 27 self._scan = None 28 28 asapplotter.__init__(self,visible=visible, **kwargs) 29 self._plotter. window.title('Flag Plotter')29 self._plotter._set_window_title('Flag Plotter') 30 30 self._panelling = 'r' 31 31 self.set_stacking('scan') 32 32 self._ismodified = False 33 33 34 def _new casabar(self):34 def _new_custombar(self): 35 35 backend = matplotlib.get_backend() 36 if self._visible and backend == "TkAgg": 37 #from asap.casatoolbar import CustomToolbarTkAgg 38 #return CustomToolbarTkAgg(self) 36 # Flag plotter relys on supported GUI backends 37 if not self._visible: 38 asaplog.push("GUI backend is not available") 39 asaplog.post("ERROR") 40 elif backend == "TkAgg": 39 41 from asap.customgui_tkagg import CustomFlagToolbarTkAgg 40 42 return CustomFlagToolbarTkAgg(self) 41 return None 43 elif backend == "Qt4Agg": 44 from asap.customgui_qt4agg import CustomFlagToolbarQT4Agg 45 return CustomFlagToolbarQT4Agg(self) 46 else: 47 asaplog.push("Unsupported backend for interactive flagging. Use either TkAgg or PyQt4Agg") 48 asaplog.post("ERROR") 42 49 43 50 @asaplog_post_dec
Note:
See TracChangeset
for help on using the changeset viewer.