http://qs321.pair.com?node_id=1160279

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks. I'll preface this with I'm a big time newbie and reading a lot and trying to solve problems myself when I can. Any way I have a script that I created a GUI for using Tcl::Tk. The GUI works fine and gives the users the ability to select input files and run the script. I would however like to add a few things and I'm finding the documentation lacking or maybe I'm looking in the wrong place? The things that I'm tinkering with and seem to get working properly are: Pull down/File menus Radio Button Check Boxes ComboBoxes (kind of working) List Boxes (kind of working) Anyway here's the code I have for file selection, etc.

#!/usr/bin/perl use strict; use warnings; use Tcl::Tk;# Perl Tk GUI; Main Window my $int = new Tcl::Tk; my $mw = $int - > main window;# messing around with menubar# my $VERSION = 3.1;# build_menubar();# sub build_menubar { # my $MW = MainWindow - > new;## init;## MainLoop;### Create the menubar and File and Quit menubuttons.Note## that the c +ascade 's menu widget is automatically created. ## my $menubar = $MW - > Menu;# $MW - > configure(-menu => $menubar);# my $file = $menubar - > cascade(-label => '~File');# my $help = $menubar - > cascade(-label => '~Help', -tearoff => 0); ## Create the menuitems for each menu.First, the File menu item + .##$file - > command(-la +bel => "Quit", -command => \ & fini);### Finally, the Help menuitems.##$help - > command(-label => 'Version +');# $help - > separator;# $help - > command(-label => 'About');## my $ver_dialog = $MW - > Dialog(-title => 'frog Version', #-text = +> "frog\n\nVersion $VERSIO + N ", # - buttons => ['OK'], #-bitmap => +'info');# my $about_dialog = $MW - > Dialog(-title => 'About frog', #-text = +> 'About frog', #-buttons => ['OK']);# my $menu = $help - > cget('-menu');# $menu - > entryconfigure('Version', -command => [$ver_dialog => ' ++ Show ']); # $menu - > entryconfigure('About', -command => [$about_ +dialog => ' + Show ']); ## $menubar;# return the menubar## }# end build_menubar my $frame_border_top = $mw - > Frame(-relief => "f +lat"); my $welcome_label = $frame_border_top - > Label(-text => $frametext); my $frame_border_bottom = $mw - > Frame(-relief => + "flat"); my $welcome_label_bottom = $frame_border_bottom - > Label(-text => "$progress +update\n") - > pack(+ -side => 'right', -anchor => 'n');# printf("%-2 +s", "\n"); # add extra buttons if version# is > 1 # create input boxes my $e = $mw - > Entry(-textvariable => \my $cityty +ped) - > tooltip("enter sea + rch term1 "); my $ea = $mw - > Entry(-textvariable => \my $c +itytyped) - > tooltip("enter se + arch term1 "); my $e0 = $mw - > Entry(-textvariable => \m +y $keywordtyped) - > tooltip("enter + search term2 ")->pack(-side=>'l +eft', -anchor=>'n'); my $e0a = $mw - > Entry(-textvariable +=> \my $keywordtyped) - > tooltip("ente + r search term2 ")->pack(-si +de=>'left', -anchor=>'n'); my $e1 = $mw - > Entry(-textvariab +le => \my $parsetyped) - > tooltip("enter p + arse word1 ")->pack(-si +de=>'left', -anchor=>'n'); my $e1a = $mw - > Entry(-textv +ariable => \my $parsetyped) - > tooltip("enter + parse word2 ")->pac +k(-side=>'left', -anchor=>'n'); my $inputcitytext = $mw - +> Label(-text => "Type in search term(s) 1:" + ); my $inputkwtext = $ +mw - > Label(-text => "Type in search term(s) 2:"); my $inputparsetex +t = $mw - > Label(-text => "Type in parse words"); # my $tool_bar = $mw - > T +oolBar(-text => "File"); # Geometry Management $frame_border_top - > grid +(-row => 1, -column => 6, -columnspan => 1); $welcome_label - > grid( +-row => 1, -column => 1, -columnspan => 2); $e - > grid(-row => 2, -co +lumn => 6); $ea - > grid(-row => 2, -column => 7); $e0 - > grid(-row => 3, -c +olumn => 6); $e0a - > grid(-row => 3, -column => 7); $e1 - > grid(-row => 4, -c +olumn => 6); $e1a - > grid(-row => 4, -column => 7); $inputcitytext - > grid(-r +ow => 2, -column => 4); $inputkwtext - > grid(-row => 3, -column => 4 +); $inputparsetext - > grid(-row => 4, -column => 4); # messing with checkbutton +s, comboboc, listbox # my $CB - > set(-textvari +able => \my $combobox, -value => "Bing");# $CB - > get path(-textvari +able => \$combobox);# $CB - > configure(-values => "USA Canada Austra +lia")# print "combobox= $combobox \n";# $CB - > bind("<<ComboboxSelec +ted>>", { scriptCombo() });# my $CB = $mw - > radi +obutton(-text => "Use Metric", -command => { metric + Changed() }, #-variable => \my $ +measuresystem, -onvalue => "metric", -offvalue => +"imperial"); my $CB = $mw - > ComboBox( +-textvariable => \my $combobox, -values => "Filter1 + Filter2 Filter3 + All ")->pack(-side=>'left', -anchor=>'n'); $CB - > bind("<<Combob +oxSelected>>", { scriptCombo() }); $CB - > grid(-row +=> 8, -column => 1, -columnspan => 1);# $CB - > cget(-values); $CB - +> cget(-command); $CB - > configure; my $lbox = $mw - > Lis +tBox(-height => 5); $lbox - > bind("<<ListboxSelect>>", sub { scriptCombo() }); $lbox - > bind("<D +ouble-1>", sub { scriptCombo() }); $mw - > bind("<Ret +urn>", sub { scriptCombo() }); $lbox - > grid(-ro +w => 8, -column => 2, -columnspan => 1); # my $rbutton = $mw - +> CheckButton(-height => 5);# $rbutton - > bind("<<ListboxSelect>>", +sub { scriptCombo() });# $rbutton - > grid +(-row => 8, -column => 3, -columnspan => 1); sub scriptCombo { print "hello"; print "combobox= $ +combobox \n"; } # print "combobox= $comb +obox \n"; # $CB - > bind("<<Comb +oboxSelected>>", { scriptCombo() });# my $CB = $mw - > +radiobutton(-text => "Use Metric", -command => { metric + Changed() }, #-variable => \my $ +measuresystem, -onvalue => "metric", -offva + lue => "imperial"); my $move_button3 = $mw + - > Button(-text => "Run", -command => \ & CallScript); $move_button +3 - > grid(-row => 5, -column => $runcolumn, -columnspan => +1); # if version is not > 1 +skip button geometry # messing with checkbu +tton if ($version == 2) { show_buttons() }; sub show_buttons { print "in if loop" +; my $select_input_f +ile_label = $mw - > Label(-text => "Select searcht + erm1 file: " ); my $select +_input_file_button = $mw - > Bu +tton(-text => "Browse", -command => \ & open_file); my $move_b +utton = $mw - > Button(-text => "Move File", -command => \ & push_but +ton); my $select +_input_file_label2 = $mw - > Label(-text => "Select search + term2 fi +le: " ); my $se +lect_input_file_button2 = $mw - +> Button(-text => "Browse", -command => \ & open_file); my $mo +ve_button0 = $mw - > Button(-text => "Move File", -command => \ & pus +h_button) - > pack(+ -side => 'left', -anchor => 'n'); my $mo +ve_button1 = $mw - > Button(-text => "Move File", -command => \ & pus +h_button); my $mo +ve_button2 = $mw - > Button(-text => "Move File", -command => \ & pus +h_button); my $se +lect_input_file_label3 = $mw - > Label(-text => "Select parse + file +: " ); my + $select_input_file_button3 = $m +w - > Button(-text => "Browse", -command => \ & open_file); $s +elect_input_file_label - > grid(-row => 2, -column => 1); $select_inp +ut_file_button - > grid(-row => 2, -column => 2); $s +elect_input_file_label2 - > grid(-row => 3, -column => 1); $select_in +put_file_button2 - > grid(-row => 3, -column => 2); $s +elect_input_file_label3 - > grid(-row => 4, -column => 1); $select_in +put_file_button3 - > grid(-row => 4, -column => 2); $m +ove_button0 - > grid(-row => 2, -column => 3, -columnspan => 1); $m +ove_button1 - > grid(-row => 3, -column => 3, -columnspan => 1); $mov +e_button2 - > grid(-row => 4, -column => 3, -columnspan => 1);# print + "runcolumn = $runcolumn\n";# $move_button3 - > grid(-row => 5, -colu +mn => $runcolumn, -columnspan => + +1); } $frame +_border_bottom - > grid(-row => 6, -column => 3, -columnspan => 6 + ) +; $welcome_label_bottom - > grid(-row => 6, -column => 3, -columnspan + => 6 + ); # addi +ng progress labels $frame_border_bottom = $mw - > Frame(-relief => "f +lat"); $welcome_label_bottom = $frame +_border_bottom - > Label(-text => $searchingtext); $frame_border_bott +om - > grid(-row => 7, -column => 3, -columnspan = + > 6); $welcome_l +abel_bottom - > grid(-row => 7, -column => 3, -columnspan += > 6); $frame +_border_bottom = $mw - > Frame(-relief => "flat"); $welcome_label_bot +tom = $frame +_border_bottom - > Label(-text => $extractinglinkstext); $frame_borde +r_bottom - > grid(-row => 8, -column => 3, -columnspan = + > 6); $wel +come_label_bottom - > grid(-row => 8, -column => 3, -columnspan += > +6); $frame +_border_bottom = $mw - > Frame(-relief => "flat"); $welcome_label_bot +tom = $frame +_border_bottom - > Label(-text => $searchingwithaddlinkste + xt); $fr +ame_border_bottom - > grid(-row => 9, -column => 3, -columnsp + an => + 6); $welcome_label_bottom - > grid(-row => 9, -column => 3, -columns + + pan => 6); $frame +_border_bottom = $mw - > Frame(-relief => "flat"); $welcome_label_bot +tom = $frame +_border_bottom - > Label(-text => $cleaninguptext); $frame_border_bot +tom - > grid(-row => 10, -column => 3, -columns + pan => 6); $welcome +_label_bottom - > grid(-row => 10, -column => 3, -column + span => 6) +; $frame +_border_bottom = $mw - > Frame(-relief => "flat"); $welcome_label_bot +tom = $frame +_border_bottom - > Label(-text => $reformhtmltext); $frame_border_bot +tom - > grid(-row => 11, -column => 3, -col + umnspan => 6); $welcome +_label_bottom - > grid(-row => 11, -column => 3, -col + umnspan => 6) +; $frame +_border_bottom = $mw - > Frame(-relief => "flat"); $welcome_label_bot +tom = $frame +_border_bottom - > Label(-text => $excelfiletext) + ; $frame_border_b +ottom - > grid(-row => 12, -column => 3, + -columnspan => 6); $welcom +e_label_bottom - > grid(-row => 12, -column => 3, + -columnspan => 6) +;

As you can see I've commented out lot's of non working code I'm trying to get working. It's a work in progress so I know the formatting, etc. is ugly. Any guidance on how to get it working is greatly appreciated. Even a simply guy that demonstrates some of these working would go a really, really long way for me. Thanks.