#!/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();
In reply to Re: Multiple file selection in Tk dialogbox
by rbc
in thread Multiple file selection in Tk dialogbox
by Pavel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |