Tk::DirSelect(3pm)

πŸ“¦
version 1.12 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

✨ NAME ✨

Tk::DirSelect β€” a cross-platform directory selection widget, and yes bestie it's giving main character energy in the file-picker department πŸ’…


🌸 SYNOPSIS 🌸

use Tk::DirSelect;
my $ds  = $mw->DirSelect();
my $dir = $ds->Show();

that's it. that's the whole vibe. four lines and you're picking directories πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this module gives you a cross-platform directory selection widget. and when it says cross-platform it MEANS it β€” on systems running Microsoft Windows that includes selection of local and mapped network drives, no cap. ✨

there's also a context menu β€” that's right-click or <Button3> for the mouse girlies β€” and it lets you create, rename, and delete directories while you're browsing. living your best file-manager life fr fr πŸ—‚οΈ

Note: Perl/Tk 804 added the chooseDirectory method which uses native system dialogs where available (i.e. Windows). If you want a native feel for your program, you probably want to use that method instead β€” possibly using this module as a fallback for systems with older versions of Tk installed.

so if you want the ✨native✨ aesthetic, chooseDirectory is right there. but if someone out there is running ancient Tk? this module is your safe little fallback babe 🫢


πŸ‘‘ METHODS πŸ‘‘

πŸ’« "DirSelect([-title => 'title'], [options])"

Constructs a new DirSelect widget as a child of the invoking object β€” usually a MainWindow, that's the typical situaysh.

  • The title for the widget can be set by specifying -title => 'Title'. cute, customizable, iconic πŸ’–
  • Any other options provided will be passed through to the DirTree widget that displays directories, so be sure they're appropriate (e.g. -width). lowkey important: they go straight through, so if you pass something weird, DirTree gets it. no take-backs πŸ’€

🌈 "Show([directory], [options])"

Displays the DirSelect widget and returns the directory the user selected β€” or undef if the operation is canceled. (yes, cancel exists. sometimes the user just says no πŸ™ˆ)

All arguments are optional, periodt. here's the tea:

  1. The first argument (if defined) is the initial directory to display.
  2. The default is to display the current working directory.
  3. Any additional options are passed through to the Popup() method.

and because of that pass-through, you can do something like this:

$ds->Show(undef, -popover => $mw);

which β€” hold on, this is the good part β€” centers the dialog over your application. obsessed. ✨


🧚 DEPENDENCIES 🧚

  • Perl 5.004
  • Tk 800
  • Win32API::File (under Microsoft Windows only)

three whole things. she's low maintenance bestie πŸ“


Copyright 2000-2001 Kristi Thompson <kristi@kristi.ca> Copyright 2002-2005,2010 Michael Carman <mjcarman@cpan.org>

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.


aaaand that's the whole page πŸŽ€ this was perl v5.36.0, dated 2022-10-14, a certified User Contributed Perl Documentation classic β€” go pick some directories, you've got this bestie πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from