Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Setting size of Tk chooseDirectory

by merrymonk (Hermit)
on Aug 10, 2016 at 15:34 UTC ( [id://1169509]=perlquestion: print w/replies, xml ) Need Help??

merrymonk has asked for the wisdom of the Perl Monks concerning the following question:

The pop-up shown when using chooseDirectory in Perl tk is too small for one of my users.
I had hoped that adding a –width and –height argument when using choose Directory (see below) would do what I want.
$dir_full = $mw->chooseDirectory(-width => $config_data{cfg_choosedir_ +width}, -height =>$config_data{cfg_choosedir_height} );
However this gave the error
Tk::Error: bad option "-height": must be -initialdir, -mustexist, -parent, or -title at ……….site/lib/Tk.pm line 353.

Is there any way that the size can be defined?
If not, is there any other Tk option I can use to select a directory?

Replies are listed 'Best First'.
Re: Setting size of Tk chooseDirectory
by Marshall (Canon) on Aug 11, 2016 at 00:52 UTC
    This is a bummer of a problem. I don't know of any way to re-size the chooseDirectory window. The DirSelect gizmo pays attention to -width, but not -height. However, it can be resized with the mouse. The disadvantage is that DirSelect is really ugly looking on Windows.

    I remember this problem from a long time ago. I needed to know the directory where hundreds of data files were located. Instead of asking about the directory directly, I asked the user to select one of the data files using the Tk::getOpenFile widget. That widget looks really nice on Windows and presented an easy to understand task to do. I threw away the file name and used the directory path. This "show me one of the data files", didn't confuse the users and worked out ok for me.

    Yes, this is a super kludge with a lot of limitations - like it won't work if you are asking for a directory to put results into (no files to select). I just mention this as a "hack" possibility - asking a more detailed question than you actually need.

    Sorry that I don't have an obvious, easy, "great" answer for you. I am not sure that there is one.

      :)

      The DirSelect gizmo pays attention to -width, but not -height. However, it can be resized with the mouse. The disadvantage is that DirSelect is really ugly looking on Windows.

      Its pure perl, WidgetDump shows you all the objects (children) and all their modifiable option, everything from icons to colors to fonts to heights

        It respects both width and height
        my $ds = $mw->DirSelect(qw/ -width 333333 -height 666666 -background red /);
Re: Setting size of Tk chooseDirectory
by Anonymous Monk on Aug 10, 2016 at 20:24 UTC

    No, there is no option to give chooseDirectory a size, although the dialog should be resizable, and I'd say its a bug if it isn't

    Anyway there is always Tk::DirSelect

    perl -MTk -e " tkinit->DirSelect->Show " perl -MTk -e " $ds = tkinit->DirSelect; $ds->parent->WidgetDump; $ds-> +Show "
      Sadly no 'arrows' appear at the corners which allow the pop-up to be resized.
      Do you know of any more extensive examples of DirSelect being used?
      My attempts to find these on the internet have failed.

        Sadly no 'arrows' appear at the corners which allow the pop-up to be resized.

        Yeah not on chooseDirectory , but DirSelect is resizable

        Do you know of any more extensive examples of DirSelect being used? My attempts to find these on the internet have failed.

        I don't understand the question, examples doing what?

        Its a real simple module to use

        perl -MTk -e " print tkinit->DirSelect(-width,5000 )->Show( shift ) " + D:\

        And its written in perl, so its easy to understand/modify....

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1169509]
Approved by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-24 17:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found