Earlier this week I asked questions about a resizable directory selection option for Tk.
Given the answers my plan was to use dirSelect initially and then work on the more flexible dirTree example to get exactly what I wanted.
I do want to be able to give an initial directory as a starting point for the directory selection. The CPAN description says “Any other options provided will be passed through to the DirTree widget that displays directories, so be sure they're appropriate (e.g. -width)”. Therefore I thought that I can specify the directory using the –directory option as in the Perl below.
use Tk; use strict "vars"; use Tk::DirSelect; my $initial_dir = "C:\\Temp"; my $mw; $mw = MainWindow->new; my $ds = $mw->DirSelect( -directory => $initial_dir, -width => 100, -height => 25, -background => red ); my $dir = $ds->Show(); print "dir <$dir>\n"; MainLoop;
However, I got the following error message:
“Can't set -directory to `C:\Temp' for Tk::DirSelect=HASH(0x45a18a8): unknown option "-directory" at … a reference to the Configure.pm line 45”
The Perl code at this point is, I have marked the line
sub configure { my $alias = shift; shift if (@_); my ($set,$get,$widget,@args) = @$alias; if (wantarray) { my @results; eval { @results = $widget->$set(@args,@_) }; croak($@) if $@; return @results; } else { my $results; [line 45]eval { $results = $widget->$set(@args,@_) }; croak($@) if $@; return $results; } }
Should I be able to use the –directory option? If so, does this mean I have something basically wrong with my Perl Tk set up?

In reply to Tk dirSelect -options problem by merrymonk

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.