Tk::DirSelect(3pm)
β¨ 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:
- The first argument (if defined) is the initial directory to display.
- The default is to display the current working directory.
- 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 π
π LICENSE AND COPYRIGHT π
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
- ubuntu noble: libtk-dirselect-perl 1.12-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtk-dirselect-perl 1.12-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtk-dirselect-perl 1.12-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms