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

panedwindow + tablelist

82 views
Skip to first unread message

Nicolas Robert

unread,
Mar 15, 2017, 3:09:03 PM3/15/17
to
Hello,

I have a problem with tablelist + panedwindow.
I'm using tablelist like a tree directory.
When I move my tablelist with the draggable sash areas , my images disappear.

My question : It's me who do not use decently panedwindow ? There is a function in the tablelist help, which I forgot or not seen .

My code below + video

https://expirebox.com/download/28e0f71a0f0da75df255bdcfae7a2f11.html


package require tablelist

image create photo gohome_16 -data {
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QAAAAAAAD5Q7t/AAAACXBI
WXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH1QoOFCUTUyrSOwAAAetJREFUOMuVk79rU1EUgL97+95L
00DyJKBVh2RRexNoVawRXByMQhOnh9RKJ5GioxhcOrRuwan+GOrUJYv1x2AT8A/wPxB5W1zEWtvw
YlGJIXnXIfbZl1AhZ7pczvfdcw7nwgHhKVWsgK6A9pR6yDCxB3tKaU+pPUlxaHixOKPLN2/8VyL6
4ZrrbhSUYv3cWbYnTnHk8DgnvCZTa2vUXJeCUtcOuW51QLAfflOcYff4MZTKMhaN0mq1GNv8SrZc
HpCIfrh6+xadZJJ0Kk0qlQJAa2i32+zW65wslUISsR9+96BExzDJ5S5g23bQmtYaAN/3+bm1RXJu
LpCICuiCUrx/VMZrNjk/nSMejyOECAl83w/OhhCM5vPUXBcDuAOsTp0+w/3SPTaqbwPwycozVh4/
RYsRdKeFMEbR3d8sLy3R7qXMynl4vjCZIRFPAKDUBJmMIpvN9F4UkpH0ld7EU3mQFlprFiYzzMO6
7O/TsixM08QwjOD+S+MHAB/qO3S7fpALMCCQUiKlxJKfAehg8fFTA4Bv3i86IhJaJGNgs/4Oz+co
AJcuTnM1GkPqcS5Lk+1NQhUY/RX8m37vpe/eDqLZOHD1A0EkEsG2bRKJBAKJEBCLxXAcZwCyLCv8
F67POq8Ah+Fi9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Hym/ISy/PT6/Oz2/OTq/MTW/Iyy/ISq/Iy2
/Gyi/CRq3OTu/Mze/MTa/ISu/HSi/FyK/FSG/NTm/KzK/KTG/JS+/GyW/Gya
/GSS/Nzq/KzG/KTC/Mzi/HSe/Ozu/Mza/AAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAal
QAAgICAaBQOhUiggFAwHREIhWCyFAUbD8YBEFAFJcilgTCiVg0WxaFuVAcLW
ccEoEhnNhkwwTDgVHR4OAhpvWHIODhkfICEiAYcAAhMGFRUjJCUOJhljWAYN
DxcRJygnKQ2SApYqHmsJKywln0MFDh8YEREapiWrli0eHgkWJJq1AQYQGLoR
Li4oJKsvCIIeCgrHtEsBFQgwMLsJsSuSbujoY35BACH+aENyZWF0ZWQgYnkg
Qk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5
OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3Iu
Y29tADs=
}


wm title . "Panedwindow + tablelist..."


ttk::style configure TPanedwindow -background blue
ttk::style configure Sash -sashthickness 10

set p [ttk::panedwindow .p -orient horizontal]
set f [frame .f -background gray -height 150 -width 150]

set tf .tf
ttk::frame $tf

set tree $tf.tree
set vsb $tf.vsb
set hsb $tf.hsb

tablelist::tablelist $tree -columns {0 "Projet -"} -stretch all \
-xscrollcommand [list $hsb set] -yscrollcommand [list $vsb set] -labelbd 1 \
-labelrelief sunken -stripebg #f0f0f0

if {[$tree cget -selectborderwidth] == 0} {
$tree configure -spacing 1
}

$tree insertchild root end "Directory"
$tree cellconfigure 0,0 -image gohome_16 -font {TkDefaultFont 10 bold}
$tree insertchild 0 end "C:/Users/Nicolas"
$tree cellconfigure 1,0 -image document_16
$tree rowconfigure 1 -name dirc
$tree insertchild root end "Fichier"
$tree cellconfigure 2,0 -image folder_ver_16 -font {TkDefaultFont 10 bold}
$tree insertchild 2 end "C:/Users/Nicolas/file.txt"
$tree cellconfigure 3,0 -image document_16

ttk::scrollbar $vsb -orient vertical -command [list $tree yview]
ttk::scrollbar $hsb -orient horizontal -command [list $tree xview]

grid $tree -row 0 -rowspan 2 -column 0 -sticky news
grid $vsb -row 0 -rowspan 2 -column 1 -sticky ns

grid $hsb -row 2 -column 0 -sticky ew
grid rowconfigure $tf 1 -weight 1
grid columnconfigure $tf 0 -weight 1


$p add $f -weight 1
$p add $tf -weight 1

grid $p -row 0 -column 0 -sticky news

grid rowconfigure . 0 -weight 1
grid columnconfigure . 0 -weight 1

nemethi

unread,
Mar 16, 2017, 7:48:11 AM3/16/17
to
I have been able to reproduce the issue on Windows only (on my Linux box
your script works as expected).

I couldn't find anything wrong in your script, and in the Tablelist code
there is nothing related to paned windows. The tablelist widget doesn't
"know" that it is embedded into a paned window.

I have taken a look at the Ttk library file panedwindow.tcl, which
implements the bindings for the ttk::panedwindow widget. I think that
the problem is caused by the fact that *every* <B1-Motion> event
generates a sashpos invocation (see the ttk::panedwindow::Drag proc). In
my opinion, this could be optimized.

--
Csaba Nemethi http://www.nemethi.de mailto:csaba....@t-online.de

nemethi

unread,
Mar 28, 2017, 5:32:13 PM3/28/17
to nicolasro...@gmail.com
Am 16.03.2017 um 12:48 schrieb nemethi:
> Am 15.03.2017 um 20:08 schrieb Nicolas Robert:
>> Hello,
>>
>> I have a problem with tablelist + panedwindow.
>> I'm using tablelist like a tree directory.
>> When I move my tablelist with the draggable sash areas , my images
>> disappear.
>>
>> My question : It's me who do not use decently panedwindow ? There is a
>> function in the tablelist help, which I forgot or not seen .
>>
>> My code below + video
>> . . .
>
> I have been able to reproduce the issue on Windows only (on my Linux box
> your script works as expected).
>
> I couldn't find anything wrong in your script, and in the Tablelist code
> there is nothing related to paned windows. The tablelist widget doesn't
> "know" that it is embedded into a paned window.
>
> I have taken a look at the Ttk library file panedwindow.tcl, which
> implements the bindings for the ttk::panedwindow widget. I think that
> the problem is caused by the fact that *every* <B1-Motion> event
> generates a sashpos invocation (see the ttk::panedwindow::Drag proc). In
> my opinion, this could be optimized.
>

Sorry for the delay, caused, among others, by preparing a new Tablelist
release (announced a few days ago).

You can significantly improve the behavior of your tablelist widget by
overriding the procedure ttk::panedwindow::Drag (implemented in the Ttk
library file panedwindow.tcl) by the following optimized version, which
you should insert into your script:

proc ttk::panedwindow::Drag {w x y} {
variable State
if {!$State(pressed)} { return }

switch -- [$w cget -orient] {
horizontal { set State(delta) [expr {$x - $State(pressX)}] }
vertical { set State(delta) [expr {$y - $State(pressY)}] }
}

if {![info exists State(afterId)]} {
set State(afterId) [after 10 \
[list ttk::panedwindow::UpdateSashPos $w]]
}
}

proc ttk::panedwindow::UpdateSashPos {w} {
variable State
unset State(afterId)

$w sashpos $State(sash) [expr {$State(sashPos) + $State(delta)}]
}

The optimization consists in keeping the frequency of the "$w sashpos
..." invocations at a reasonably low value.

Harald Oehlmann

unread,
Mar 29, 2017, 4:37:33 AM3/29/17
to
Csaba,

Am 28.03.2017 um 23:32 schrieb nemethi:
> You can significantly improve the behavior of your tablelist widget by
> overriding the procedure ttk::panedwindow::Drag (implemented in the Ttk
> library file panedwindow.tcl) by the following optimized version, which
> you should insert into your script:
>
> proc ttk::panedwindow::Drag {w x y} {
> variable State
> if {!$State(pressed)} { return }
>
> switch -- [$w cget -orient] {
> horizontal { set State(delta) [expr {$x - $State(pressX)}] }
> vertical { set State(delta) [expr {$y - $State(pressY)}] }
> }
>
> if {![info exists State(afterId)]} {
> set State(afterId) [after 10 \
> [list ttk::panedwindow::UpdateSashPos $w]]
> }
> }
>
> proc ttk::panedwindow::UpdateSashPos {w} {
> variable State
> unset State(afterId)
>
> $w sashpos $State(sash) [expr {$State(sashPos) + $State(delta)}]
> }
>
> The optimization consists in keeping the frequency of the "$w sashpos
> ..." invocations at a reasonably low value.
>

Would this be a general optimisation for core Tk?
Should we create a ticket?
A frequency of 10ms still feels quick...

Thank you,
Harald

nemethi

unread,
Mar 29, 2017, 5:43:45 AM3/29/17
to
Maybe. But I will take a look at the bindings for the Tk panedwindow,
too, before creating a ticket.

Harald Oehlmann

unread,
Mar 29, 2017, 5:46:02 AM3/29/17
to
Ok, great !

By the way, what do you think about the new text widget implementation?

Thank you,
Harald



nemethi

unread,
Mar 29, 2017, 8:53:14 AM3/29/17
to
I couldn't test it yet, but the benchmarks look very promising. I am
sure Tablelist will benefit from the performance improvements of the new
text widget implementation.

Nicolas Robert

unread,
Mar 29, 2017, 2:00:36 PM3/29/17
to
Le mardi 28 mars 2017 23:32:13 UTC+2, nemethi a écrit :
> Sorry for the delay, caused, among others, by preparing a new Tablelist
> release (announced a few days ago).
>
> You can significantly improve the behavior of your tablelist widget by
> overriding the procedure ttk::panedwindow::Drag (implemented in the Ttk
> library file panedwindow.tcl) by the following optimized version, which
> you should insert into your script:
>
> proc ttk::panedwindow::Drag {w x y} {
> variable State
> if {!$State(pressed)} { return }
>
> switch -- [$w cget -orient] {
> horizontal { set State(delta) [expr {$x - $State(pressX)}] }
> vertical { set State(delta) [expr {$y - $State(pressY)}] }
> }
>
> if {![info exists State(afterId)]} {
> set State(afterId) [after 10 \
> [list ttk::panedwindow::UpdateSashPos $w]]
> }
> }
>
> proc ttk::panedwindow::UpdateSashPos {w} {
> variable State
> unset State(afterId)
>
> $w sashpos $State(sash) [expr {$State(sashPos) + $State(delta)}]
> }
>
> The optimization consists in keeping the frequency of the "$w sashpos
> ..." invocations at a reasonably low value.
>
> --
> Csaba Nemethi http://www.nemethi.de mailto:csaba....@t-online.de

Thank you so much Csaba.

after 10 performs the same way that the normal procedure ttk::panedwindow::Drag.
I must to increase the time :
after 60,70... ; # works for me

Thanks again

Nicolas
0 new messages