Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Treeview in Tile

17 views
Skip to first unread message

sharon

unread,
Feb 16, 2006, 7:32:27 PM2/16/06
to
Hello all, I'm having some difficulty with the treeview in tile. I
need the user to be able to edit the text of each of the node names.
Is this possible or is the treeview suppose to be planned? Thanks a
lot!

bs

unread,
Feb 17, 2006, 10:38:46 AM2/17/06
to

I had to do this several months ago....when I talked to Joe back then,
I believe there was no plan for this, however, I'll let him speak to
that now.

What I had to do is [place] an entry where the tree item was, to let
the user edit the text. It works Ok, but it would be nicer to have it
within treeview.

sharon

unread,
Feb 17, 2006, 1:54:01 PM2/17/06
to
How exactly did you place the entry where the tree item was? I don't
know where I would pack it. Thanks again for your help!

bs

unread,
Feb 20, 2006, 4:54:52 PM2/20/06
to
Note: what I think the Treeview should at least do, is provide a method
to return the bbox of an item, so that discovering the coords is not
necessary.

For me, I bound a proc to the Double-1, and in the proc, I [place] the
entry widget where the Double-1 click occurred. It's not very exact,
but works ok. I have to discover the y coord, and you might also have
to adjust it if the window is resized (use <Configure>).

Note: My tree only has one column, so if there are multiple columns,
this may be trickier.

something like this:

bind .tree <Double-1> [list embedEntry $base %W %X %Y]
bind .tree <Configure> [list adjustEntryWidth %W]

proc embedEntry {base_ wid_ {y_ ""}} {

variable W

catch {$wid_ delete dummy}
catch {destroy ${wid_}.addressentry}

##
## find a good y to start at
##
if {$y_ == ""} {
$wid_ insert {} end -id dummy

update idletasks

## find better starting number
set y 31
for {set i 20} {$i <= 200} {incr i} {
set x [lindex [$wid_ identify 10 $i] 1]

if {$x == "dummy"} {
set y $i
break
}
}
} else {
set y [expr {$y_ - [winfo rooty $wid_]}]
}

# hard coded for now
set x 8

set item [lindex [$wid_ identify $x $y] 1]

set W(recipient_entry) [::ttk::entry ${wid_}.addressentry -width
52]

place ${wid_}.addressentry -x $x -y [expr {$y + 1}] -in $wid_

${wid_}.addressentry insert 0 [$wid_ item $item -text]

bind ${wid_}.addressentry <Key-Escape> [list destroy
${wid_}.addressentry]
bind ${wid_}.addressentry <Return> [list replaceToString $wid_
$item ${wid_}.addressentry]

focus ${wid_}.addressentry

adjustEntryWidth $wid_

return
}

proc adjustEntryWidth {treewid_} {

variable W

if {![info exists W(recipient_entry)]} {return}

if {![winfo exists $W(recipient_entry)]} {return}

set twid [winfo width $treewid_]

##
## This is called for both tree widgets, so only need
## this for the one that has the embedded entry widget
##
if {[string equal $treewid_ .tree]} {
set ewid [expr {$twid - 16}]
set fsize [font measure TkTextFont 0]
$W(recipient_entry) configure -width [expr {$ewid / $fsize}]
}

$treewid_ column #0 -width [expr {$twid - 12}]

return
}

Eckhard Lehmann

unread,
Feb 21, 2006, 3:36:07 AM2/21/06
to

ttk::treeview is great, I like it especially for it's simple usage and
tile themes.
But for more sophisticated things, like your node-editing problem, you
might want to have a look at tktreectrl
(http://tktreectrl.sourceforge.net/).


Eckhard

jo...@swri.edu

unread,
Feb 21, 2006, 10:20:45 AM2/21/06
to

I tried using TreeCtrl and got the following core dump on Solaris using
Tcl/Tk v8.4.12 when trying the demo.tcl script in the demos directory.

Here's the stack trace:

(gdb) where
#0 0xfed8f8f8 in AllocHax_Alloc () from /data1/optlocal/tcltk-8.4.12/lib/treectrl2.1/libtreectrl2.1.so
#1 0xfed8fdb8 in PerStateInfo_FromObj () from /data1/optlocal/tcltk-8.4.12/lib/treectrl2.1/libtreectrl2.1.so
#2 0xfed5f39c in Column_Config () from /data1/optlocal/tcltk-8.4.12/lib/treectrl2.1/libtreectrl2.1.so
#3 0xfed631f0 in Tree_InitColumns () from /data1/optlocal/tcltk-8.4.12/lib/treectrl2.1/libtreectrl2.1.so
#4 0xfed640a8 in TreeObjCmd () from /data1/optlocal/tcltk-8.4.12/lib/treectrl2.1/libtreectrl2.1.so
#5 0xff1a80dc in TclEvalObjvInternal () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
#6 0xff1d1dbc in TclExecuteByteCode () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
#7 0xff1d12b8 in TclCompEvalObj () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
#8 0xff205ae8 in TclObjInterpProc () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
#9 0xff1a80dc in TclEvalObjvInternal () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
#10 0xff1d1dbc in TclExecuteByteCode () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
#11 0xff1d12b8 in TclCompEvalObj () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
#12 0xff205ae8 in TclObjInterpProc () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
#13 0xff1a80dc in TclEvalObjvInternal () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
#14 0xff1a89dc in Tcl_EvalEx () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
#15 0xff1ee700 in Tcl_FSEvalFile () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
#16 0xff1ed368 in Tcl_EvalFile () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
#17 0xff2c0abc in Tk_MainEx () from /opt/local/tcltk-8.4.12/lib/libtk8.4.so
#18 0x000109b0 in main ()

Any ideas?

Joey

Eckhard Lehmann

unread,
Feb 21, 2006, 1:19:13 PM2/21/06
to
> I tried using TreeCtrl and got the following core dump on Solaris using
> Tcl/Tk v8.4.12 when trying the demo.tcl script in the demos directory.
>
> Here's the stack trace:
>
> (gdb) where
> #0 0xfed8f8f8 in AllocHax_Alloc () from /data1/optlocal/tcltk-8.4.12/lib/treectrl2.1/libtreectrl2.1.so
> #1 0xfed8fdb8 in PerStateInfo_FromObj () from /data1/optlocal/tcltk-8.4.12/lib/treectrl2.1/libtreectrl2.1.so
> #2 0xfed5f39c in Column_Config () from /data1/optlocal/tcltk-8.4.12/lib/treectrl2.1/libtreectrl2.1.so
> #3 0xfed631f0 in Tree_InitColumns () from /data1/optlocal/tcltk-8.4.12/lib/treectrl2.1/libtreectrl2.1.so
> #4 0xfed640a8 in TreeObjCmd () from /data1/optlocal/tcltk-8.4.12/lib/treectrl2.1/libtreectrl2.1.so
> #5 0xff1a80dc in TclEvalObjvInternal () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
> #6 0xff1d1dbc in TclExecuteByteCode () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
> #7 0xff1d12b8 in TclCompEvalObj () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
> #8 0xff205ae8 in TclObjInterpProc () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
> #9 0xff1a80dc in TclEvalObjvInternal () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
> #10 0xff1d1dbc in TclExecuteByteCode () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
> #11 0xff1d12b8 in TclCompEvalObj () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
> #12 0xff205ae8 in TclObjInterpProc () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
> #13 0xff1a80dc in TclEvalObjvInternal () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
> #14 0xff1a89dc in Tcl_EvalEx () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
> #15 0xff1ee700 in Tcl_FSEvalFile () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
> #16 0xff1ed368 in Tcl_EvalFile () from /opt/local/tcltk-8.4.12/lib/libtcl8.4.so
> #17 0xff2c0abc in Tk_MainEx () from /opt/local/tcltk-8.4.12/lib/libtk8.4.so
> #18 0x000109b0 in main ()
>
> Any ideas?

Hmm, sorry - no. I was using it once on Windows, and there it works
fine...


Eckhard

sleb...@gmail.com

unread,
Feb 22, 2006, 10:52:04 PM2/22/06
to
jo...@swri.edu wrote:
> Eckhard Lehmann <eck...@web.de> wrote:
> > sharon wrote:
> > > Hello all, I'm having some difficulty with the treeview in tile. I
> > > need the user to be able to edit the text of each of the node names.
> > > Is this possible or is the treeview suppose to be planned? Thanks a
> > > lot!
> >
> > ttk::treeview is great, I like it especially for it's simple usage and
> > tile themes.
> > But for more sophisticated things, like your node-editing problem, you
> > might want to have a look at tktreectrl
> > (http://tktreectrl.sourceforge.net/).
>
> I tried using TreeCtrl and got the following core dump on Solaris using
> Tcl/Tk v8.4.12 when trying the demo.tcl script in the demos directory.
>
> Here's the stack trace:
>
> (gdb) where
> <snip core dump>
> Any ideas?
>

I've used BWidget tree for this. It's pure tcl based on the canvas. It
has the in-place text editing built in like what you want.

sharon

unread,
Feb 23, 2006, 4:53:50 PM2/23/06
to
Another question about treeview in tile... Is there a way to get the
full path name of an item in the tree? All I can see is that you can
just get the direct parent of an item. I know I could use a loop to
get the parent's parent and so on. It just seems like there should be
an easier way. Am I missing something? Thanks for your help!

Eckhard Lehmann

unread,
Feb 24, 2006, 2:52:38 AM2/24/06
to
No, it seems that you can not get the full path name.

But that's a problem I just dealed with, so it's quite fresh in my mind
:-):

set path [list [$tree selection]]
set sel [$tree selection]

while {1} {
set parItem [$tree parent $sel]
if {$parItem == ""} {
break
}
set path [concat $parItem $path]
set sel $parItem
}


Eckhard

0 new messages