GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  TK::TREE (3)

.ds Aq ’

NAME

Tk::Tree - Create and manipulate Tree widgets

CONTENTS

SYNOPSIS

<B>use Tk::Tree;B>

$tree = $parent-><B>TreeB>(?options?);

SUPER-CLASS

The <B>TreeB> class is derived from the HList class and inherits all the methods, options and subwidgets of its super-class. A <B>TreeB> widget is not scrolled by default.

STANDARD OPTIONS

<B>TreeB> supports all the standard options of an HList widget. See Tk::options for details on the standard options.

WIDGET-SPECIFIC OPTIONS

Name:          <B>browseCmdB>
Class:         <B>BrowseCmdB>
Switch:                <B>-browsecmdB> Specifies a callback to call whenever the user browses on an entry (usually by single-clicking on the entry). The callback is called with one argument, the pathname of the entry.
Name:          <B>closeCmdB>
Class:         <B>CloseCmdB>
Switch:                <B>-closecmdB> Specifies a callback to call whenever an entry needs to be closed (See BINDINGS below). This method is called with one argument, the pathname of the entry. This method should perform appropriate actions to close the specified entry. If the <B>-closecmdB> option is not specified, the default closing action is to hide all child entries of the specified entry.
Name:          <B>commandB>
Class:         <B>CommandB>
Switch:                <B>-commandB> Specifies a callback to call whenever the user activates an entry (usually by double-clicking on the entry). The callback is called with one argument, the pathname of the entry.
Name:          <B>ignoreInvokeB>
Class:         <B>IgnoreInvokeB>
Switch:                <B>-ignoreinvokeB> A Boolean value that specifies when a branch should be opened or closed. A branch will always be opened or closed when the user presses the (+) and (-) indicators. However, when the user invokes a branch (by doublc-clicking or pressing <Return>), the branch will be opened or closed only if <B>-ignoreinvokeB> is set to false (the default setting).
Name:          <B>openCmdB>
Class:         <B>OpenCmdB>
Switch:                <B>-opencmdB> Specifies a callback to call whenever an entry needs to be opened (See BINDINGS below). This method is called with one argument, the pathname of the entry. This method should perform appropriate actions to open the specified entry. If the <B>-opencmdB> option is not specified, the default opening action is to show all the child entries of the specified entry.

DESCRIPTION

The <B>TreeB> method creates a new window and makes it into a Tree widget and return a reference to it. Additional options, described above, may be specified on the command line or in the option database to configure aspects of the Tree widget such as its cursor and relief.

The Tree widget can be used to display hierarchical data in a tree form. The user can adjust the view of the tree by opening or closing parts of the tree.

To display a static tree structure, you can add the entries into the Tree widget and hide any entries as desired. Then you can call the <B>autosetmodeB> method. This will set up the Tree widget so that it handles all the open and close events automatically. the demonstration program Tixish/examples/perl-tix-tree).

The above method is not applicable if you want to maintain a dynamic tree structure, i.e, you do not know all the entries in the tree and you need to add or delete entries subsequently. To do this, you should first create the entries in the Tree widget. Then, use the <B>setmodeB> method to indicate the entries that can be opened or closed, and use the <B>-opencmdB> and <B>-closecmdB> options to handle the opening and closing events. (Please see the demonstration program Tixish/examples/perl-tix-dyntree).

Use either

$parent-><B>ScrolledB>(<B>’Tree’B>, ... );

or

$parent-><B>ScrlTreeB>( ... );

to create a scrolled <B>TreeB>. See Tk::Scrolled for details.

WIDGET METHODS

The <B>TreeB> method creates a widget object. This object supports the <B>configureB> and <B>cgetB> methods described in Tk::options which can be used to enquire 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 Tree widgets:
$tree-><B>add_pathimageB>(treeRegExp [, openImg, closeImg]) This method defines images for a given path (images must be in xpm format). The path can be determined by a simplified regular expression. There are just three metasymbols:
^ at the beginning of the treeRegExp same as in Perl regular expressions
* anything
$ at the end of the TreeRegExp, the same as in Perl regular expressions

Examples:



  $tree->add_pathimage(^root,openfolder,folder);



matches root, root.foo, root.bar, but not foo.root



  $tree->add_pathimage(root.*.class,openfolder,folder);



matches all paths containing root.<anything>.class, but not root.<anything>.<anything>.class * is one part of the path. If you want to use a wildcard for two steps, you have to use *.*.



  $tree->add_pathimage(class$,openfolder,folder);



This matches all path with class at the end.

$tree-><B>autosetmodeB> This method calls the <B>setmodeB> method for all the entries in this Tree widget: if an entry has no child entries, its mode is set to <B>noneB>. Otherwise, if the entry has any hidden child entries, its mode is set to <B>openB>; otherwise its mode is set to <B>closeB>.
$tree-><B>child_entriesB>([$path][,$depth]) This method returns in list context an array that contains all pathnames of subentries within the given path. In scalar context it returns the number of subentries in the given path.



  Example:
    root
     | foo
     | bar
     |  | bar1
     |  | bar2

  my @childentries = $tree->child_entries(root.bar);
  # returns (root.bar.bar1, root.bar.bar2)

  my $nr_of_subentries = $tree->child_entries(root,2);
  # returns 4



If $path is omitted, all it is assumed, that the entry above ’root’ is meant. $depth defines the numbers of levels.

$tree-><B>closeB>(entryPath) Close the entry given by entryPath if its mode is <B>closeB>.
$tree-><B>getmodeB>(entryPath) Returns the current mode of the entry given by entryPath.
$tree-><B>openB>(entryPath) Open the entry given by entryPath if its mode is <B>openB>.
$tree-><B>setmodeB>(entryPath, mode) This method is used to indicate whether the entry given by entryPath has children entries and whether the children are visible. mode must be one of <B>openB>, <B>closeB> or <B>noneB>. If mode is set to <B>openB>, a (+) indicator is drawn next to the entry. If mode is set to <B>closeB>, a (-) indicator is drawn next to the entry. If mode is set to <B>noneB>, no indicators will be drawn for this entry. The default mode is none. The <B>openB> mode indicates the entry has hidden children and this entry can be opened by the user. The <B>closeB> mode indicates that all the children of the entry are now visible and the entry can be closed by the user.

BINDINGS

The basic mouse and keyboard bindings of the Tree widget are the same as the bindings of the HList widget. In addition, the entries can be opened or closed under the following conditions:
[1] If the mode of the entry is <B>openB>, it can be opened by clicking on its (+) indicator.
[2] If the mode of the entry is <B>closeB>, it can be closed by clicking on its (-) indicator.

SEE ALSO

Tk::HList

AUTHOR

Perl/TK version by Chris Dean <ctdean@cogit.com>. Original Tcl/Tix version by Ioi Kim Lam.

Additions by Renee Baecker <module@renee-baecker.de>

ACKNOWLEDGEMENTS

Thanks to Achim Bohnet <ach@mpe.mpg.de> for all his help.
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 TREE (3) 2015-01-31

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.