The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Tk::CanvasDirTree - Perl Derived Canvas widget for browsing Directory Trees

SYNOPSIS

  use Tk;
  use Tk::CanvasDirTree;
 
  my $ztree = $frame->Scrolled('CanvasDirTree',
            -bg =>'lightblue',
            -width =>300,
            -height =>300,
#           -backimage => 'bridget-5a.jpg',  #either a gif,jpg,or png file 
#           -backimage => $bunny,            #or Tk::Photo object data 
            -imx => 200,           # image position relative to nw corner 
            -imy => 10,            # to place nw corner of image 
            -floatback => 1,  # makes background appear stationary in y 
                              # direction, defaults to 0     
            -font => 'big',        # defaults to system 
#           -fontcolorn => 'cyan', # defaults to black 
#           -fontcolora => 'lightseagreen', #defaults to red 
#           -indfilln => 'hotpink',         #defaults to blue    
#           -indfilla => 'orange',          #defaults to red 
            -scrollbars =>'osw',
            )->pack(-side=>'left',-fill=>'both', -expand=>1);

#binding $ztree->bind('<ButtonPress-1>', sub{ my $selected = $ztree->get_selected(); if(length $selected){print "$selected\n"} });

#configuring $ztree->configure('-indfilla' => 'red' ); $ztree->configure('-indfilln' => 'orange'); $ztree->configure('-fontcolora' => 'white'); $ztree->configure('-fontcolorn' => 'cyan'); $ztree->configure('-bg' => 'black'); # gif, jpg, or png file $ztree->configure('-backimage' => $tux ); $ztree->configure('-imy' => 45 ); $ztree->configure('-imx' => 25 );

DESCRIPTION

This widget reads a directory tree, in an efficient manner, and provides an intuitive graphical interface to selecting them. It only recurses 2 levels at a time, so it is efficient on deeply nested trees. It is similar in appearance to the Gtk2 TreeView. Colors and fonts are configurable, as well as a background image (with configurable location placement). Also with -floatback => 1, the background image will appear to stay stationary as the y scrollbar is moved. Due to the wide variety of possible color schemes, creating a pleasing background image is left to you. See the included scripts in the scripts directory, for examples to make charcoal or faded backgrounds.

It is a single mouse click selector( I nevered liked double-click bindings :-) ). If a sub-directory has subdirs in it's own tree, a colored triangular shaped indicator will be placed to the left of the subdir. Clicking on the indicator will expand that subdir tree, and subsequent clicks will close it.

The basic operation is simple. A left mouse click on a subdirectory, will return it's full path. You can then do what you want with the path, from your main script.

This widget is a derived Tk::Canvas, can be treated like a Canvas. It contains additional configuration options:

    -backimage => 'bridget-5a.jpg',  # either a file 
    -backimage => $bunny,            # or Tk::Photo object data 
    -imx => 200,                     # image position relative to nw corner 
    -imy => 10,                      # to place nw corner of image 
    -floatback => 1,                 # floating background, defaults to 0
    -font => 'big',                  # defaults to system 
    -fontcolorn => 'cyan',           # defaults to black 
    -fontcolora => 'lightseagreen',  # defaults to red 
    -indfilln => 'hotpink',          # defaults to blue    
    -indfilla => 'orange',           # defaults to red 

EXPORT

None.

SEE ALSO

See "perldoc Tk::Canvas" for the standard Canvas options See perldoc Tk::Derived for information on how this module was derived.

AUTHOR

zentara, <zentara@zentara.net> See http://zentara.net/perlplay for other perl script examples.

COPYRIGHT AND LICENSE

Copyright (C)April 14, 2006 by Joseph B. Milosch a.k.a zentara

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.