perlynewby has asked for the wisdom of the Perl Monks concerning the following question:
Hello PerlMonks,
I am back at Perl Tk again. I'm creating an order like logfile from MENU.txt; however, I came to an abrupt end because I do not know how to do many the following - it's not shocking for me to come to an abrupt end after failing and trying new stuff to make it work. Anyhow, I am creating this GUI to get some experience in handling some tasks below. If you have an idea how to improve please write comments so I can follow the code; I learn by trying new stuff and comments help me a lot ;-)
Formatting challenges ( it tried and just could get it; I haven't giving up on formatting yet)
1) How to make checkbox stay lined up one below the other regardless of the length of the text string?
1a) How to format Checkbox text to wrap around the next line below without moving around the checkbox?
2) How to make left frame to meet right with a small line going down separation both?
Some additional functionality ; these I need help because I am not sure how to do any of these
3) After first checkbox selected, how to add an additional pop up check box?
4) How to add a file browser button to left size when selecting checks.txt file and select file from a menu and save/show the selection on the GUI? my file browser sort of works but requires a lot of work
5) How to add a button/code (side => right) to email recipients in a list of the output or pointer to output from the GUI
Special frame to add comments below checkboxes && save it to log file
6) How to add frame (frm_frame) on right side below checkboxes to allow user to add comments with a title=> "Special Notes"? then save it all to a logfile
#!/usr/bin/perl # This program will select items via checkbox # This program will then save these selections to a log file it create +s # This is figuring out how frames work, checkbox, radiobutton, file br +owser. # Validates input -> later # March 20 2022 use strict; use warnings; use Tk; use Tk::Checkbutton; use Tk::Radiobutton; use Tk::Pane; use Tk::BrowseEntry; #my $file = "expenses"; #add validation if file exists. #-----------------FH open/close------------------# #open Log file here ....I think it is here to get tail -f of final out +put #---------------Declare vars---------------------# my ($var1,$var2,$var3,$var4); my $current_file=(); #--------------------Frames geometries-----------# my $mw = MainWindow->new(); $mw->geometry("1000x500"); $mw->title("Check using GUI"); #-----------------Frames-----------------------# my $main_frame = $mw->Frame()->pack( -side => 'top', - fill => 'x' ); my $top_frame = $mw->Frame( -background => 'light green' )->pack( -side => 'top', +-fill => 'x' ); my $left_frame = $mw->Frame( -background => 'gray' , -width => 45)->pack( -side => +'left', -fill => 'y' ); my $right_frame = $mw->Frame( -background => 'white', -foreground => 'white' )->pack +( -side => 'right', -fill => 'y' ); # This is the Special Notes area for user to add text my $frm_frame = $mw->Frame( -background => 'light blue' )->pack( -side => 'right' +, -fill => 'x'); #---------------TOP Widget-------------------------# $top_frame->Label( -text => "Bank statement Checks", -background => 'light green' ) ->pack( -side => 'top' ); #------------LEFT wedget-------------------------# $left_frame->Label( -text => 'Checks Selection', -background => 'white', -width => 45 )->pack( -side => 'top', -fill => 'both' ); #-----------adding file browser to chose the Checks.txt file------- +------# our $mw = MainWindow->new; $mw->configure(-title=> "File Browser"); my $menu_f = $mw->Frame()->pack(-side=>'top',-fill=>'x'); my $menu_file = $menu_f->Menubutton (-text=>'Select File Browser',-tearoff=>'false') ->pack(-side=>'left'); $menu_file->command(-label=>'...', -command=> \&open_txt); # This opens txt files where ch +ecks written with amounts # GRRR! -command isn't working for me h +ere, where did I go wrong??!!! #------------Right checkButtons------------------------# my $right_text; my ($check1, $check2, $check3, $check4); $check1= $right_frame->Checkbutton( -text => "Confirm check was used for home to school travel, books, + meals", -onvalue => 1, -background => 'white', -variable => \$var1, )->pack(); $check2= $right_frame->Checkbutton( -text => "Discuss check usage are only for school expenditures", -onvalue => 1, -background => 'white', -variable => \$var2, )->pack(); $check3= $right_frame->Checkbutton( -text => "Archive the checks that are to come visit home segregate +d from other travel from home to school", -onvalue => 1, -background => 'white', -variable => \$var3, )->pack(); #### HOW to add another popup Checkbox when $check3 is selecte +d; is it Parents HOME or Grand Parent's home if ($var3 == 1 ){ ## how to get logic to recognized $check3 is + selected?? then opo up with new additional checkbox selection is it +== 1 or eq true??? my $check20= my $frm_frame= $mw ->Frame(); my $check_travel = my $frm_name ->Label ( -text => "Check from sch +ool to home travel"); my $ent = $frm_name -> Entry(); # This is not right either!! + I've tried many things unsuccessful ...Need to ask for help! } $check4= $right_frame->Checkbutton( -text => "Confirm there were no Check errors/corrupted files durin +g audit", -onvalue => 1, -background => 'white', -variable => \$var4, )->pack(); #---------- Exit Button -----------------------# my $left_text; my $exitButton= $left_frame->Button( -text => "Done" , -command => sub { exit } )->pack( -side => 'bottom' , -fill =>'both', -expand =>1); #------------Enter button && save to Log file-------------------# my $executeButton = $left_frame->Button( -text => "Enter" , -command => sub { Echo_to_Log($left_text);} )->pack( -side => 'bottom', -fill => 'both' , -expand =>1); # C +aputure ALL of checkboxes and Path to files, # shoudl it be "left_text" && $ri +ght_text(create if so)?How to do this?jj #------------format Enter and Done buttons ----# $left_text = $left_frame->Text( -height => 30, -width => 30 , )->pack( -side => 'left' , -fill => 'both', -expand =>1 ); #--------------Format right buttons -----# $right_text= $right_frame->Text( -height => 30, -width => 70, )->pack( -side => 'right' , -fill => 'both', -expand =>1 ); MainLoop; sub open_txt { my @types = (["txt files", [qw/.txt /]], ["All files", '*'], ); $current_file= $mw->getOpenFile(-filetypes => \@types); print "$current_file\n"; } sub Echo_to_log { # let's put all the selections into a Logfile. I am not sure if a -t +ail -f will work here because I want only selected windows }
|
|---|