Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Open a file using Tkx package

by Gangabass (Priest)
on Nov 19, 2011 at 13:28 UTC ( #938971=note: print w/ replies, xml ) Need Help??


in reply to Open a file using Tkx package

my $btn_source_file = $mw->new_tk__button( -text => "Choose...", -command => sub { get_source_filename(); } ); sub get_source_filename { $source_file = Tkx::tk___getOpenFile(); }


Comment on Re: Open a file using Tkx package
Download Code
Re^2: Open a file using Tkx package
by bugged123 (Initiate) on Nov 21, 2011 at 18:41 UTC
    Hi I tried that I am still not able to run it. Here's what I did. I am using active perl 5.14 Thanks
    use strict; use Tkx; use constant TRUE => 1; use constant FALSE => 0; #Defining UI components. our $iteration = 0; our $mw = Tkx::widget->new("."); $mw->g_wm_title("G7 Fiery."); $mw->g_wm_minsize(300, 300); #our $filename = Tkx::tk__getOpenFile(); our $frame = $mw->new_ttk__frame( -padding => "3 3 12 12"); our $label1 = $mw->new_ttk__label(-text => "Iteration"); our $label2 = $mw->new_ttk__label(-textvariable => \$iteration); our $cb = $frame->new_ttk__button(-text => "Calculate", -command => su +b {calculate();}); our $cb1 = $frame->new_ttk__button(-text => "open", -command => sub {g +et_source_filename();}); #Placing objects . $frame->g_grid(-column => 0, -row => 0, -sticky => "nwes"); $cb->g_grid(-column => 3, -row => 3, -sticky => "w"); $cb1->g_grid(-column => 2, -row => 3, -sticky => "e"); $label1->g_grid(-column => 2, -row => 1, -sticky => "w"); $label2->g_grid(-column => 3, -row => 1, -sticky => "w"); $mw->g_grid_columnconfigure(0, -weight => 1); $mw->g_grid_rowconfigure(0, -weight => 1); foreach (Tkx::SplitList($frame->g_winfo_children)) { Tkx::grid_configure($_, -padx => 5, -pady => 5); } sub calculate() { $iteration ++; } sub get_source_filename { $source_file = Tkx::tk___getOpenFile(); } Tkx::MainLoop;

      $ perl junk Global symbol "$source_file" requires explicit package name at junk li +ne 35. Execution of junk aborted due to compilation errors.

      It works for me every time

      $ perl -MTkx -e " print Tkx::tk___getOpenFile() " C:/dev/temp/junk
        Thanks !!! That helped a lot !! A big thank you...
        Thank you !!! This helped a lot. Declared the $filename as our and the problem got solved.
      Uncommenting the line $source_file = Tkx::tk___getOpenFile(); and it runs.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://938971]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2014-07-24 04:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (157 votes), past polls