summaryrefslogtreecommitdiffstats
path: root/demos/random.tcl
diff options
context:
space:
mode:
authortreectrl <treectrl>2005-03-29 20:26:13 (GMT)
committertreectrl <treectrl>2005-03-29 20:26:13 (GMT)
commit8892641fcc63266bc08b6390c252e79525a7702f (patch)
tree14ab3b26eee716fb0f4a8eaaa7d7681a3d6fc1dc /demos/random.tcl
parent511cd686d18fc9b56910c78232a646ce6e70302e (diff)
downloadtktreectrl-8892641fcc63266bc08b6390c252e79525a7702f.zip
tktreectrl-8892641fcc63266bc08b6390c252e79525a7702f.tar.gz
tktreectrl-8892641fcc63266bc08b6390c252e79525a7702f.tar.bz2
Added standard block comments to highlight steps of creating and using a treectrl widget.
Diffstat (limited to 'demos/random.tcl')
-rw-r--r--demos/random.tcl22
1 files changed, 21 insertions, 1 deletions
diff --git a/demos/random.tcl b/demos/random.tcl
index 4127dab..dace0a6 100644
--- a/demos/random.tcl
+++ b/demos/random.tcl
@@ -13,14 +13,27 @@ proc DemoRandom {} {
if {$height < 18} {
set height 18
}
+
+ #
+ # Configure the treectrl widget
+ #
+
$T configure -itemheight $height -selectmode extended \
-showroot yes -showrootbutton yes -showbuttons yes -showlines yes \
-scrollmargin 16 -xscrolldelay "500 50" -yscrolldelay "500 50"
+ #
+ # Create columns
+ #
+
$T column create -expand yes -text Item -itembackground {#e0e8f0 {}} -tag item
$T column create -text Parent -justify center -itembackground {gray90 {}} -tag parent
$T column create -text Depth -justify center -itembackground {linen {}} -tag depth
+ #
+ # Create elements
+ #
+
$T element create e1 image -image {folder-open {open} folder-closed {}}
$T element create e2 image -image small-file
$T element create e3 text \
@@ -30,6 +43,10 @@ proc DemoRandom {} {
$T element create e5 rect -showfocus yes \
-fill [list $::SystemHighlight {selected focus} gray {selected !focus}]
+ #
+ # Create styles using the elements
+ #
+
$T style create s1
$T style elements s1 {e5 e1 e3 e4}
$T style layout s1 e1 -padx {0 4} -expand ns
@@ -56,6 +73,10 @@ proc DemoRandom {} {
{item s2 e2 e3}
}
+ #
+ # Create items and assign styles
+ #
+
set clicks [clock clicks]
set items [$T index root]
for {set i 1} {$i < $::RandomN} {incr i} {
@@ -138,7 +159,6 @@ proc TreeCtrl::RandomButton1 {T x y} {
variable Priv
focus $T
set id [$T identify $x $y]
- puts $id
set Priv(buttonMode) ""
# Click outside any item