Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do I open a file dialog box

Posted on 2009-05-12
3
Medium Priority
?
331 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 2000 total points
ID: 24377313
you just need to click on the 'Kick Me' button...
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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

824 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