For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > October 2005 > easy color changing









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author easy color changing
Krystian

2005-10-09, 6:57 pm

Hi there
I have perl/tk application. all GUI elements use grey color as default
in my operating system (windows / activeperl). i would like to know if
there is a simple way to change such color so MainWindow, embadded
frames and elements will use other color and application will look
different. I found it hard to change all color related options of each
widget (-background, -highlightcolor, -highlightbackground and so on).
Maybe there is any idea of inheritance. I tried to set these options
in MainWindow but elements created from it didn't have these colors.
Is there any approach of solving such look and feel problems? thanks
in advance

best
krystian
Marc Dashevsky

2005-10-09, 6:57 pm

Krystian <nobody@this.home.com> writes in article %:
> Hi there
> I have perl/tk application. all GUI elements use grey color as default
> in my operating system (windows / activeperl). i would like to know if
> there is a simple way to change such color so MainWindow, embadded
> frames and elements will use other color and application will look
> different. I found it hard to change all color related options of each
> widget (-background, -highlightcolor, -highlightbackground and so on).
> Maybe there is any idea of inheritance. I tried to set these options
> in MainWindow but elements created from it didn't have these colors.
> Is there any approach of solving such look and feel problems? thanks
> in advance


use strict;
use Tk;
my $mw = tkinit;
$mw->optionAdd('*foreground' => 'yellow');
$mw->optionAdd('*background' => 'black');
my $f = $mw->Frame->pack(-expand => 1, -fill => 'both');
$f->Label(-text => 'First label')->pack;
$f->Text->pack;
MainLoop;

Keep in mind that optionAdd() does not affect any widgets that
already exist at the time it is invoked.

--
Go to http://MarcDashevsky.com to send me e-mail.
(Reunion -- http://ClassicalHigh70.com)
Krystian

2005-10-09, 6:57 pm

Hi

> use strict;
> use Tk;
> my $mw = tkinit;
> $mw->optionAdd('*foreground' => 'yellow');
> $mw->optionAdd('*background' => 'black');
> my $f = $mw->Frame->pack(-expand => 1, -fill => 'both');
> $f->Label(-text => 'First label')->pack;
> $f->Text->pack;
> MainLoop;
>
>Keep in mind that optionAdd() does not affect any widgets that
>already exist at the time it is invoked.


thanks, this is exactly what i wanted.
cheers
k
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com