Tkinter equiv for setPalette

MASI qwe at ngi.it
Sun Feb 10 11:31:59 EST 2008


Il Sun, 10 Feb 2008 12:03:59 +0100, Helmut Jarausch ha scritto:

> Hi,
> 
> I am to convert an old Perl-Tk script to Python.
> It starts by
> my $MW= new MainWindow;
> $MW->setPalette(background => 'AntiqueWhite1', foreground => 'blue');
> 
> Is there an equivalent for Tkinter? How can I set default colors for
> background and foreground for the whole application (root window and its
> children)
> 
> Many thanks for a hint,
> Helmut.

You have two options:
1) put your preference in a file

eg

file 'tk_option':

*foreground: blue
*background: green
*Entry*background: red

and read it

root = Tkinter.Tk()
root.option_readfile('tk_option')

2) in your program whit option_add

eg

root = Tkinter.Tk()
root.option_add('*foreground', 'blue')
root.option_add('*background', 'green')
root.option_add('*Entry*background', 'red')



More information about the Python-list mailing list