Nicer Tkinter on UNIX?

Martin Franklin martin.franklin at westgeo.com
Mon Oct 29 03:26:39 EST 2001


Mike Clarkson wrote:


>>>> 
>>>>I like Tkinter because it's standard. But there is a big but.
>>>>While on Windows it looks great, on unices it makes kids laugh.
>>>>Not that it's particularly ugly, but quite awkward and not up to the
>>>>aesthetic standards people expect now.


--- snip lots and lots of good stuff ---


I too don't like the 'look' of Tk on unix so here is what I do.

def change_theme(parent):
    font='Fixed'                  # all text (Label, Button, Listbox....  
    bg='grey88'                   # all backgrounds (Frame, Button etc)  
    tbg='white'                   # Text backgrounds (Entry, Listbox,Text)
    fg='black'                    # All foreground text 
    sbg='navy'                    # selected background
    sfg='white'                   # selected foreground 
    abg='grey77'                  # active background
    afg='black'                   # active foreground
    
    # all widgets
    parent.option_add('*background', bg)
    parent.option_add('*foreground', fg)
    parent.option_add('*activeBackground', abg)
    parent.option_add('*activeForeground', afg)
    parent.option_add('*selectBackground', sbg)
    parent.option_add('*selectForeground', sfg)
    parent.option_add('*font', font) 

   # Listbox widget
    parent.option_add('*Listbox.background', tbg)
 
    # Text widget
    parent.option_add('*Text.background', tbg)
 
    # Entry widget
    parent.option_add('*Entry.background', tbg)
 
    # Canvas widget
    parent.option_add('*Canvas.background', tbg)

I just call it with the Tk root window as the only argument.....

HTH
Martin.








More information about the Python-list mailing list