hangon has asked for the wisdom of the Perl Monks concerning the following question:
Is there a way to configure the default options that a particular type of widget will use when initialized? I have been setting them in a hash and adding it to the parameter list when calling the widget's constructor. It seems that there should be a better way built into Tk, but I've been unable to find it.
# this is what I'm doing: my %button_options = ( -font => '{Arial} 10 {bold}', -padx => 2, -pady => 2, ); my $button1 = $mw->Button( %button_options, -text => 'foo', -command => \&foo, ); my $button2 = $mw->Button( %button_options, -text => 'bar', -command => \&bar, ); # I would like to do it something like this: setDefaults ( -widget => 'Button', -font => '{Arial} 10 {bold}', -padx => 2, -pady => 2, ); my $button1 = $mw->Button( -text => 'foo', -command => \&foo, ); my $button2 = $mw->Button( -text => 'bar', -command => \&bar, );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Configure default widget options in Tk
by zentara (Cardinal) on Jan 19, 2009 at 17:56 UTC | |
by hangon (Deacon) on Jan 19, 2009 at 20:36 UTC |