| Computers Forum Index » Computer Languages (TCL) » Treeview in Tile |
|
Page 1 of 1 |
|
| Author |
Message |
| sharon |
Posted: Fri Feb 17, 2006 4:27 am |
|
|
|
Guest
|
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! |
|
|
| Back to top |
|
|
|
| bs |
Posted: Fri Feb 17, 2006 8:38 pm |
|
|
|
Guest
|
sharon wrote:
Quote: 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!
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. |
|
|
| Back to top |
|
|
|
| sharon |
Posted: Fri Feb 17, 2006 11:54 pm |
|
|
|
Guest
|
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! |
|
|
| Back to top |
|
|
|
| bs |
Posted: Tue Feb 21, 2006 2:54 am |
|
|
|
Guest
|
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
} |
|
|
| Back to top |
|
|
|
| Eckhard Lehmann |
Posted: Tue Feb 21, 2006 1:36 pm |
|
|
|
Guest
|
sharon wrote:
Quote: 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/).
Eckhard |
|
|
| Back to top |
|
|
|
| Guest |
Posted: Tue Feb 21, 2006 8:20 pm |
|
|
|
|
Eckhard Lehmann <ecky-l@web.de> wrote:
Quote: 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
#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 |
|
|
| Back to top |
|
|
|
| Eckhard Lehmann |
Posted: Tue Feb 21, 2006 11:19 pm |
|
|
|
Guest
|
Quote: 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 |
|
|
| Back to top |
|
|
|
| slebetman@yahoo.com |
Posted: Thu Feb 23, 2006 4:26 am |
|
|
|
Guest
|
joey@swri.edu wrote:
Quote: Eckhard Lehmann <ecky-l@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. |
|
|
| Back to top |
|
|
|
| sharon |
Posted: Fri Feb 24, 2006 2:53 am |
|
|
|
Guest
|
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! |
|
|
| Back to top |
|
|
|
| Eckhard Lehmann |
Posted: Fri Feb 24, 2006 12:52 pm |
|
|
|
Guest
|
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 |
|
|
| Back to top |
|
|
|
|