in reply to GUI Setup with Tk, overly verbose, or maintainable?
I like the use constant approach that keszler mentioned. There is a module that can do the counting for you; it is called enum::fields. You also have the opportunity to remove some redundancy from your array initializations.
sub guiStart { my ($client,$login) = @_; my $mw = MainWindow->new(-borderwidth => 30, -title => "Duplicates: ".$client); use enum::fields qw{ LIST DEL ADD DUP CHG EXIT }; my %layout; $layout{label} = [ 'List Available Data', 'Remove Data', 'Add Data', 'Identify Duplicates', 'Change Client', 'Exit Application', ]; $layout{callback} = [ \&listData, \&removeData, [\&addData,,$client,$login,$mw], \&identifyDuplicates, \&changeClient, \&exitApp, ]; for my $btn (LIST..EXIT) { $layout{frame}->[$btn] = $mw->Frame(); $layout{button}->[$btn] = $layout{frame}->[$btn] ->Button(-text => $layout{label}->[$btn], -width => 20, -command => $layout{callback}->[$btn]) ->pack(); $layout{frame}->[$btn]->pack(); } MainLoop; return; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: GUI Setup with Tk, overly verbose, or maintainable?
by Grygonos (Chaplain) on Jul 04, 2004 at 14:14 UTC | |
by toma (Vicar) on Jul 06, 2004 at 00:08 UTC |