Butch has asked for the wisdom of the Perl Monks concerning the following question:
#!perl -w use strict; use warnings; use Cwd; use Tk 804; require Tk::Pane; # Buttons to be loaded onto the GUI my @buttons; $buttons[0] = "Button1"; $buttons[1] = "Button2"; $buttons[2] = "Button3"; # Create the main GUI my $MW = MainWindow->new(); $MW->title("Generic GUI creation list demo"); # Create a frame to hold all of the buttons my $master_frame = $MW->Frame( -borderwidth => 2, -relief => 'solid' )->pack( -side => 'top', -expand => 0, -anchor => 'w' ); # Create a scrolled pane within the frame my $master_pane = $master_frame->Scrolled( 'Pane', -height => 100, -width => 1000, -scrollbars => 'osoe', )->pack( -side => 'top', -anchor => 'w' ); # Add the list of pictures to the frame foreach my $button ( @buttons ) { # Create a frame for the widgets my $frame = $master_pane->Frame->pack( -side => 'top', -expand => 1, -fill => 'both', -anchor => 'w', -padx => 2, - pady => 4 ); # Add a label widget $frame->Label( -anchor => 'nw', -justify => 'right', -relief => 'groove', -text => $button, -width => 20, -height => 1 )->pack( -side => 'left', -anchor => 'w' ); # Add a button widget $frame->Button( -anchor => 'nw', -text => "change " . $button, -command => 'main::print_button_label' )->pack( -side => 'left', -anchor => 'w', -padx => 2 ); } # Run the GUI MainLoop; sub print_button_label # This operation is responsible for determining which # button was pressed and then printing the label # assocaited with the button { # Print out the label assocated with this button # # I can't work out how to do this!! # print "????\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Currently selected TK widget.
by zentara (Cardinal) on Apr 11, 2006 at 11:39 UTC | |
by Butch (Novice) on Apr 11, 2006 at 11:52 UTC | |
|
Re: Currently selected TK widget.
by wulvrine (Friar) on Apr 11, 2006 at 11:24 UTC |