[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Tkinter equiv for setPalette

Helmut Jarausch

2/10/2008 11:04:00 AM

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
2 Answers

MASI

2/10/2008 4:32:00 PM

0

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

Russell E. Owen

2/11/2008 7:42:00 PM

0

In article <47aeda20$0$2988$ba620e4c@news.skynet.be>,
Helmut Jarausch <jarausch@skynet.be> wrote:

> 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