amboxer21 has asked for the wisdom of the Perl Monks concerning the following question:
#########################################################################use strict; #use warnings; #use diagnostics; use Tk; my $mw = MainWindow->new; $mw->title( 'Albums' ); open my $FILE, "<Album_Names", or die "Can't open file: $!"; my @lines = <$FILE>; my $NumberOfAlbums = scalar @lines; print "You have $NumberOfAlbums albums.\n"; close( $FILE ) or die "Cannot close file: $!"; my $i = 0; my @Selected; foreach my $n ( @lines ) { $mw->Checkbutton( -text => "$n", -onvalue => $n, -offvalue => 0, -variable => \$Selected[$i], )->pack(-side => 'top', -anc +hor => 'nw' ); $i=$i+1; } my $GetAlbumsButtons = $mw->Button( -text => "Get Albums", -command => \&value, )->pack( -side => 'bottom', +-anchor => 's' ); sub value { for my $x ( @Selected ) { ## Regex is a test to see if it works. if( $x ne 0 && $x =~ m/LINUX/ ) { print "$x"; } } print "\n"; }; MainLoop;
use strict; use warnings; use Tk; my $mw = MainWindow->new; $mw->title( 'Albums' ); my @Buttons; open my $FILE, "<Album_Names", or die "Can't open file: $!"; my @lines = <$FILE>; my $NumberOfAlbums = scalar @lines; print "You have $NumberOfAlbums albums.\n"; close( $FILE ) or die "Cannot close file: $!"; my $i = 0; my @Selected; foreach my $n ( @lines ) { push( my @Values, $mw->Checkbutton( -text => "$n", -variable => \$Selected[$i], )->pack(-side => ' +top', -anchor => 'nw' ) ); $i=$i+1; } my $GetAlbumsButtons = $mw->Button( -text => "Get Albums", -command => sub { print "Get Albums Button Pressed +.\n"; }, )->pack( -side => 'bottom', -anchor => 's' ); MainLoop;
Mobile Uploads Timeline Photos Untitled Album LINUX Cover Photos 5k Races 2013 Dirt bike Races 2013 Profile Pictures
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: print the values of the selected check buttons
by zentara (Cardinal) on Jan 12, 2014 at 13:16 UTC | |
|
Re: print the values of the selected check buttons
by Anonymous Monk on Jan 12, 2014 at 04:17 UTC |