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, );
In reply to Configure default widget options in Tk by hangon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |