Perl Tk widget access question


Read With Formatting | Free Open Source Tutorials Account

Perl Programming
Thread: Perl Tk widget access question


Mallow
Hi.

Somewhat new to Perl Tk, and trying to understand where the master list of widgets is. For example,

my $newwidget = $mw->label()
my $alsonewwidget = $mw->notebook()
access_widgets();
MainLoop;

sub access_widgets {
$newwidget->configure(-foreground => 'red')
$alsonewwidget->configure(-foreground => 'blue')

}

-------
The above won't work because the widgets fall out of scope. It seems to be forcing me to sweep every little widget into the called function in order to touch it.

It seems like there should be a way to make widgets global so that they can be accessed anywhere even if not passed as parameters to the called function.

Does anybody know how to make this work?

Thanks in advance.