Solved

How do I open a file dialog box

Posted on 2009-05-12
3
305 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
  • 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

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.…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

778 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