#!/usr/bin/perl use strict; #use diagnostics; use Tk; use Tk::Checkbox; #my $netUp = qx(bash /home/anthony/Documents/Bash/network); my $mw = MainWindow->new; $mw->geometry("150x600"); $mw->title("ConMan"); open my $FILE, '<', "ESSID", or die "Can't open file: $!"; my @lines = <$FILE>; my @Sel; my $i = 0; my @Selected; my $checkButton; foreach my $n ( @lines ) { $checkButton = $mw->Checkbutton( -text => "$n", -onvalue => 1, -offvalue => 0, -command => sub{push(@Sel, $n);}, -variable => \$Selected[$i], )->pack( -side => 'top', -anchor => 'nw' ); $i=$i+1; } my $connButton = $mw->Button( -text => "Connect", -command => \&value )->pack( -side => 'left', -anchor => 'sw', -padx => '5', -pady => '5' ); my $CancelButtons = $mw->Button( -text => "Close", -command => sub { print "Closing out ConnMan.\n"; $mw->withdraw; exit 0; }, )->pack( -side => 'right', -anchor => 'se', -padx => '5',); sub value { my $p = scalar(@Sel); foreach my $x (@Sel) { if( ( $p ne 0 ) && ( $p lt 2) ) { print $x; return 0; } else { print "\nSelect one network please.\n"; return 0; } } print "\n"; } sub reset { } MainLoop;