in reply to Tk::Tree how to set color of entry after tree creation
The Tree class is derived from the HList class and inherits all the methods, options and subwidgets of its super-class.
And Tk::HList shows what we need to do:
Each list entry in an HList widget is associated with a display item. The display item determines what visual information should be displayed for this list entry. Please see Tk::DItem for a list of all display items.
Having read Tk::DItem, we can now solve the problem:
#! /usr/bin/perl use warnings; use strict; use Tk qw{ MainLoop }; use Tk::Tree; use Tk::ItemStyle; my $mw = 'MainWindow'->new(-title => 'Tree'); my $tree = $mw->Tree->pack(-fill => 'both', -expand => 1); $tree->add($_, -text => $_) for qw( orange orange.red orange.yellow ); my $blue = $tree->ItemStyle('imagetext', -foreground => 'blue'); $tree->itemConfigure('orange.red', 0, -style => $blue); MainLoop();
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Tk::Tree how to set color of entry after tree creation
by EnzoXenon (Acolyte) on Feb 02, 2024 at 12:28 UTC |