my %default_scale_options = (
-width => '10',
-length => '200',
-sliderlength => '16',
-orient => 'horizontal',
-borderwidth => '1',
-cursor => 'hand2',
-showvalue => '0'
);
...
my $scale1 = $parent->Scale(%default_scale_options);
...
my $scaleN = $parent->Scale(%default_scale_options);
An alternative to this is to use an option database. You can set this up external to your script (e.g. with a .Xdefaults file) allowing access by multiple scripts; you can also use optionAdd(), and related methods, to handle options within a single script. See option for details.
Here's an example of usage extracted from one of my own scripts. configure_option_database() is called after MainWindow->new() but before any widgets are created.
sub configure_option_database {
...
my $priority = 'startupFile'; # 40
...
# Button
$mw->optionAdd('*Button*borderWidth', 1, $priority);
$mw->optionAdd('*Button*activeBorderWidth', 1, $priority);
...
# Entry
$mw->optionAdd('*Entry*background', '#ffffff', $priority);
$mw->optionAdd('*Entry*borderWidth', 1, $priority);
$mw->optionAdd('*Entry*cursor', 'xterm', $priority);
...
}
|