pdbzro has asked for the wisdom of the Perl Monks concerning the following question:
use Tkx; use strict; my $tree; my $mw= Tkx::widget->new("."); $mw->g_wm_focus(); display_tree(); Tkx::MainLoop; sub treeclic { #my $clic=$tree->selection(); my $clic=$tree->focus(); print "$clic\n"; } sub display_tree { $tree=""; $tree=$mw->new_ttk__treeview(); my $scrollbarv=$mw->new_ttk__scrollbar(-orient=>"vertical", -command=> +[$tree,"yview"]); $scrollbarv->g_pack(-side=>'right',-fill=>'y'); my $scrollbarh=$mw->new_ttk__scrollbar(-orient=>"horizontal", -command +=>[$tree,"xview"]); $scrollbarh->g_pack(-side=>'bottom',-fill=>'x'); $tree->configure(-xscrollcommand=>[$scrollbarh,"set"]); $tree->configure(-yscrollcommand=>[$scrollbarv,"set"]); $tree->g_pack(-side=>'top',-anchor=>'w',-expand=>1,-fill=>'both'); $tree->tag_configure("ttk",-background=>"lightblue"); $tree->tag_bind("ttk","<1>",sub{treeclic}); $tree->insert("","end",-id=>"perea",-text=>"perea",-tags=>"ttk simple" +); $tree->insert("perea","end",-id=>"fils",-text=>"fils aaaaaaaaaaaaaaaaa +aaaaaaaaa",-tags=>"ttk simple"); $tree->insert("perea","end",-id=>"fille",-text=>"fille",-tags=>"ttk si +mple"); $tree->insert("","end",-id=>"pereb",-text=>"pereb",-tags=>"ttk simple" +); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: tree in perl Tkx
by Anonymous Monk on Jan 31, 2016 at 10:32 UTC | |
by pdbzro (Initiate) on Jan 31, 2016 at 12:44 UTC | |
by Anonymous Monk on Jan 31, 2016 at 21:38 UTC |