Solved

How do I open a file dialog box

Posted on 2009-05-12
3
324 Views
Last Modified: 2012-05-06
How do I open a file dialog box in perl i have look every where
then read the file i selected
0
Comment
Question by:1030071002
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:1030071002
ID: 24374690
I need to do this TKX i need some help

 my($LoadDialog) = $main->FileDialog(-Title =>'File Dialogbox', -Create => 0);
 $LoadDialog->configure(-FPat => '*txt', -ShowAll => 'YES');
$fname = $LoadDialog->Show(-Horiz => $Horiz);
0
 
LVL 1

Expert Comment

by:berseken
ID: 24377304
This works:

#!/usr/bin/perl

use Tk;
use Tk::FileDialog;
use strict;

my $main = MainWindow->new;

my $Horiz = 1;

my($LoadDialog) = $main->FileDialog(-Title =>'File Dialogbox', -Create => 0);

$LoadDialog->configure(-FPat => '*txt', -ShowAll => 'YES');

my $fname;

$main->Entry(-textvariable => \$fname)
        ->pack(-expand => 1,
               -fill => 'x');

$main->Button(-text => 'Kick me!',
             -command => sub {
                 $fname = $LoadDialog->Show(-Horiz => $Horiz);
                 if (!defined($fname)) {
                     $fname = "Fine,Cancel, but no Chdir anymore!!!";
                     $LoadDialog->configure(-Chdir =>'NO');
                 }
             })
       ->pack(-expand => 1,
              -fill => 'x');

MainLoop;

print "Exit Stage right!\n";

exit;
0
 
LVL 1

Accepted Solution

by:
berseken earned 500 total points
ID: 24377313
you just need to click on the 'Kick Me' button...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question