Changeset 1983


Ignore:
Timestamp:
01/31/11 12:32:32 (13 years ago)
Author:
Kana Sugimoto
Message:

New Development: No

JIRA Issue: Yes (CAS-1822/ASAP-204)

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: Put page counter and page change buttons at the right side of the tool bar

Test Programs: plot something with ASAP plotter

Put in Release Notes: No

Module(s): asapplotter & sdplot

Description:

  • Put page counter and page change buttons at the right side of the tool bar.
  • moved backend independent functions to the class, CustomToolbarCommon?.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/casatoolbar.py

    r1982 r1983  
    168168        return False
    169169
    170     def _new_page(self,next=True):
     170    ### Page chages
     171    ### go to the previous page
     172    def prev_page(self):
     173        self.figmgr.toolbar.set_message('plotting the previous page')
     174        self._new_page(goback=True)
     175
     176    ### go to the next page
     177    def next_page(self):
     178        self.figmgr.toolbar.set_message('plotting the next page')
     179        self._new_page(goback=False)
     180
     181    ### actual plotting of the new page
     182    def _new_page(self,goback=False):
    171183        if self.plotter._startrow <= 0:
    172184            msg = "The page counter is reset due to chages of plot settings. "
     
    174186            asaplog.push(msg)
    175187            asaplog.post('WARN')
    176             next = True
     188            goback = False
    177189           
    178190        self.plotter._plotter.hold()
    179         if not next:
     191        if goback:
    180192            self._set_prevpage_counter()
    181193        #self.plotter._plotter.clear()
    182194        self.plotter._plot(self.plotter._data)
    183         self.set_pagenum(self._get_pagenum())
     195        self.set_pagecounter(self._get_pagenum())
    184196        self.plotter._plotter.release()
    185197        self.plotter._plotter.tidy()
    186198        self.plotter._plotter.show(hardrefresh=False)
    187199
     200    ### calculate the panel ID and start row to plot the previous page
    188201    def _set_prevpage_counter(self):
    189202        # set row and panel counters to those of the 1st panel of previous page
     
    212225        del lastpanel,currpnum,prevpnum,start_ipanel
    213226
     227    ### refresh the page counter
     228    ### refresh the page counter
     229    def set_pagecounter(self,page):
     230        nwidth = int(numpy.ceil(numpy.log10(max(page,1))))+1
     231        nwidth = max(nwidth,4)
     232        formatstr = '%'+str(nwidth)+'d'
     233        self.show_pagenum(page,formatstr)
     234
     235    def show_pagenum(self,pagenum,formatstr):
     236        # passed to backend dependent class
     237        pass       
     238
    214239    def _get_pagenum(self):
    215240        maxpanel = 16
     
    242267        self.mode = ''
    243268        self.button = True
    244         self.pagenum = None
     269        self.pagecount = None
     270        CustomToolbarCommon.__init__(self,parent)
     271        self.notewin=NotationWindowTkAgg(master=self.canvas)
    245272        self._add_custom_toolbar()
    246         self.notewin=NotationWindowTkAgg(master=self.canvas)
    247         CustomToolbarCommon.__init__(self,parent)
    248273
    249274    def _add_custom_toolbar(self):
     
    259284                                   text='statistics',
    260285                                   command=self.stat_cal)
    261         # page change oparations
    262         self.lPagetitle = Tk.Label(master=self,text='   Page:',padx=5)
    263         self.lPagetitle.pack(side=Tk.LEFT)
    264         self.pagenum = Tk.StringVar(master=self)
    265         self.lPage = Tk.Label(master=self,textvariable=self.pagenum,
    266                               padx=5,bg='white')
    267         self.lPage.pack(side=Tk.LEFT,padx=3)
    268        
    269         self.bNext=self._NewButton(master=self,
    270                                    text=' + ',
    271                                    command=self.next_page)
    272         self.bPrev=self._NewButton(master=self,
    273                                    text=' - ',
    274                                    command=self.prev_page)
    275 
    276         if os.uname()[0] != 'Darwin':
    277             self.bPrev.config(padx=5)
    278             self.bNext.config(padx=5)
    279286        self.bQuit=self._NewButton(master=self,
    280287                                   text='Quit',
    281288                                   command=self.quit,
    282289                                   side=Tk.RIGHT)
     290
     291        # page change oparations
     292        frPage = Tk.Frame(master=self,borderwidth=2,relief=Tk.GROOVE)
     293        frPage.pack(ipadx=2,padx=10,side=Tk.RIGHT)
     294        self.lPagetitle = Tk.Label(master=frPage,text='Page:',padx=5)
     295        self.lPagetitle.pack(side=Tk.LEFT)
     296        self.pagecount = Tk.StringVar(master=frPage)
     297        self.lPagecount = Tk.Label(master=frPage,
     298                                   textvariable=self.pagecount,
     299                                   padx=5,bg='white')
     300        self.lPagecount.pack(side=Tk.LEFT,padx=3)
     301       
     302        self.bNext=self._NewButton(master=frPage,
     303                                   text=' + ',
     304                                   command=self.next_page)
     305        self.bPrev=self._NewButton(master=frPage,
     306                                   text=' - ',
     307                                   command=self.prev_page)
     308
     309        if os.uname()[0] != 'Darwin':
     310            self.bPrev.config(padx=5)
     311            self.bNext.config(padx=5)
     312
    283313        self.pack(side=Tk.BOTTOM,fill=Tk.BOTH)
    284         self.pagenum.set('    ')
     314        self.pagecount.set(' '*4)
    285315
    286316        self.disable_button()
     
    295325        b.pack(side=side)
    296326        return b
     327
     328    def show_pagenum(self,pagenum,formatstr):
     329        self.pagecount.set(formatstr % (pagenum))
    297330
    298331    def spec_show(self):
     
    339372        self._p.register('button_press',self._mod_note)
    340373
    341     def prev_page(self):
    342         self.figmgr.toolbar.set_message('plotting the previous page')
    343         self._new_page(next=False)
    344 
    345     def next_page(self):
    346         self.figmgr.toolbar.set_message('plotting the next page')
    347         self._new_page(next=True)
    348 
    349     def set_pagenum(self,page):
    350         nwidth = int(numpy.ceil(numpy.log10(max(page,1))))+1
    351         nwidth = max(nwidth,4)
    352         formatstr = '%'+str(nwidth)+'d'
    353         self.pagenum.set(formatstr % (page))
    354 
    355374    def quit(self):
    356375        self.__disconnect_event()
Note: See TracChangeset for help on using the changeset viewer.