Hi monks,

I'm using the next code
my $top = MainWindow -> new(title=>"Choose Directory(must be a pro +ject Directory)"); $top->withdraw; my $t = $top->Toplevel; # my $top = new MainWindow; # $top->withdraw; # my $t = $top->Toplevel; $t->title("Choose Directory(must be a project Directory)"); # my $t = $top->Frame; my $ok = 0; # flag: "1" means OK, "-1" means cancelled # Create Frame widget before the DirTree widget, so it's always vi +sible # if the window gets resized. my $f = $t->Frame->pack(-fill => "x", -side => "bottom"); #my $curr_dir = Cwd::cwd(); my $curr_dir = 'k:/'; my $d; $d = $t->Scrolled('DirTree', -scrollbars => 'osoe', -width => 60, -height => 20, -selectmode => 'browse', -exportselection => 1, -browsecmd => sub { $curr_dir = shift }, # With this version of -command a double-click will # select the directory #-command => sub { $ok = 1 }, # With this version of -command a double-click will # open a directory. Selection is only possible with # the Ok button. -command => sub { $d->opencmd($_[0]) } )->pack(-fill => "both", -expand => 1); # Set the initial directory $d->chdir($curr_dir); $d->chdir('c:/'); $f->Button(-text => 'Ok', -command => sub{$ok = 1} )->pack(-side => 'left', qw/-padx +50 -ipadx 10/); $f->Button(-text => 'Cancel', -command => sub {$ok = -1})->pack(-side => 'right',qw/-pady + 3 -padx 50/); $top->bind('<Key-Escape>',[$top=>'destroy']); $t->bind('<Key-Escape>',sub{$ok=3}); $f->bind('<Key-Escape>',sub{$ok=3}); # You probably want to set a grab. See the Tk::FBox source code fo +r # more information (search for grabCurrent, waitVariable and # grabRelease). $f->waitVariable(\$ok); if ($ok == 1) { warn "The resulting directory is: $curr_dir\n"; }#elsif($ok == -1){exit(0);} else{print"No directory chosen.\n";goto TOP;} $top => 'destroy'; return ($curr_dir);


I want to close the window after choosing the directory
in order to use this window again and not have more then one window open at a time

Another thing I want to do is to present all drives on the computer as options in the tree

I appreciate the help,
Thaks in advace,
Moked

In reply to operation on DIRTree by moked

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.