(self, data=None)
return
Plot options dialog
Plot options dialog
Plot options dialog
def plotSetup(self, data=None):
        """Plot options dialog"""

        if data != None:
            self.setData(data)
        self.plotprefswin=Toplevel()
        self.plotprefswin.geometry('+300+450')
        self.plotprefswin.title('Plot Preferences')
        row=0
        frame1=LabelFrame(self.plotprefswin, text='General')
        frame1.grid(row=row,column=0,sticky='news',padx=2,pady=2)
        def close_prefsdialog():
            self.plotprefswin.destroy()

        def choosecolor(x):
            """Choose color for data series"""
            d=x[0]
            c=x[1]
            #print 'passed', 'd',d, 'c',c
            import tkColorChooser
            colour,colour_string = tkColorChooser.askcolor(c,parent=self.plotprefswin)
            if colour != None:
                self.datacolors[d] = str(colour_string)
                cbuttons[d].configure(bg=colour_string)

            return

        Checkbutton(frame1, text="Grid lines", variable=self.pltgrid,
                    onvalue=1, offvalue=0).grid(row=0,column=0, columnspan=2, sticky='news')
        Checkbutton(frame1, text="Legend", variable=self.pltlegend,
                    onvalue=1, offvalue=0).grid(row=1,column=0, columnspan=2, sticky='news')

        Label(frame1,text='Symbol:').grid(row=2,column=0,padx=2,pady=2)
        symbolbutton = Menubutton(frame1,textvariable=self.pltsymbol,
					                relief=GROOVE, width=16, bg='lightblue')
        symbol_menu = Menu(symbolbutton, tearoff=0)
        symbolbutton['menu'] = symbol_menu
        for text in self.shapes:
            symbol_menu.add_radiobutton(label=text,
                                            variable=self.pltsymbol,
                                            value=text,
                                            indicatoron=1)
        symbolbutton.grid(row=2,column=1, sticky='news',padx=2,pady=2)
        row=row+1

        Label(frame1,text='Legend pos:').grid(row=3,column=0,padx=2,pady=2)
        legendposbutton = Menubutton(frame1,textvariable=self.legendlocvar,
					                relief=GROOVE, width=16, bg='lightblue')
        legendpos_menu = Menu(legendposbutton, tearoff=0)
        legendposbutton['menu'] = legendpos_menu
        i=0
        for p in self.legend_positions:
            legendpos_menu.add_radiobutton(label=p,
                                        variable=self.legendlocvar,
                                        value=p,
                                        indicatoron=1)
            i+=1
        legendposbutton.grid(row=3,column=1, sticky='news',padx=2,pady=2)

        Label(frame1,text='Font:').grid(row=4,column=0,padx=2,pady=2)
        fontbutton = Menubutton(frame1,textvariable=self.fontvar,
					                relief=GROOVE, width=16, bg='lightblue')
        font_menu = Menu(fontbutton, tearoff=0)
        fontbutton['menu'] = font_menu
        for f in self.fonts:
            font_menu.add_radiobutton(label=f,
                                            variable=self.fontvar,
                                            value=f,
                                            indicatoron=1)
        fontbutton.grid(row=4,column=1, sticky='news',padx=2,pady=2)
        row=row+1
        Label(frame1,text='Font size:').grid(row=5,column=0,padx=2,pady=2)
        Scale(frame1,from_=8,to=26,resolution=0.5,orient='horizontal',
                            relief=GROOVE,variable=self.fontsizevar).grid(row=5,column=1,padx=2,pady=2)

        Label(frame1,text='linewidth:').grid(row=6,column=0,padx=2,pady=2)
        Scale(frame1,from_=1,to=10,resolution=0.5,orient='horizontal',
                            relief=GROOVE,variable=self.linewidthvar).grid(row=6,column=1,padx=2,pady=2)
        row=0
        scalesframe = LabelFrame(self.plotprefswin, text="Axes Scales")
        scales={0:'norm',1:'log'}
        for i in range(0,2):
            Radiobutton(scalesframe,text='x-'+scales[i],variable=self.xscalevar,
                            value=i).grid(row=0,column=i,pady=2)
            Radiobutton(scalesframe,text='y-'+scales[i],variable=self.yscalevar,
                            value=i).grid(row=1,column=i,pady=2)
        scalesframe.grid(row=row,column=1,sticky='news',padx=2,pady=2)

        row=row+1
        frame=LabelFrame(self.plotprefswin, text='Graph type')
        frame.grid(row=row,column=0,columnspan=2,sticky='news',padx=2,pady=2)
        for i in range(len(self.graphtypes)):
            Radiobutton(frame,text=self.graphtypes[i],variable=self.graphtypevar,
                            value=self.graphtypes[i]).grid(row=0,column=i,pady=2)

        row=row+1
        labelsframe = LabelFrame(self.plotprefswin,text='Labels')
        labelsframe.grid(row=row,column=0,columnspan=2,sticky='news',padx=2,pady=2)
        Label(labelsframe,text='Title:').grid(row=0,column=0,padx=2,pady=2)
        Entry(labelsframe,textvariable=self.plottitlevar,bg='white',relief=GROOVE).grid(row=0,column=1,padx=2,pady=2)
        Label(labelsframe,text='X-axis label:').grid(row=1,column=0,padx=2,pady=2)
        Entry(labelsframe,textvariable=self.plotxlabelvar,bg='white',relief=GROOVE).grid(row=1,column=1,padx=2,pady=2)
        Label(labelsframe,text='Y-axis label:').grid(row=2,column=0,padx=2,pady=2)
        Entry(labelsframe,textvariable=self.plotylabelvar,bg='white',relief=GROOVE).grid(row=2,column=1,padx=2,pady=2)

        if self.currdata != None:
            #print self.dataseriesvars
            row=row+1
            seriesframe = LabelFrame(self.plotprefswin, text="Data Series Labels")
            seriesframe.grid(row=row,column=0,columnspan=2,sticky='news',padx=2,pady=2)
            #self.dataseriesvars=[]
            if len(self.dataseriesvars) == 0:
                self.setDataSeries(range(len(self.currdata)))
            r=1
            sr=1
            cl=0
            for s in self.dataseriesvars:
                Label(seriesframe,text='Series '+str(r)).grid(row=r,column=cl,padx=2,pady=2)
                Entry(seriesframe,textvariable=s,bg='white',
                                          relief=GROOVE).grid(row=r,column=cl+1,padx=2,pady=2)
                r+=1
                if r > 8:
                    r=1
                    cl+=2
            row=row+1
            cbuttons = {}
            frame = LabelFrame(self.plotprefswin, text="Dataset Colors")
            r=1
            cl=0
            sr=1
            ci=0
            for d in range(len(self.dataseriesvars)):
                if d >= len(self.datacolors):
                    self.datacolors.append(self.colors[ci])
                    ci+=1
                c = self.datacolors[d]
                action = lambda x =(d,c): choosecolor(x)
                cbuttons[d]=Button(frame,text='Series '+str(sr),bg=c,command=action)
                cbuttons[d].grid(row=r,column=cl,sticky='news',padx=2,pady=2)
                r+=1
                sr+=1
                if r > 8:
                    r=1
                    cl+=1
            frame.grid(row=row,column=0,columnspan=2,sticky='news',padx=2,pady=2)

        row=row+1
        frame=Frame(self.plotprefswin)
        frame.grid(row=row,column=0,columnspan=2,sticky='news',padx=2,pady=2)
        replotb = Button(frame, text="Replot",
                command=lambda:self.plotCurrent(graphtype=self.graphtype,guiopts=True),
                relief=GROOVE, bg='#99ccff')
        replotb.pack(side=LEFT,fill=X,padx=2,pady=2)
        b = Button(frame, text="Apply", command=self.applyOptions, relief=GROOVE, bg='#99ccff')
        b.pack(side=LEFT,fill=X,padx=2,pady=2)
        b = Button(frame, text="Save", command=self.saveCurrent, relief=GROOVE, bg='#99ccff')
        b.pack(side=LEFT,fill=X,padx=2,pady=2)
        c=Button(frame,text='Close', command=close_prefsdialog, relief=GROOVE, bg='#99ccff')
        c.pack(side=LEFT,fill=X,padx=2,pady=2)
        if self.currdata == None:
            replotb.configure(state=DISABLED)

        self.plotprefswin.focus_set()
        self.plotprefswin.grab_set()

        return
def plotSetup ( self , data = None ) : if data != None : self . setData ( data ) self . plotprefswin = Toplevel ( ) self . plotprefswin . geometry ( '+300+450' ) self . plotprefswin . title ( 'Plot Preferences' ) row = 0 frame1 = LabelFrame ( self . plotprefswin , text = 'General' ) frame1 . grid ( row = row , column = 0 , sticky = 'news' , padx = 2 , pady = 2 ) def close_prefsdialog ( ) : self . plotprefswin . destroy ( ) def choosecolor ( x ) : """Choose color for data series""" d = x [ 0 ] c = x [ 1 ] #print 'passed', 'd',d, 'c',c import tkColorChooser colour , colour_string = tkColorChooser . askcolor ( c , parent = self . plotprefswin ) if colour != None : self . datacolors [ d ] = str ( colour_string ) cbuttons [ d ] . configure ( bg = colour_string ) return Checkbutton ( frame1 , text = "Grid lines" , variable = self . pltgrid , onvalue = 1 , offvalue = 0 ) . grid ( row = 0 , column = 0 , columnspan = 2 , sticky = 'news' ) Checkbutton ( frame1 , text = "Legend" , variable = self . pltlegend , onvalue = 1 , offvalue = 0 ) . grid ( row = 1 , column = 0 , columnspan = 2 , sticky = 'news' ) Label ( frame1 , text = 'Symbol:' ) . grid ( row = 2 , column = 0 , padx = 2 , pady = 2 ) symbolbutton = Menubutton ( frame1 , textvariable = self . pltsymbol , relief = GROOVE , width = 16 , bg = 'lightblue' ) symbol_menu = Menu ( symbolbutton , tearoff = 0 ) symbolbutton [ 'menu' ] = symbol_menu for text in self . shapes : symbol_menu . add_radiobutton ( label = text , variable = self . pltsymbol , value = text , indicatoron = 1 ) symbolbutton . grid ( row = 2 , column = 1 , sticky = 'news' , padx = 2 , pady = 2 ) row = row + 1 Label ( frame1 , text = 'Legend pos:' ) . grid ( row = 3 , column = 0 , padx = 2 , pady = 2 ) legendposbutton = Menubutton ( frame1 , textvariable = self . legendlocvar , relief = GROOVE , width = 16 , bg = 'lightblue' ) legendpos_menu = Menu ( legendposbutton , tearoff = 0 ) legendposbutton [ 'menu' ] = legendpos_menu i = 0 for p in self . legend_positions : legendpos_menu . add_radiobutton ( label = p , variable = self . legendlocvar , value = p , indicatoron = 1 ) i += 1 legendposbutton . grid ( row = 3 , column = 1 , sticky = 'news' , padx = 2 , pady = 2 ) Label ( frame1 , text = 'Font:' ) . grid ( row = 4 , column = 0 , padx = 2 , pady = 2 ) fontbutton = Menubutton ( frame1 , textvariable = self . fontvar , relief = GROOVE , width = 16 , bg = 'lightblue' ) font_menu = Menu ( fontbutton , tearoff = 0 ) fontbutton [ 'menu' ] = font_menu for f in self . fonts : font_menu . add_radiobutton ( label = f , variable = self . fontvar , value = f , indicatoron = 1 ) fontbutton . grid ( row = 4 , column = 1 , sticky = 'news' , padx = 2 , pady = 2 ) row = row + 1 Label ( frame1 , text = 'Font size:' ) . grid ( row = 5 , column = 0 , padx = 2 , pady = 2 ) Scale ( frame1 , from_ = 8 , to = 26 , resolution = 0.5 , orient = 'horizontal' , relief = GROOVE , variable = self . fontsizevar ) . grid ( row = 5 , column = 1 , padx = 2 , pady = 2 ) Label ( frame1 , text = 'linewidth:' ) . grid ( row = 6 , column = 0 , padx = 2 , pady = 2 ) Scale ( frame1 , from_ = 1 , to = 10 , resolution = 0.5 , orient = 'horizontal' , relief = GROOVE , variable = self . linewidthvar ) . grid ( row = 6 , column = 1 , padx = 2 , pady = 2 ) row = 0 scalesframe = LabelFrame ( self . plotprefswin , text = "Axes Scales" ) scales = { 0 : 'norm' , 1 : 'log' } for i in range ( 0 , 2 ) : Radiobutton ( scalesframe , text = 'x-' + scales [ i ] , variable = self . xscalevar , value = i ) . grid ( row = 0 , column = i , pady = 2 ) Radiobutton ( scalesframe , text = 'y-' + scales [ i ] , variable = self . yscalevar , value = i ) . grid ( row = 1 , column = i , pady = 2 ) scalesframe . grid ( row = row , column = 1 , sticky = 'news' , padx = 2 , pady = 2 ) row = row + 1 frame = LabelFrame ( self . plotprefswin , text = 'Graph type' ) frame . grid ( row = row , column = 0 , columnspan = 2 , sticky = 'news' , padx = 2 , pady = 2 ) for i in range ( len ( self . graphtypes ) ) : Radiobutton ( frame , text = self . graphtypes [ i ] , variable = self . graphtypevar , value = self . graphtypes [ i ] ) . grid ( row = 0 , column = i , pady = 2 ) row = row + 1 labelsframe = LabelFrame ( self . plotprefswin , text = 'Labels' ) labelsframe . grid ( row = row , column = 0 , columnspan = 2 , sticky = 'news' , padx = 2 , pady = 2 ) Label ( labelsframe , text = 'Title:' ) . grid ( row = 0 , column = 0 , padx = 2 , pady = 2 ) Entry ( labelsframe , textvariable = self . plottitlevar , bg = 'white' , relief = GROOVE ) . grid ( row = 0 , column = 1 , padx = 2 , pady = 2 ) Label ( labelsframe , text = 'X-axis label:' ) . grid ( row = 1 , column = 0 , padx = 2 , pady = 2 ) Entry ( labelsframe , textvariable = self . plotxlabelvar , bg = 'white' , relief = GROOVE ) . grid ( row = 1 , column = 1 , padx = 2 , pady = 2 ) Label ( labelsframe , text = 'Y-axis label:' ) . grid ( row = 2 , column = 0 , padx = 2 , pady = 2 ) Entry ( labelsframe , textvariable = self . plotylabelvar , bg = 'white' , relief = GROOVE ) . grid ( row = 2 , column = 1 , padx = 2 , pady = 2 ) if self . currdata != None : #print self.dataseriesvars row = row + 1 seriesframe = LabelFrame ( self . plotprefswin , text = "Data Series Labels" ) seriesframe . grid ( row = row , column = 0 , columnspan = 2 , sticky = 'news' , padx = 2 , pady = 2 ) #self.dataseriesvars=[] if len ( self . dataseriesvars ) == 0 : self . setDataSeries ( range ( len ( self . currdata ) ) ) r = 1 sr = 1 cl = 0 for s in self . dataseriesvars : Label ( seriesframe , text = 'Series ' + str ( r ) ) . grid ( row = r , column = cl , padx = 2 , pady = 2 ) Entry ( seriesframe , textvariable = s , bg = 'white' , relief = GROOVE ) . grid ( row = r , column = cl + 1 , padx = 2 , pady = 2 ) r += 1 if r > 8 : r = 1 cl += 2 row = row + 1 cbuttons = { } frame = LabelFrame ( self . plotprefswin , text = "Dataset Colors" ) r = 1 cl = 0 sr = 1 ci = 0 for d in range ( len ( self . dataseriesvars ) ) : if d >= len ( self . datacolors ) : self . datacolors . append ( self . colors [ ci ] ) ci += 1 c = self . datacolors [ d ] action = lambda x = ( d , c ) : choosecolor ( x ) cbuttons [ d ] = Button ( frame , text = 'Series ' + str ( sr ) , bg = c , command = action ) cbuttons [ d ] . grid ( row = r , column = cl , sticky = 'news' , padx = 2 , pady = 2 ) r += 1 sr += 1 if r > 8 : r = 1 cl += 1 frame . grid ( row = row , column = 0 , columnspan = 2 , sticky = 'news' , padx = 2 , pady = 2 ) row = row + 1 frame = Frame ( self . plotprefswin ) frame . grid ( row = row , column = 0 , columnspan = 2 , sticky = 'news' , padx = 2 , pady = 2 ) replotb = Button ( frame , text = "Replot" , command = lambda : self . plotCurrent ( graphtype = self . graphtype , guiopts = True ) , relief = GROOVE , bg = '#99ccff' ) replotb . pack ( side = LEFT , fill = X , padx = 2 , pady = 2 ) b = Button ( frame , text = "Apply" , command = self . applyOptions , relief = GROOVE , bg = '#99ccff' ) b . pack ( side = LEFT , fill = X , padx = 2 , pady = 2 ) b = Button ( frame , text = "Save" , command = self . saveCurrent , relief = GROOVE , bg = '#99ccff' ) b . pack ( side = LEFT , fill = X , padx = 2 , pady = 2 ) c = Button ( frame , text = 'Close' , command = close_prefsdialog , relief = GROOVE , bg = '#99ccff' ) c . pack ( side = LEFT , fill = X , padx = 2 , pady = 2 ) if self . currdata == None : replotb . configure ( state = DISABLED ) self . plotprefswin . focus_set ( ) self . plotprefswin . grab_set ( ) return