How do I open a file dialog box

Posted on 2009-05-12
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
Question by:1030071002
  • 2

Author Comment

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);

Expert Comment

ID: 24377304
This works:


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');


print "Exit Stage right!\n";


Accepted Solution

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
perl script help 12 101
Port 80 requests 16 80
Perl script not writing to .csv file 6 99
perl: Cleaning meta tags using RegEX 12 43
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now