Grygonos has asked for the wisdom of the Perl Monks concerning the following question:
I come seeking your opinions on this subroutine, it takes a reference to a scalar holding the name of the client, and a reference to a hash of db login properties. It then constructs the gui by creating a hash of arrays to hold corresponding elements.... lemme know what you think.. is it overly verbose.. or does it add to maintainability.
sub guiStart { my ($client,$login) = @_; my $mw = MainWindow->new(-borderwidth=>30, -title=>"Duplicates: ".$$client); my %layout = ('frame' => [], 'button' => [], 'label' => [], 'callback'=> []); #Construct labels $layout{'label'}->[0] = 'List Available Data'; $layout{'label'}->[1] = 'Remove Data'; $layout{'label'}->[2] = 'Add Data'; $layout{'label'}->[3] = 'Identify Duplicates'; $layout{'label'}->[4] = 'Change Client'; $layout{'label'}->[5] = 'Exit Application'; #Set callbacks $layout{'callback'}->[0] = \&listData; $layout{'callback'}->[1] = \&removeData; $layout{'callback'}->[2] = [\&addData,,$client,$login,$mw]; $layout{'callback'}->[3] = \&identifyDuplicates; $layout{'callback'}->[4] = \&changeClient; $layout{'callback'}->[5] = \&exitApp; for (0..5) { #Create the frames $layout{'frame'}->[$_] = $mw->Frame(); #Create the buttons $layout{'button'}->[$_] = $layout{'frame'}->[$_]->Button(-text + =>$layout{'label'}->[$_], -widt +h =>20, -comm +and=>$layout{'callback'}->[$_])->pack(); $layout{'frame'}->[$_]->pack(); } MainLoop; return; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: GUI Setup with Tk, overly verbose, or maintainable?
by keszler (Priest) on Jul 02, 2004 at 17:38 UTC | |
by Grygonos (Chaplain) on Jul 02, 2004 at 17:44 UTC | |
|
Re: GUI Setup with Tk, overly verbose, or maintainable?
by saberworks (Curate) on Jul 02, 2004 at 21:00 UTC | |
|
Re: GUI Setup with Tk, overly verbose, or maintainable?
by toma (Vicar) on Jul 03, 2004 at 23:07 UTC | |
by Grygonos (Chaplain) on Jul 04, 2004 at 14:14 UTC | |
by toma (Vicar) on Jul 06, 2004 at 00:08 UTC |