I'm now using strict and have declared variables globally. The application works as expected.
For completion, here's the working code:
I'd like to thank the Wisdom of the Monks for assisting with this solution.#!/usr/local/bin/perl use Tcl::Tk; use strict; # Main Window my $int = new Tcl::Tk; my $mw = $int->mainwindow; $mw->title("Move File"); my $frame_border_top = $mw -> Frame(-relief => "flat"); my $welcome_label = $frame_border_top -> Label(-text => "Welcome\n"); my $select_input_file_label = $mw -> Label(-text=>"Select initial file + for conversion:"); my $select_input_file_button = $mw -> Button(-text => "Browse", -command => \&open_file ); my $move_button = $mw -> Button(-text => "Move File", -command => \&push_button ); # Geometry Management $frame_border_top -> grid(-row=>1,-column=>1,-columnspan=>2); $welcome_label -> grid(-row=>1,-column=>1,-columnspan=>2); $select_input_file_label -> grid(-row=>2,-column=>1); $select_input_file_button -> grid(-row=>2,-column=>2); $move_button -> grid(-row=>10,-column=>1,-columnspan=>2); $int->MainLoop; # Declare global subroutine variables my $select_input_file; my $selected_file; ### All sub-routines below this point. ### # Open file dialogue sub open_file { $select_input_file = $mw-> getOpenFile(-title=>"Select File"); # These lines just to see what's going on print "Got: $select_input_file\n"; print "My current directory is: $ENV{PWD}\n"; print "Thinking of doing: mv ${select_input_file} -t /home/phillc\n"; } # Push button and move file sub push_button { $selected_file = "mv ${select_input_file} -t /home/phillc"; system($selected_file); }
In reply to Re: Tcl::Tk getOpenFile Not Working - Missing File Operand
by phillc
in thread Tcl::Tk getOpenFile Not Working - Missing File Operand
by phillc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |