Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Tree with checkboxes

by perlNoob (Acolyte)
on Nov 21, 2004 at 22:27 UTC ( [id://409445]=perlquestion: print w/replies, xml ) Need Help??

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

Hello,
I want to make a Tree made up of checkboxes (so the user can chose (one or more) specific nodes of the tree) and it has confused me quite a bit.

Should I still use Tk::Tree?
Could anyone please point me out to the right direction because I'm a little lost

again, much appreciated

Replies are listed 'Best First'.
Re: Tree with checkboxes
by tall_man (Parson) on Nov 21, 2004 at 23:41 UTC
    You'll probably have to write your own mega-widget for this, but something generic like Tk::HList might be a good starting point.

      Unfortunately, HList is not generic enough to take widget as values (or more precisely its nodes), otherwise this would be trivial.

        Sorry, you're wrong. Using itemType 'window' you can pass it any widget you like. (I know, because I'm doing it with Entries, Checkbuttons and BrowseEntries)

        C.

Re: Tree with checkboxes
by bibliophile (Prior) on Nov 22, 2004 at 14:50 UTC
    Do let us know what you come up with... I can see that being a useful tool :-)

    (If you want someone to bang on it with you, let me know. I've been monkeying with Tk for a bit - not an expert by any stretch - but willing to hack!)

Re: Tree with checkboxes
by Courage (Parson) on Nov 22, 2004 at 14:40 UTC
    As long as I never saw such widget before (closest I saw is list list of checkboxes) I doubt there exists any.
    Probably no-one bothered creating such.

    But it seems to me using namely Tk::Tree this is quite possible: display items could be any window, however they must be different windows (not instances of same window)

    Did not tried this myself though...

    Best regards,
    Courage, the Cowardly Dog

Re: Tree with checkboxes
by tos (Deacon) on Nov 23, 2004 at 13:08 UTC
    though it contains no checkboxes you should perhaps have a view on dstat for some inspiration regarding Tk::HList.

    regards, tos

    Is simplicity best or simply the easiest Martin L. Gore
Re: Tree with checkboxes
by TheMarty (Acolyte) on Aug 12, 2005 at 13:45 UTC
    Hi, Here is the solution (actually very simple, but one have to know that).
    use Tk; use Tk::Tree; use strict; my $Main = MainWindow->new; $Main->title("kuku"); my @win; my $kuku; my $info_m = $Main->Frame(-relief=>'groove',-borderwidth=>'3',)->pack( +-side => 'left', -expand => 1, -fill => 'both',); my $tree = $info_m->Scrolled("Tree")->pack(-side=>'top',-expan +d=>1,-fill=>'both'); #my $win = $Main->Toplevel; $win[0] = $tree -> Checkbutton(-text => "Kaka", -variable => \ +$kuku); $win[1] = $tree -> Checkbutton(-text => "Kaka2"); $win[2] = $tree -> Checkbutton(-text => "Kaka2"); $win[3] = $tree -> Checkbutton(-text => "Kaka2", -variable => +\$kuku); $tree -> add("one", -widget=> $win[0], -itemtype => 'window'); $tree -> add("one.two", -widget=> $win[1], -itemtype => 'windo +w'); $tree -> add("one.two.muku", -widget=> $win[2], -itemtype => ' +window'); $tree -> add("three", -widget=> $win[3], -itemtype => 'window' +); $tree -> add("four",-text=> "four"); $tree -> autosetmode(); MainLoop;
    Have fun... TheMarty
Re: Tree with checkboxes
by Anonymous Monk on Dec 08, 2004 at 22:15 UTC
    thanks a lot for the information, I don't know if I would be capable to crack this on my own
    I would at least need a starting hand, but I think I'm just going to try the list of checkboxes for now

    if I do try to do it and manage it I will let you know.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://409445]
Approved by Arunbear
Front-paged by Courage
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2024-04-26 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found