NAME

Wx::Perl::DirTree - A directory tree widget for wxPerl

VERSION

version 0.07

SYNOPSIS

use Wx::Perl::DirTree;

my $panel = Wx::Panel->new;
my $tree  = Wx::Perl::DirTree->new( $panel, [100,100] );
  
my $main_sizer   = Wx::BoxSizer->new( wxVERTICAL );
$main_sizer->Add( $tree->GetTree,  0, wxTOP, 0 );

# in a subroutine
print $tree->GetSelectedPath;

DESCRIPTION

Many widgets that display directory trees are dialogs or can't handle drives on Windows. This module aims to fill the gap. It can be integrated in any frame or dialog and it handles drives under Windows.

METHODS

GetSelectedPath

$tree->GetSelectedPath

This method returns the path of the item that is selected.

GetTree

$tree->GetTree

This is just a convenience method that wraps the GetTree method of Wx::Perl::VirtualTree.

new

Creates a new object

my $tree  = Wx::Perl::DirTree->new( $panel, [100,100] );

my $tree2  = Wx::Perl::DirTree->new( 
    $panel, 
    [100,100],
    {
        dir => $path_to_dir,
    }
);

my $tree2  = Wx::Perl::DirTree->new( 
    $panel, 
    [100,100],
    {
        dir     => $path_to_dir,
        is_root => 1,
    }
);

Parameters:

1 $parent

A parent widget.

2 $size

The size of the tree widget. This has to be an array reference.

3 $hashref

In this hash reference you can specifiy more parameters:

  • dir

    If you want to "open" a specific directory, you can specify "dir"

  • is_root

    If set to a true value, the dir tree starts at the specified directory. If you want to provide a directory tree that shows only the directories below the home directory of a user you can do this:

    Wx::Perl::DirTree->new(
      $panel,
      $size,
      {
          dir => File::HomeDir->my_home,
          is_root => 1,
      }
    );
  • allowed

    With that option you can specify whether only directories or only files can be selected. If this option is ommitted, both types can be selected.

    use Wx::Perl::DirTree qw(:const); # loads two constants
    
    my $tree = Wx::Perl::DirTree->new(
      $panel,
      $size,
      {
          dir => File::HomeDir->my_home,
          allowed => wxPDT_DIR, # only directories can be selected
      }
    );

See also the scripts in the example dir.

AUTHOR

Renee Baecker <module@renee-baecker.de>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2010 by Renee Baecker.

This is free software, licensed under:

The Artistic License 2.0