The getOpenFile method in Tk will create a native-feel file selector dialog.
You can specify the default extension (in your case *.log) and then let the
user pick it from the directory.

Hope this is useful,

Mark Harris

use Tk;
use Tk::Dialog;

$main::mw = MainWindow->new;
$main::mw->title("Load log file");

$main::mw->Button(-text => 'Load log file',
                -command => sub {

                    my $file = $main::mw->getOpenFile(-title => "Select log
file:",
                                                      -defaultextension =>
'.log',
                                                      -filetypes => [['Log
file', '.log'],
                                                                     ['All
files', '*']]);

                    
                    
                    open INFILE, $file or do {
                        my $invalidFileDialog = $mw->DialogBox(-title =>
"Error",
        
-default_button => 'Ok',
                                                               -buttons =>
["Ok"]);
                        my $errorLabel = $invalidFileDialog
                            ->add('Label', -text => "Unable to open file
$file",
                                  -wraplength => 400)->pack();
                        
                        $invalidFileDialog->Show;
                        return;
                    };

                    # parse the file here
                    #
                    #

                    
                })->pack;

$main::mw->MainLoop;




-----Original Message-----
From: Mike Singleton [mailto:[EMAIL PROTECTED]]
Sent: 10 September 2002 13:34
To: [EMAIL PROTECTED]
Subject: gui experts...


How would I make a GUI perhaps using the code below to enable the end user
to select a file from a drop down list and have it then subsequently parse
it? Thanks.
 
== Start ==
use strict;
my @files = glob('3D*.log');
foreach(@files){
  open(INFILE,$_) || die "Could not open file $_!  $!";
while (<@files>) {
        my @files = split /\s+/, $_, 9;
        print join ',', @files;
}

}
==== End =====


===
Mike Singleton 
Network Analyst
(253) 272-1916  x1259
(253) 405-1968 (cellular)
[EMAIL PROTECTED]

DaVita Inc.
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
This message contains confidential and potentially legally privileged
information solely for its intended recipients and others may not
distribute, copy or use it. If you have received this communication in
error, please tell us by return email and delete it, and any copies of it.
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to