in reply to Setting Standard options for Tk widgets

Tk::option::optionAdd in the Tk::option module may be what you are looking for. Described in Chapter 16 of 'Mastering Perl/Tk'.


--Bob Niederman, http://bob-n.com
  • Comment on Re: Setting Standard options for Tk widgets

Replies are listed 'Best First'.
Re: Re: Setting Standard options for Tk widgets
by bobn (Chaplain) on Jun 09, 2003 at 01:59 UTC
    Here's an example:
    #!/usr/bin/perl -w use Tk; use strict; my $mw = MainWindow->new; $mw->packPropagate(0); $mw->optionAdd("*Button.Background", "red"); print "ARGV=@ARGV.\n"; my $l1 = $mw->Label(-text => "Application class/name is\n'" . $mw->class . '/' . $mw->name . "' +"); $l1->pack; my $b1 = $mw->Button(-background => 'yellow')->pack; my $b2 = $mw->Button->pack; my $b3 = $mw->Button('Name' => 'B3')->pack; foreach ($mw->children) { next if ref $_ eq 'Tk::Label'; $_->configure(-text => "'" . $_->PathName . "'"); } MainLoop;


    Run this with and without the $mw->optionAdd line to see the effect.

    --Bob Niederman, http://bob-n.com
Re: Re: Setting Standard options for Tk widgets
by batkins (Chaplain) on Jun 09, 2003 at 01:42 UTC
    ++ That's what I was looking for!

    I even looked throught Mastering Perl/Tk. I guess I missed it. Thanks a lot!

    Bill