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, the DirTree widget 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 -dircmd option. πŸ™ˆ
  • -directory β€” Name: directory, Class: Directory, Alias: -value. Specifies the name of the current directory to be displayed in the DirTree widget. πŸ“πŸ’–

🌈 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:

  • OpenCmd
  • Populate
  • add_to_tree
  • dirnames
  • fullpath
  • has_subdir
  • opencmd
  • set_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::Tree
  • Tk::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