Heya, fellow monks!

I've got a little problem here, and i want to hear your opinions about it:

I've got a little Tk-Application, and i want to select a directory in it.

The script shall run on other computers in my company as well, so i do not want to install further modules.

BTW: The System is Windows XP an IndigoPerl 5.6

Unfortunately Tk::FileSelect doesn't return directories, and i can't find Tk::chooseDirectory on my machine, which was recommended by some monks in the chatterbox.

So after some scrolling through the docs, i found Tk::DirTree, which looked very promising, but i cannot get the currently selected directory out of this widget, at least not in the following way:

my $currentDir = "D:/p/"; my $dirTreeFrame = $mainwin->Frame; $dirTreeFrame->pack(); my $scrolledDirTree = $dirTreeFrame->Scrolled('DirTree', -scrollbars = +> "oeos")->pack(); $scrolledDirTree->configure(-directory => $currentDir, -width => 35, -height => 35, -command=> sub {doCreate($currentDir)} +);
I found the following documentation:
...
Switch: -command
Specifies the callback to be called when the user activates on a directory (usually by double-clicking on the name of the directory). The callback is called with one argument, the complete pathname of the directory.
...

So what argument do i have to submit, and how do i get it? It's not -directory, or else the code above should work...

Thanks for your help

Elderian

Update:
I used one single line out of zentara's code, and it worked! Hooray....
Unfortunately i have to offer more than one drive, which is not easy in windows.

So i found Win32::GUI::BrowseForFolder, which seems to be just thing i always searched for! ;)

Thank you all for your help!


In reply to How do i select a directory in Tk? by Elderian

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.