Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello

I have searched here for an example code using the TK::DataTree module to no avail.

This the only bit of code that is supplied with the documentation of the module.
use Tk; use Tk::DataTree; $mw = MainWindow->new(-title =>'DataTree'); $dt = $mw->DataTree; $dt->data( { foo => 1, bar => [2, 3] } )->pack; Mainloop;
Can someone elaborate on this code, and come up with a better example for us wannabe Tk programmers to learn from. Regards

Thanks

Replies are listed 'Best First'.
Re: TK::DataTree Examples
by kvale (Monsignor) on Sep 24, 2004 at 22:31 UTC
    Look in the test directory for a number of examples of Tk::DataTree use.

    -Mark

      I am working on a similar project. Here you are:
      #!c:/perl/bin use strict; use diagnostics; use Tk; use Tk::DataTree; my $mw = MainWindow->new (-title=>'Cartoon DataTree'); $mw->geometry('200x500'); my $dt = $mw->Scrolled('DataTree',-activecolor => 'blue', -scrollbars=>'se')->pack(-fill=>'both',-expand=>1); $dt->data( { flintstones => { series => "flintstones", nights => [ qw(monday thursday friday) ], members => [ { name => "fred", role => "lead", age => 36, }, { name => "wilma", role => "wife", age => 31, }, { name => "pebbles", role => "kid", age => 4, }, ], }, jetsons => { series => "jetsons", nights => [ qw(wednesday saturday) ], members => [ { name => "george", role => "lead", age => 41, }, { name => "jane", role => "wife", age => 39, }, { name => "elroy", role => "kid", age => 9, }, ], }, simpsons => { series => "simpsons", nights => [ qw(monday) ], members => [ { name => "homer", role => "lead", age => 34, }, { name => "marge", role => "wife", age => 37, }, { name => "bart", role => "kid", age => 11, }, ], }, } ); MainLoop;
      Regards

      Blackadder
Re: TK::DataTree Examples
by eserte (Deacon) on Sep 27, 2004 at 19:18 UTC
    Without looking at the actual Tk::DataTree documentation, but shouldn't the ->pack() call be applied to the widget, not to a random method call? So it should be:
    $dt = $mw->DataTree->pack; $dt->data( { foo => 1, bar => [2, 3] } );