Setting the mode for trees in PerlTk

A

A Epstein

I have created a tree object in PerlTk. It seems to work fine. When
the tree is initially displayed, I want all the children (for each
path) to be hidden. Basically that the parents will have the '+' sign
next to them and when i click it, it will show the sub branches. I
have written something like this:

foreach (@paths) {

$tree -> setmode ( $_, 'open' );

}

According to documentation, this is the way to do it. 'open' means
that the branches will be "ready for opening," i.e closed. However
this seems to have no effect at all. The branches are all open ('-'
sign) and the children are not hidden.

Btw: I did not forget to put

$tree -> autosetmode();

at the end, if that is what anyone was thinking.

What am I doing wrong?!!! Help!!!
 
A

A Epstein

I have created a tree object in PerlTk. It seems to work fine. When
the tree is initially displayed, I want all the children (for each
path) to be hidden. Basically that the parents will have the '+' sign
next to them and when i click it, it will show the sub branches. I
have written something like this:

foreach (@paths) {

$tree -> setmode ( $_, 'open' );

}

According to documentation, this is the way to do it. 'open' means
that the branches will be "ready for opening," i.e closed. However
this seems to have no effect at all. The branches are all open ('-'
sign) and the children are not hidden.

Btw: I did not forget to put

$tree -> autosetmode();

at the end, if that is what anyone was thinking.

What am I doing wrong?!!! Help!!!


I asked the question and I will answer (I found out what happened).
There is no need to use autosetmode which will only override all the
setmode(...) calls done prior to it. instead, just use the loop w/
setmode(..) as before and add a line to hide the children of each
parent (somebody please hide the children!!!):

foreach (@paths) {

if ($_ is a parent) {
$tree -> setmode ( $_, 'open' );
} else {
$tree->hide('entry', $_);
}
}

the result will be closed branches w/ '+' signs next to them. when
you click on the '+', the branches will open up to display the
children. to check if a path is a parent i just searched the path
string for the parent/child separator but i am sure there is a better
way.
 
S

Steve Lidie

A Epstein said:
string for the parent/child separator but i am sure there is a better
way.


Ask your Perl/Tk questions in comp.lang.perl.tk for possibly better ways (;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top