Tkinter equiv for setPalette

H

Helmut Jarausch

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.

--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
 
M

MASI

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')
 
R

Russell E. Owen

Helmut Jarausch said:
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)

Tkinter widgets have a tk_setPalette method so you can do this:

root = Tkinter.Tk()
root.tk_setPalette(background = 'AntiqueWhite1', foreground = 'blue')

-- Russell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,149
Members
46,695
Latest member
StanleyDri

Latest Threads

Top