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.

In reply to Re: Multiple file selection in Tk dialogbox by rbc
in thread Multiple file selection in Tk dialogbox by Pavel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.