Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do I open a file dialog box

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

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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…
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

722 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