Hi,
I'm trying to make the user select the directory he wants to save files in using the chooseDirectory method. The problem I have is that I want the user to choose the directory once and it should be set for the next time he opens the program again. I can't seem to set the user's input as default for the program. Here is my code:
#!/usr/bin/perl
use Tk;
use Tk::JPEG;
use Tk::Dialog;
my $mw = MainWindow->new;
my $c = $mw->Canvas(
-tile => $tile,
qw/-width 1500 -height 750/);
$c->pack(-side => 'left');
$path = $c->Label(-text => "Default Path For Saving Input Files",
-font => 'Garamond 10 bold') ->place(-relx => 0.23, -rely =>
+ 0.4);
$path_text = $c->Entry(-textvariable => \$def_path,
-width => 50)->place(-relx => 0.4, -rely => 0.4);
$path_button = $c->Button(-text => "Browse",
-font => 'Garamond 8 bold',
-width => 5,
-command => \&browse)->place(-relx => 0.65, -rely => 0.4);
MainLoop;
sub browse {
$def_path = $path_button->chooseDirectory(-title => 'Select direc
+tory',
-initialdir => '.',
-mustexist => 1);
}
Any Suggestions?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.