DirTree(3pm)
π Tk::DirTree β DirTree(3pm) π
okay bestie, listen UP π this is a page from the User Contributed Perl Documentation set, and it's all about Tk::DirTree β the widget that makes a whole directory tree pop off in your Perl/Tk app. Think folder browser energy. Main character widget. Let's get into it. π¦
β¨ NAME β¨
Tk::DirTree β create and manipulate DirTree widgets. that's it, that's the whole vibe. π
πΈ SYNOPSIS πΈ
use Tk::DirTree;
$dirtree = $parent->DirTree(?options?);
so you use it, then you build one off a $parent with ?options? if you want. slay. π«Ά
π SUPER-CLASS π
The DirTree class is derived from the Tree class, and it inherits all the methods, options and subwidgets of its super-class. no cap β everything Tree can do, DirTree can do too. generational wealth fr. π
β STANDARD OPTIONS β
Tree supports all the standard options of a Tree widget. See Tk::options for the details on the standard options. π§
π WIDGET-SPECIFIC OPTIONS π
these are the ones that are hers, the ones that make her different from a plain old Tree:
-browsecmdβ Name:browseCmd, Class:BrowseCmd. Specifies a callback to call whenever the user browses on a directory (usually by single-clicking on the name of the directory). The callback gets called with one argument: the complete pathname of the directory. πβ¨-commandβ Name:command, Class:Command. Specifies the callback to be called when the user activates on a directory (usually by double-clicking on the name of the directory). Also called with one argument: the complete pathname of the directory. πππ₯-dircmdβ Name:dircmd, Class:DirCmd. Specifies the callback to be called when a directory listing is needed for a particular directory. If you don't set this option, theDirTreewidget will by default try to read the directory as a Unix directory. But sometimes the application programmer wants to supply a special method for reading directories β for example, when he needs to list remote directories π. That's exactly when you reach for-dircmd. The callback you give it takes two arguments: the first is the name of the directory to be listed; the second is a Boolean value saying whether hidden sub-directories should be listed. And it returns a list of names of the sub-directories of that directory. Like so:
sub read_dir {
my( $dir, $showhidden ) = @_;
return( qw/DOS NORTON WINDOWS/ ) if $dir eq "C:\\";
return();
}
-showhiddenβ Name:showHidden, Class:ShowHidden. Specifies whether hidden directories should be shown. By default, a directory name starting with a period"."counts as a hidden directory. You can override that rule by supplying an alternative-dircmdoption. π-directoryβ Name:directory, Class:Directory, Alias:-value. Specifies the name of the current directory to be displayed in theDirTreewidget. ππ
π DESCRIPTION π
The DirTree constructor method creates a new window (given by the $dirtree argument) and makes it into a DirTree widget. Additional options, described above, may be specified on the command line or in the option database to configure aspects of the DirTree such as its cursor and relief. π
The DirTree widget displays a list view of a directory, its previous directories and its sub-directories. The user can choose one of the directories displayed in the list, or change to another directory. it's giving file explorer but make it cute. ποΈβ¨
π«Ά WIDGET METHODS π«Ά
The DirTree method creates a widget object. This object supports the configure and cget methods described in Tk::options, which you can use to enquire about and modify the options described above. The widget also inherits all the methods provided by the generic Tk::Widget class. π
The following additional methods are available for DirTree widgets:
$dirtree->chdir(dir)β Change the current directory to dir. that's the whole method, and honestly? iconic. πͺβ‘οΈπ
π§ OTHER METHODS π§
ngl these ones still have to be documented or made private:
OpenCmdPopulateadd_to_treedirnamesfullpathhas_subdiropencmdset_dir
π BINDINGS π
The mouse and keyboard bindings of the DirTree widget are the same as the bindings of the Tree widget. same hands, same keys, no notes. β¨οΈπ±οΈ
β KEYWORDS β
directory, tree, tix
π₯ SEE ALSO π₯
Tk::TreeTk::HList
π AUTHOR π
Perl/TK version by Chris Dean <ctdean@cogit.com>. Original Tcl/Tix version by Ioi Kim Lam.
okay that's the whole page bestie, you ate it, go build a directory tree π³π
this lil love letter to DirTree came to you via perl v5.40.1, dated 2025-04-13 β and yeah, DirTree(3pm), you already knew that. mwah. ππ
π¦ where this page comes from
- debian trixie: perl-tk 1:804.036+dfsg1-5
- ubuntu questing: perl-tk 1:804.036+dfsg1-5
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms