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; }
In reply to GUI Setup with Tk, overly verbose, or maintainable? by Grygonos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |