1Tree(3)               User Contributed Perl Documentation              Tree(3)
2
3
4

NAME

6       Tk::Tree - Create and manipulate Tree widgets
7

SYNOPSIS

9           use Tk::Tree;
10
11           $tree = $parent->Tree(?options?);
12

SUPER-CLASS

14       The Tree class is derived from the HList class and inherits all the
15       methods, options and subwidgets of its super-class.  A Tree widget is
16       not scrolled by default.
17

STANDARD OPTIONS

19       Tree supports all the standard options of an HList widget.  See
20       Tk::options for details on the standard options.
21

WIDGET-SPECIFIC OPTIONS

23       Name:          browseCmd
24       Class:         BrowseCmd
25       Switch:        -browsecmd
26           Specifies a callback to call whenever the user browses on an entry
27           (usually by single-clicking on the entry). The callback is called
28           with one argument, the pathname of the entry.
29
30       Name:          closeCmd
31       Class:         CloseCmd
32       Switch:        -closecmd
33           Specifies a callback to call whenever an entry needs to be closed
34           (See "BINDINGS" below). This method is called with one argument,
35           the pathname of the entry. This method should perform appropriate
36           actions to close the specified entry. If the -closecmd option is
37           not specified, the default closing action is to hide all child
38           entries of the specified entry.
39
40       Name:          command
41       Class:         Command
42       Switch:        -command
43           Specifies a callback to call whenever the user activates an entry
44           (usually by double-clicking on the entry). The callback is called
45           with one argument, the pathname of the entry.
46
47       Name:          ignoreInvoke
48       Class:         IgnoreInvoke
49       Switch:        -ignoreinvoke
50           A Boolean value that specifies when a branch should be opened or
51           closed. A branch will always be opened or closed when the user
52           presses the (+) and (-) indicators. However, when the user invokes
53           a branch (by doublc-clicking or pressing <Return>), the branch will
54           be opened or closed only if -ignoreinvoke is set to false (the
55           default setting).
56
57       Name:          openCmd
58       Class:         OpenCmd
59       Switch:        -opencmd
60           Specifies a callback to call whenever an entry needs to be opened
61           (See "BINDINGS" below). This method is called with one argument,
62           the pathname of the entry. This method should perform appropriate
63           actions to open the specified entry. If the -opencmd option is not
64           specified, the default opening action is to show all the child
65           entries of the specified entry.
66

DESCRIPTION

68       The Tree method creates a new window and makes it into a Tree widget
69       and return a reference to it.  Additional options, described above, may
70       be specified on the command line or in the option database to configure
71       aspects of the Tree widget such as its cursor and relief.
72
73       The Tree widget can be used to display hierarchical data in a tree
74       form. The user can adjust the view of the tree by opening or closing
75       parts of the tree.
76
77       To display a static tree structure, you can add the entries into the
78       Tree widget and hide any entries as desired. Then you can call the
79       autosetmode method. This will set up the Tree widget so that it handles
80       all the open and close events automatically.  the demonstration program
81       Tixish/examples/perl-tix-tree).
82
83       The above method is not applicable if you want to maintain a dynamic
84       tree structure, i.e, you do not know all the entries in the tree and
85       you need to add or delete entries subsequently. To do this, you should
86       first create the entries in the Tree widget. Then, use the setmode
87       method to indicate the entries that can be opened or closed, and use
88       the -opencmd and -closecmd options to handle the opening and closing
89       events. (Please see the demonstration program
90       Tixish/examples/perl-tix-dyntree).
91
92       Use either
93
94           $parent->Scrolled('Tree', ... );
95
96       or
97
98           $parent->ScrlTree( ... );
99
100       to create a scrolled Tree. See Tk::Scrolled for details.
101

WIDGET METHODS

103       The Tree method creates a widget object.  This object supports the
104       configure and cget methods described in Tk::options which can be used
105       to enquire and modify the options described above.  The widget also
106       inherits all the methods provided by the generic Tk::Widget class.
107
108       The following additional methods are available for Tree widgets:
109
110       $tree->add_pathimage(treeRegExp [, openImg, closeImg])
111           This method defines images for a given path (images must be in xpm
112           format). The path can be determined by a simplified regular
113           expression. There are just three metasymbols:
114
115           ^   at the beginning of the "treeRegExp" same as in Perl regular
116               expressions
117
118           *   anything
119
120           $   at the end of the "TreeRegExp", the same as in Perl regular
121               expressions
122
123           Examples:
124
125             $tree->add_pathimage('^root','openfolder','folder');
126
127           matches "root", "root.foo", "root.bar", but not "foo.root"
128
129             $tree->add_pathimage('root.*.class','openfolder','folder');
130
131           matches all paths containing "root.<anything>.class", but not
132           "root.<anything>.<anything>.class" "*" is one part of the path. If
133           you want to use a wildcard for two steps, you have to use "*.*".
134
135             $tree->add_pathimage('class$','openfolder','folder');
136
137           This matches all path with "class" at the end.
138
139       $tree->autosetmode
140           This method calls the setmode method for all the entries in this
141           Tree widget: if an entry has no child entries, its mode is set to
142           none. Otherwise, if the entry has any hidden child entries, its
143           mode is set to open; otherwise its mode is set to close.
144
145       $tree->child_entries([$path][,$depth])
146           This method returns in list context an array that contains all
147           pathnames of subentries within the given path. In scalar context it
148           returns the number of subentries in the given path.
149
150             Example:
151               root
152                | foo
153                | bar
154                |  | bar1
155                |  | bar2
156
157             my @childentries = $tree->child_entries('root.bar');
158             # returns (root.bar.bar1, root.bar.bar2)
159
160             my $nr_of_subentries = $tree->child_entries('root',2);
161             # returns 4
162
163           If $path is omitted, all it is assumed, that the entry above 'root'
164           is meant. $depth defines the numbers of levels.
165
166       $tree->close(entryPath)
167           Close the entry given by entryPath if its mode is close.
168
169       $tree->getmode(entryPath)
170           Returns the current mode of the entry given by entryPath.
171
172       $tree->open(entryPath)
173           Open the entry given by entryPath if its mode is open.
174
175       $tree->setmode(entryPath, mode)
176           This method is used to indicate whether the entry given by
177           entryPath has children entries and whether the children are
178           visible. mode must be one of open, close or none. If mode is set to
179           open, a (+) indicator is drawn next to the entry. If mode is set to
180           close, a (-) indicator is drawn next to the entry. If mode is set
181           to none, no indicators will be drawn for this entry. The default
182           mode is none. The open mode indicates the entry has hidden children
183           and this entry can be opened by the user. The close mode indicates
184           that all the children of the entry are now visible and the entry
185           can be closed by the user.
186

BINDINGS

188       The basic mouse and keyboard bindings of the Tree widget are the same
189       as the bindings of the HList widget.  In addition, the entries can be
190       opened or closed under the following conditions:
191
192       [1] If the mode of the entry is open, it can be opened by clicking on
193           its (+) indicator.
194
195       [2] If the mode of the entry is close, it can be closed by clicking on
196           its (-) indicator.
197

SEE ALSO

199       Tk::HList
200

AUTHOR

202       Perl/TK version by Chris Dean <ctdean@cogit.com>.  Original Tcl/Tix
203       version by Ioi Kim Lam.
204
205       Additions by Renee Baecker <module@renee-baecker.de>
206

ACKNOWLEDGEMENTS

208       Thanks to Achim Bohnet <ach@mpe.mpg.de> for all his help.
209
210
211
212perl v5.30.0                      2019-07-26                           Tree(3)
Impressum