For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > April 2004 > Newbie question: Use of File Dialog









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Newbie question: Use of File Dialog
Vikram Khurana

2004-04-28, 7:58 pm

Hello,

How do I use getOpenFile or some other widget/module to open a dialog box
when I click on a browse button & the return the path of the file to a Entry
box?

I tried putting getOpenFile in the command option of the button, but the
dialog box opens as soon as the compiler gets to that line and doesn't open
up when I click on the button.

Thanks,
Vikram


-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
Marc Dashevsky

2004-04-28, 8:33 pm

At 06:13 PM 4/28/2004, Vikram Khurana wrote:
>How do I use getOpenFile or some other widget/module to open a dialog box
>when I click on a browse button & the return the path of the file to a Entry
>box?


use strict;
use Tk;

my $path;
my $mw = tkinit;
$mw->Button(
-text => 'Pick a file',
-command => sub {$path = $mw->getOpenFile},
)->pack;
$mw->Entry(-textvariable => \$path)->pack;

MainLoop;

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to majordomo@lists.stanford.edu
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com