How to change tkinter GUI look-and-feel?

klappnase klappnase at web.de
Fri May 7 07:12:06 EDT 2004


Jonathon McKitrick <jcm at FreeBSD-uk.eu.org> wrote in message news:<mailman.331.1083882928.25742.python-list at python.org>...
> I saw some screenshots of mayavi.  Is there any way we can set tkinter to
> use the motif (or some other toolkit under Unix) rather than the default?
> 
> jm

Hi Jonathon,

you cannot make Tkinter use another toolkit (of course); if you mean
just to change the look and feel you can use the tk_strictMotif()
method to get a quite "native" motif look and feel:

from Tkinter import *
root = Tk()
root.tk_strictMotif()

or use an optionDB file if you just want to do an application wide
change of tk's sometimes ugly defaults on unix:

from Tkinter import *
root = Tk()
root.option_readfile(path-to-your-optionDB)

The contents of the optionDB may look like this:
########-file optionDB-##############################
*font : Helvetica -12
*Entry*background : white
*Listbox*background : white
*Listbox*exportSelection : 0
*selectBackground : #a0a
*selectForeground : white
*Scrollbar*Width : 12
*Scrollbar*troughColor : #aaa
*Scrollbar*takeFocus : 0
*Checkbutton*selectColor : green
*Radiobutton*selectColor : green
*Menu*tearOff : 0
*Menu*relief : ridge
*Menu*borderWidth : 2
*Button*Width : 10
######################################################
That's an optionDB I've been using, I think you'll see the point how
to change the default values of configuration options for different
widgets.

I hope this helps

Michael



More information about the Python-list mailing list