Thanks. honyok#!/usr/bin/perl -w use warnings; use strict; use Tk; use Tk::NoteBook; require Tk::Pane; use Tie::IxHash; use Tk::LabEntry; my $mw = MainWindow->new; $mw->geometry( "600x500"); $mw->title("Survival Kit"); ##################NOTES######## ##expansion from 2nd tab has bug? ###default hash tie my %tools, 'Tie::IxHash', 'program1' => ordered_hash_ref ( 'PARM1' => 'Y', 'PARM2' => 'files', ' +PARM3' => 'list', 'PARM4' => 'Y', 'PARM5' => 'N'), 'program2' => ordered_hash_ref ( 'PARM' => '', 'PARM0' => 0, 'PARM1' = +> 1, 'PARM2' => 2, 'PARM3' => 3, 'PARM4' => 4, 'PARM5' => 5, 'PARM6' +=> 6, 'PARM7' => 7, 'PARM8' => 8, 'PARM9' =>9, 'PARM10' => 10 ); + ## create notebook my $book = $mw->NoteBook()->pack(-expand=>1,-fill=>'both'); #####program1####### my $tab_cnt=1; for my $tab (keys %tools){ ##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',-background=>'slate grey +')->pack(-expand=>1, -fill=>'both'); my $tab_frame1=$tab_spane->Frame(-background=>'blue')->pack(-sid +e=>'left',-expand=>1,-fill=>'both',-padx=>15); my $tab_frame2=$tab_spane->Frame(-background=>'red')->pack(-side +=>'bottom',-anchor=>'s',-fill=>'x'); $tab_cnt++; #create columns my $tab_column1 = $tab_frame1->Frame()->pack(-side=>'left',-exp +and=>1,-fill=>'both'); my $tab_column2 = $tab_frame2->Frame()->pack(-side=>'right',-ex +pand=>1,-fill=>'both'); ##now fill frames my $parm_cnt=1; #print "Processing tool: $tab\n"; foreach my $parm ( keys %{$tools{$tab}}) { #print " $parm = $tools{$tab}{$parm}\n"; my $tab_test; if ($parm_cnt < 7 ){ $tab_test=$tab_column1->LabEntry(-label => "$parm=" +); $tab_test->Subwidget('entry')->configure(-textvariable => + \$tools{$tab}{$parm} ); $tab_test->configure(-labelPack=>[-side=>'left']); $tab_test->pack(-anchor=>'e'); } else { $tab_test=$tab_column2->LabEntry(-label => "$parm=" +); $tab_test->Subwidget('entry')->configure(-textvariable => + \$tools{$tab}{$parm} ); $tab_test->configure(-labelPack=>[-side=>'left']); $tab_test->pack(-anchor=>'e'); } $parm_cnt++; } #######go and save button############# my $run=$tab_tab->Button(-text => "\n $tab \n ",-command=> +\&go ,-command =>[\&save_parms,$tab],-background=>'slate grey')->pack +; } MainLoop; ####################### subs ############################### ## save parameters ########## sub save_parms { my $tab = shift; #print $tab; open (my $parfile,"> ${tab}_parms.txt") or warn "$!\n"; foreach my $parm ( keys %{$tools{$tab}} ) { print $parfile "$parm=$tools{$tab}{$parm}\n"; } close $parfile; } ###########execute program sub go { #if ( "$tab" eq "program1"){ #open STDOUT,">tmpfile" or die "Cannot open temp file"; #open STDERR, '>>&STDOUT'; #system 'program1.exe' or die "$!\n" #close STDOUT; #} } ## order hashes## sub ordered_hash_ref { tie my %hash, 'Tie::IxHash', @_; return \%hash; } #######conflict between save_parms output and save_history output? #sub save_history { #foreach my $tool (sort keys %tools){ # open (my $histfile,"> ${tool}.history") or warn "$!\n"; # foreach my $text (custom_sort(\%{$tools{$tool}})) { # print $histfile "$text=$tools{$tool}{$text}\n"; # } #close $histfile; # } #} ###########################
In reply to Tk gui bug by honyok
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |