in reply to Multiple file selection in Tk dialogbox

OOPS! I mean ...

You can try something like this ...

#!/usr/bin/perl -w use strict; use Tk; use Tk qw(exit); use Tk::DialogBox; my $FILE1 = "Please select a file"; my $FILE2 = "Please select a file"; my $top = MainWindow->new(); my $thebutton = $top->Button( -relief => "groove", -text => "Click Me ", -command => \&thebuttonCallback)->pack(); sub selectFile1Callback { my $userSelectedFile = $top->getOpenFile( -defaultextension => ".ctl", -filetypes => [ ['Control Files', '.ctl'], ['All Files', '*'] ], -initialdir => "C:\\TEMP", -initialfile => "Junk.txt", -title => "Select file 1" ); if ($userSelectedFile) { $FILE1 = $userSelectedFile; } } sub selectFile2Callback { my $userSelectedFile = $top->getOpenFile( -defaultextension => ".ctl", -filetypes => [ ['Control Files', '.ctl'], ['All Files', '*'] ], -initialdir => "C:\\TEMP", -initialfile => "Junk.txt", -title => "Select file 2" ); if ($userSelectedFile) { $FILE2 = $userSelectedFile; } } sub thebuttonCallback { my $d = $top->DialogBox( -title => "View Control File", -buttons => ["Done"] ); my $e1 = $d->add( 'Entry', -width => 60, -textvariable => \$FILE1 )->pack(); my $b1 = $d->add( 'Button', -width => 10, -text => 'File 1', -command => \&selectFile1Callback); my $e2 = $d->add( 'Entry', -width => 60, -textvariable => \$FILE2 )->pack(); my $b2 = $d->add( 'Button', -width => 10, -text => 'File 2', -command => \&selectFile2Callback); $e1->pack(); $b1->pack(); $e2->pack(); $b2->pack(); $d->Show(); } MainLoop();

Previous post left out part of the code!!!
There is a lot of room for improvement.
You only need one selectFileCalback.
Hope that helps

--
Its like a dog that can sing and dance.
It's remarkable because it can do it.
Not that it can do it well.

Replies are listed 'Best First'.
Use Updates instead of reposts
by Rex(Wrecks) (Curate) on Jan 09, 2002 at 01:51 UTC
    FYI, you can update your posts, rather than posting twice.

    "Nothing is sure but death and taxes" I say combine the two and its death to all taxes!
Re: Re: Multiple file selection in Tk dialogbox
by Pavel (Novice) on Jan 09, 2002 at 15:20 UTC
    Thanks for your help, but the getOpenFile dialog box does not allow us to select multiple objects...

    Pavel