(self, prefs=None)
return self.prefswindow
Show table options dialog using an instance of prefs
Show table options dialog using an instance of prefs
Show table options dialog using an instance of prefs
def showtablePrefs(self, prefs=None):
        """Show table options dialog using an instance of prefs"""
        #self.prefs = prefs
        if self.prefs == None:
            self.loadPrefs()
        self.prefswindow=Toplevel()
        x,y,w,h = self.getGeometry(self.master)
        self.prefswindow.geometry('+%s+%s' %(int(x+w/2),int(y+h/2)))
        self.prefswindow.title('Preferences')
        self.prefswindow.resizable(width=FALSE, height=FALSE)

        frame1=Frame(self.prefswindow)
        frame1.pack(side=LEFT)
        frame2=Frame(self.prefswindow)
        frame2.pack()
        def close_prefsdialog():
            self.prefswindow.destroy()
        row=0
        Checkbutton(frame1, text="Show horizontal lines", variable=self.horizlinesvar,
                    onvalue=1, offvalue=0).grid(row=row,column=0, columnspan=2, sticky='news')
        row=row+1
        Checkbutton(frame1, text="Show vertical lines", variable=self.vertlinesvar,
                    onvalue=1, offvalue=0).grid(row=row,column=0, columnspan=2, sticky='news')
        row=row+1
        Checkbutton(frame1, text="Alternate Row Color", variable=self.alternaterowsvar,
                    onvalue=1, offvalue=0).grid(row=row,column=0, columnspan=2, sticky='news')
        row=row+1
        lblrowheight = Label(frame1,text='Row Height:')
        lblrowheight.grid(row=row,column=0,padx=3,pady=2)
        rowheightentry = Spinbox(frame1,from_=12,to=50,width=10,
                            textvariable=self.rowheightvar)
        rowheightentry.grid(row=row,column=1,padx=3,pady=2)
        row=row+1
        lblcellwidth = Label(frame1,text='Cell Width:')
        lblcellwidth.grid(row=row,column=0,padx=3,pady=2)
        cellwidthentry = Spinbox(frame1,from_=20,to=500, width=10,
                             textvariable=self.cellwidthvar)
        cellwidthentry.grid(row=row,column=1,padx=3,pady=2)
        row=row+1

        lbllinewidth = Label(frame1,text='Line Width:')
        lbllinewidth.grid(row=row,column=0,padx=3,pady=2)
        linewidthentry = Spinbox(frame1,from_=0,to=10,width=10,
                            textvariable=self.linewidthvar)
        linewidthentry.grid(row=row,column=1,padx=3,pady=2)
        row=row+1

        rowhdrwidth = Label(frame1,text='Row Header Width:')
        rowhdrwidth.grid(row=row,column=0,padx=3,pady=2)
        rowhdrentry = Spinbox(frame1,from_=0,to=300, width=10,
                            textvariable=self.rowheaderwidthvar)
        rowhdrentry.grid(row=row,column=1,padx=3,pady=2)
        row=row+1

        #fonts
        fts = self.getFonts()
        self.fontvar = StringVar()
        self.fontvar.set(self.prefs.get('celltextfont'))
        def setFont(*args):
            self.thefont = self.fontvar.get()
            return

        self.fontbox = Combobox(frame2,
                        values=(fts),
                        text='Font:',
                        height = 6,
                        textvariable=self.fontvar)
        self.fontvar.trace('w', setFont)
        Label(frame2,text='Font:').grid(row=row,column=0,padx=3,pady=2)
        self.fontbox.grid(row=row,column=1, columnspan=2, sticky='nes', padx=3,pady=2)
        row=row+1

        lblfontsize=Label(frame2,text='Text Size:')
        lblfontsize.grid(row=row,column=0,padx=3,pady=2)
        fontsizeentry = Spinbox(frame2,from_=6,to=50, width=20,
                                textvariable=self.celltextsizevar)

        fontsizeentry.grid(row=row,column=1, sticky='wens',padx=3,pady=2)
        row=row+1

        #cell alignment
        lbl=Label(frame2,text='Alignment:')
        lbl.grid(row=row,column=0,padx=3,pady=2)
        alignentry_button = Menubutton(frame2,textvariable=self.cellalignvar, width=16)
        alignentry_menu = Menu(alignentry_button,tearoff=0)
        alignentry_button['menu'] = alignentry_menu
        alignments=['w','e','center']
        for text in alignments:
            alignentry_menu.add_radiobutton(label=text,
                                            variable=self.cellalignvar,
                                            value=text,
                                            indicatoron=1)
        alignentry_button.grid(row=row,column=1, sticky='nes', padx=3,pady=2)
        row=row+1

        #colors
        style = Style()
        style.configure("cb.TButton", background=self.bgcolor)
        bgcolorbutton = Button(frame2, text='table background', style="cb.TButton", #bg=self.bgcolor,
                                 command=self.setbgcolor)
        bgcolorbutton.grid(row=row,column=0,columnspan=2, sticky='news',padx=3,pady=2)
        row=row+1
        style = Style()
        style.configure("gc.TButton", background=self.grid_color)
        grid_colorbutton = Button(frame2, text='grid color',  style="gc.TButton", #bg=self.grid_color,
                                 command=self.setgrid_color)
        grid_colorbutton.grid(row=row,column=0,columnspan=2,  sticky='news',padx=3,pady=2)
        row=row+1
        style = Style()
        style.configure("rhc.TButton", background=self.rowselectedcolor)
        rowselectedcolorbutton = Button(frame2, text='row highlight color', style="rhc.TButton",
                                 command=self.setrowselectedcolor)
        rowselectedcolorbutton.grid(row=row,column=0,columnspan=2,  sticky='news',padx=3,pady=2)
        row=row+1

        frame=Frame(self.prefswindow)
        frame.pack()
        # Apply Button
        b = Button(frame, text="Apply Settings", command=self.applyPrefs)
        b.grid(row=row,column=1,columnspan=2,sticky='news',padx=4,pady=4)

        # Close button
        c=Button(frame,text='Close', command=close_prefsdialog)
        c.grid(row=row,column=0,sticky='news',padx=4,pady=4)
        self.prefswindow.focus_set()
        self.prefswindow.grab_set()
        self.prefswindow.wait_window()
        return self.prefswindow
def showtablePrefs ( self , prefs = None ) : #self.prefs = prefs if self . prefs == None : self . loadPrefs ( ) self . prefswindow = Toplevel ( ) x , y , w , h = self . getGeometry ( self . master ) self . prefswindow . geometry ( '+%s+%s' % ( int ( x + w / 2 ) , int ( y + h / 2 ) ) ) self . prefswindow . title ( 'Preferences' ) self . prefswindow . resizable ( width = FALSE , height = FALSE ) frame1 = Frame ( self . prefswindow ) frame1 . pack ( side = LEFT ) frame2 = Frame ( self . prefswindow ) frame2 . pack ( ) def close_prefsdialog ( ) : self . prefswindow . destroy ( ) row = 0 Checkbutton ( frame1 , text = "Show horizontal lines" , variable = self . horizlinesvar , onvalue = 1 , offvalue = 0 ) . grid ( row = row , column = 0 , columnspan = 2 , sticky = 'news' ) row = row + 1 Checkbutton ( frame1 , text = "Show vertical lines" , variable = self . vertlinesvar , onvalue = 1 , offvalue = 0 ) . grid ( row = row , column = 0 , columnspan = 2 , sticky = 'news' ) row = row + 1 Checkbutton ( frame1 , text = "Alternate Row Color" , variable = self . alternaterowsvar , onvalue = 1 , offvalue = 0 ) . grid ( row = row , column = 0 , columnspan = 2 , sticky = 'news' ) row = row + 1 lblrowheight = Label ( frame1 , text = 'Row Height:' ) lblrowheight . grid ( row = row , column = 0 , padx = 3 , pady = 2 ) rowheightentry = Spinbox ( frame1 , from_ = 12 , to = 50 , width = 10 , textvariable = self . rowheightvar ) rowheightentry . grid ( row = row , column = 1 , padx = 3 , pady = 2 ) row = row + 1 lblcellwidth = Label ( frame1 , text = 'Cell Width:' ) lblcellwidth . grid ( row = row , column = 0 , padx = 3 , pady = 2 ) cellwidthentry = Spinbox ( frame1 , from_ = 20 , to = 500 , width = 10 , textvariable = self . cellwidthvar ) cellwidthentry . grid ( row = row , column = 1 , padx = 3 , pady = 2 ) row = row + 1 lbllinewidth = Label ( frame1 , text = 'Line Width:' ) lbllinewidth . grid ( row = row , column = 0 , padx = 3 , pady = 2 ) linewidthentry = Spinbox ( frame1 , from_ = 0 , to = 10 , width = 10 , textvariable = self . linewidthvar ) linewidthentry . grid ( row = row , column = 1 , padx = 3 , pady = 2 ) row = row + 1 rowhdrwidth = Label ( frame1 , text = 'Row Header Width:' ) rowhdrwidth . grid ( row = row , column = 0 , padx = 3 , pady = 2 ) rowhdrentry = Spinbox ( frame1 , from_ = 0 , to = 300 , width = 10 , textvariable = self . rowheaderwidthvar ) rowhdrentry . grid ( row = row , column = 1 , padx = 3 , pady = 2 ) row = row + 1 #fonts fts = self . getFonts ( ) self . fontvar = StringVar ( ) self . fontvar . set ( self . prefs . get ( 'celltextfont' ) ) def setFont ( * args ) : self . thefont = self . fontvar . get ( ) return self . fontbox = Combobox ( frame2 , values = ( fts ) , text = 'Font:' , height = 6 , textvariable = self . fontvar ) self . fontvar . trace ( 'w' , setFont ) Label ( frame2 , text = 'Font:' ) . grid ( row = row , column = 0 , padx = 3 , pady = 2 ) self . fontbox . grid ( row = row , column = 1 , columnspan = 2 , sticky = 'nes' , padx = 3 , pady = 2 ) row = row + 1 lblfontsize = Label ( frame2 , text = 'Text Size:' ) lblfontsize . grid ( row = row , column = 0 , padx = 3 , pady = 2 ) fontsizeentry = Spinbox ( frame2 , from_ = 6 , to = 50 , width = 20 , textvariable = self . celltextsizevar ) fontsizeentry . grid ( row = row , column = 1 , sticky = 'wens' , padx = 3 , pady = 2 ) row = row + 1 #cell alignment lbl = Label ( frame2 , text = 'Alignment:' ) lbl . grid ( row = row , column = 0 , padx = 3 , pady = 2 ) alignentry_button = Menubutton ( frame2 , textvariable = self . cellalignvar , width = 16 ) alignentry_menu = Menu ( alignentry_button , tearoff = 0 ) alignentry_button [ 'menu' ] = alignentry_menu alignments = [ 'w' , 'e' , 'center' ] for text in alignments : alignentry_menu . add_radiobutton ( label = text , variable = self . cellalignvar , value = text , indicatoron = 1 ) alignentry_button . grid ( row = row , column = 1 , sticky = 'nes' , padx = 3 , pady = 2 ) row = row + 1 #colors style = Style ( ) style . configure ( "cb.TButton" , background = self . bgcolor ) bgcolorbutton = Button ( frame2 , text = 'table background' , style = "cb.TButton" , #bg=self.bgcolor, command = self . setbgcolor ) bgcolorbutton . grid ( row = row , column = 0 , columnspan = 2 , sticky = 'news' , padx = 3 , pady = 2 ) row = row + 1 style = Style ( ) style . configure ( "gc.TButton" , background = self . grid_color ) grid_colorbutton = Button ( frame2 , text = 'grid color' , style = "gc.TButton" , #bg=self.grid_color, command = self . setgrid_color ) grid_colorbutton . grid ( row = row , column = 0 , columnspan = 2 , sticky = 'news' , padx = 3 , pady = 2 ) row = row + 1 style = Style ( ) style . configure ( "rhc.TButton" , background = self . rowselectedcolor ) rowselectedcolorbutton = Button ( frame2 , text = 'row highlight color' , style = "rhc.TButton" , command = self . setrowselectedcolor ) rowselectedcolorbutton . grid ( row = row , column = 0 , columnspan = 2 , sticky = 'news' , padx = 3 , pady = 2 ) row = row + 1 frame = Frame ( self . prefswindow ) frame . pack ( ) # Apply Button b = Button ( frame , text = "Apply Settings" , command = self . applyPrefs ) b . grid ( row = row , column = 1 , columnspan = 2 , sticky = 'news' , padx = 4 , pady = 4 ) # Close button c = Button ( frame , text = 'Close' , command = close_prefsdialog ) c . grid ( row = row , column = 0 , sticky = 'news' , padx = 4 , pady = 4 ) self . prefswindow . focus_set ( ) self . prefswindow . grab_set ( ) self . prefswindow . wait_window ( ) return self . prefswindow