Thank your for your patience and help. I have improved the code a bit, but have hit a snag. I am using a hash reference to call a Checkbutton variable. The reference on line 55 , $flags{$tab} is the variable $pgr1_flag. Evidently this is ill-advised. Advice?
use warnings; use strict; use Tk; use Tk::NoteBook; require Tk::Pane; use Tk::LabEntry; my $mw = MainWindow->new; $mw->geometry( "600x500" ); $mw->title("Survival Kit"); ##mainwindow, scroll, frames## my $spane=$mw->Scrolled('Pane')->pack(-expand=>1,-fill=>'both'); my $frame1=$spane->Frame()->pack(-side=>'left',-expand=>1,-fill=>'both +',-padx=>15); my $frame2=$spane->Frame(-padx=>15)->pack(-side=>'right',-expand=>1,-f +ill=>'both'); ##Checkbuttons## my ($pgr1_flag,$pgr2_flag); my %flags = qw(program1 $pgr1_flag program2 $pgr2_flag); my $cb_cnt=1; for my $flag (keys %flags){ if ($cb_cnt < 6 ){ my $flag_but=$frame1->Checkbutton(-text => "$flag ", -variable + => \$flags{$flag} )->pack; } else { my $flag_but=$frame2->Checkbutton(-text => "$flag ", -va +riable => \$flags{$flag} )->pack; } $cb_cnt++; } ##OPEN button## my $open=$mw->Button(-text => "Open\n Tool (s)", -command => \&but)->p +ack( -side=>'bottom', -pady=>20); MainLoop; ####################### subs ################################# sub but { ## kill top window $spane->destroy($open); ###default hash my %tools = ( 'program1' => { 'PARM1' => 1, 'PARM2' => 'n', 'PARM3' => + 'y', 'PARM4' => 'n', 'PARM5' => 'y', 'PARM6' => 'n', 'PARM7' => 'y', + 'PARM8' => 'n', 'PARM9' => 'y', 'PARM10' => 'n' }, 'program2' => { ' +PARM1' => 1, 'PARM2' => 2, 'PARM3' => 3, 'PARM4' => 4, 'PARM5' => 5, +'PARM6' => 6, 'PARM7' => 7, 'PARM8' => 8, 'PARM9' => 9, 'PARM10' => 1 +0 }); ## create notebook my $book = $mw->NoteBook()->pack(-expand=>1,-fill=>'both'); #####program1####### my $tab_cnt=1; for my $tab (keys %flags){ if ($flags{$tab}){ ##create tab,scroll pane,frames my $tab_tab=$book->add("Sheet $tab_cnt", -label => "$tab")->pack +(-expand=>1,-fill=>'both'); my $tab_spane=$tab_tab->Scrolled('Pane')->pack(-expand=>1,-fill= +>'both'); my $tab_frame1=$tab_spane->Frame()->pack(-side=>'left',-expand=> +0,-fill=>'both',-padx=>15); my $tab_frame2=$tab_spane->Frame(-padx=>15)->pack(-side=>'right' +,-expand=>0,-fill=>'both'); $tab_cnt++; ##now fill frames my $parm_cnt=0; print "Processing tool: $tab\n"; foreach my $parm ( keys %{$tools{$tab}}) { print " $parm = $tools{$tab}{$parm}\n"; if ($parm_cnt < 5){ $tab_frame1->LabEntry(-label => "$parm=", -textvariab +le => "$tools{$tab}{$parm}" )->pack; } else { $tab_frame2->LabEntry(-label => "$parm=", -textvariab +le => "$tools{$tab}{$parm}" )->pack; } my $tab_parms .= "$parm=$tools{$tab}{$parm}\n"; $parm_cnt++; } } } ###################SAVE parameters? ## button - disappears on reset? #my $save1=$sub_spane->Button(-text => "Save Parameters ")->pack; ########Exit button########### ## Implement save? my $leave=$mw->Button(-text => "Save & Exit ",-command => \&save_parms +)->pack; ############################## #######Reset button############# ##needs better implementation? my $return=$mw->Button(-text => "Reset ", -command => \&rtn)->pack( -s +ide=>'bottom', -pady=>20); } ###################################################################### +###################################### sub rtn{ system 'perl doOver.1 &'; exit; } ############################# #our ($pgr1_parms,$pgr2_parms); sub save_parms { # open (SP1,">pgr1_parms.txt"); # print SP1 $pgr1_parms; # close SP1; # open (SP2,">pgr2_parms.txt"); # print SP2 $pgr2_parms; # close SP2; exit; }
BJ

In reply to Re^4: clunky Tk GUI by honyok
in thread clunky Tk GUI by honyok

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.