Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #327: The POP server is out of Coke


comp / comp.lang.tcl / Re: Another Tablelist question

SubjectAuthor
* Another Tablelist questionAlan Grunwald
`* Re: Another Tablelist questiongreg
 `- Re: Another Tablelist questionAlan Grunwald

1
Subject: Another Tablelist question
From: Alan Grunwald
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Fri, 15 Nov 2024 19:20 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: nospam.nurdglaw@gmail.com (Alan Grunwald)
Newsgroups: comp.lang.tcl
Subject: Another Tablelist question
Date: Fri, 15 Nov 2024 19:20:14 +0000
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <vh86v6$3i2jm$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 15 Nov 2024 20:21:11 +0100 (CET)
Injection-Info: dont-email.me; posting-host="c39982d7fa14823644e1169da91c8595";
logging-data="3738230"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19SoF4cPzk7bUD7NUlqro5j/lK6tkEQjgM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Ef3pdZgVlC4VVB+vRGFAJVoSA54=
Content-Language: en-US
View all headers

How do I tell the height occupied by a row (or a few rows) in a Tablelist?

tl;dr

I'm writing a GUI with a tablelist and a text widget displayed one above
the other in a paned window. I'd like to position the sash
programmatically so that the entire content of the tablelist is visible,
with the remaining space in the paned window occupied by the text widget.

I have observed that having the two widget heights in the ratio 1:3
works about right, but I'd like to get it spot on if I can.

All the rows in the tablelist are the same height, so if I knew that
height I could easily work out how much space is required for the five
or six rows that I've inserted. On the other hand, one might conceivably
have rows of different heights, so something to get the height of the
first few rows (or maybe even any set of adjacent rows) would be nice.

Thanks again (in advance)

Alan

Subject: Re: Another Tablelist question
From: greg
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sat, 16 Nov 2024 00:00 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gregor.ebbing@gmx.de (greg)
Newsgroups: comp.lang.tcl
Subject: Re: Another Tablelist question
Date: Sat, 16 Nov 2024 01:00:44 +0100
Organization: A noiseless patient Spider
Lines: 80
Message-ID: <vh8nbc$3lcgh$1@dont-email.me>
References: <vh86v6$3i2jm$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 16 Nov 2024 01:00:45 +0100 (CET)
Injection-Info: dont-email.me; posting-host="e6b61f0ea3025b99fac4b7a345a059bc";
logging-data="3846673"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Fl+9dANNPP8NsBP7tOpViYJFYygsYPS0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:2ZM2hf5GAQPJSQKqOPS0OzzonlM=
Content-Language: de-DE
In-Reply-To: <vh86v6$3i2jm$1@dont-email.me>
View all headers

Am 15.11.24 um 20:20 schrieb Alan Grunwald:
> How do I tell the height occupied by a row (or a few rows) in a Tablelist?
>
> tl;dr
>
> I'm writing a GUI with a tablelist and a text widget displayed one above
> the other in a paned window. I'd like to position the sash
> programmatically so that the entire content of the tablelist is visible,
> with the remaining space in the paned window occupied by the text widget.
>
> I have observed that having the two widget heights in the ratio 1:3
> works about right, but I'd like to get it spot on if I can.
>
> All the rows in the tablelist are the same height, so if I knew that
> height I could easily work out how much space is required for the five
> or six rows that I've inserted. On the other hand, one might conceivably
> have rows of different heights, so something to get the height of the
> first few rows (or maybe even any set of adjacent rows) would be nice.
>
> Thanks again (in advance)
>
> Alan

Hello,

I find your question interesting.
My script does not correspond to your suggestion.
Perhaps bbox can help you.

Gregor

package require Tk
package require tablelist

# Main window
ttk::panedwindow .pw -orient vertical
pack .pw -fill both -expand true

# Tablelist
tablelist::tablelist .pw.tl -columns {0 "Name" left 0 "Value" center}
-height 5
..pw add .pw.tl -weight 0

# Text
text .pw.text -wrap word -background white
..pw add .pw.text -weight 1

# Tablelist insert datas
set data {
{"Item 1" "10"}
{"Item 2" "20"}
{"Item 3" "30"}
{"Item 4" "40"}
{"Item 5" "50"}
{"Item 6" "60"}
{"Item 7" "70"}
} foreach row $data {
.pw.tl insert end $row
}

# https://www.nemethi.de/tablelist/tablelistWidget.html#bbox
wm geometry . 400x300
update idle
set hwin [winfo height .pw]
set hpw [.pw sash 0 $hwin]
set adjust [expr {$hwin - $hpw}]

update idle
#https://www.nemethi.de/tablelist/tablelistWidget.html#row_indices
#bottom instead of end, if the entire table is not visible
set bottomboxlist [.pw.tl bbox bottom]
set ybottombox [lindex $bottomboxlist 1]
set hbottombox [lindex $bottomboxlist 3]

set htl [.pw sash 0 [expr {$ybottombox + $hbottombox + $adjust }]]

puts "$hwin : $hpw : $adjust : $htl : $bottomboxlist : $ybottombox :
$hbottombox"
#300 : 295 : 5 : 169 : 2 145 110 19 : 145 : 19

Subject: Re: Another Tablelist question
From: Alan Grunwald
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sat, 16 Nov 2024 00:23 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: nospam.nurdglaw@gmail.com (Alan Grunwald)
Newsgroups: comp.lang.tcl
Subject: Re: Another Tablelist question
Date: Sat, 16 Nov 2024 00:23:32 +0000
Organization: A noiseless patient Spider
Lines: 90
Message-ID: <vh8ont$3lmt0$1@dont-email.me>
References: <vh86v6$3i2jm$1@dont-email.me> <vh8nbc$3lcgh$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 16 Nov 2024 01:24:29 +0100 (CET)
Injection-Info: dont-email.me; posting-host="4b2465890faf2c7bc7d4b2528c9cd859";
logging-data="3857312"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+MhePHpHGp9NQg5TXnZm0siFon/k9jRfw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:cbjE5HLEMiYWkvkm9OZ1Jk7Q7b8=
Content-Language: en-US
In-Reply-To: <vh8nbc$3lcgh$1@dont-email.me>
View all headers

On 16/11/2024 00:00, greg wrote:
> Am 15.11.24 um 20:20 schrieb Alan Grunwald:
>> How do I tell the height occupied by a row (or a few rows) in a
>> Tablelist?
>>
>> tl;dr
>>
>> I'm writing a GUI with a tablelist and a text widget displayed one
>> above the other in a paned window. I'd like to position the sash
>> programmatically so that the entire content of the tablelist is
>> visible, with the remaining space in the paned window occupied by the
>> text widget.
>>
>> I have observed that having the two widget heights in the ratio 1:3
>> works about right, but I'd like to get it spot on if I can.
>>
>> All the rows in the tablelist are the same height, so if I knew that
>> height I could easily work out how much space is required for the five
>> or six rows that I've inserted. On the other hand, one might
>> conceivably have rows of different heights, so something to get the
>> height of the first few rows (or maybe even any set of adjacent rows)
>> would be nice.
>>
>> Thanks again (in advance)
>>
>> Alan
>
> Hello,
>
> I find your question interesting.
> My script does not correspond to your suggestion.
> Perhaps bbox can help you.
>
> Gregor
>
> package require Tk
> package require tablelist
>
> # Main window
> ttk::panedwindow .pw -orient vertical
> pack .pw -fill both -expand true
>
> # Tablelist
> tablelist::tablelist .pw.tl -columns {0 "Name" left 0 "Value" center}
> -height 5
> .pw add .pw.tl -weight 0
>
> # Text
> text .pw.text -wrap word -background white
> .pw add .pw.text -weight 1
>
> # Tablelist insert datas
> set data {
>   {"Item 1" "10"}
>   {"Item 2" "20"}
>   {"Item 3" "30"}
>   {"Item 4" "40"}
>   {"Item 5" "50"}
>   {"Item 6" "60"}
>   {"Item 7" "70"}
> }
> foreach row $data {
>   .pw.tl insert end $row
> }
>
> # https://www.nemethi.de/tablelist/tablelistWidget.html#bbox
> wm geometry . 400x300
> update idle
> set hwin [winfo height .pw]
> set hpw [.pw sash 0 $hwin]
> set adjust [expr {$hwin - $hpw}]
>
> update idle
> #https://www.nemethi.de/tablelist/tablelistWidget.html#row_indices
> #bottom instead of end, if the entire table is not visible
> set bottomboxlist [.pw.tl bbox bottom]
> set ybottombox [lindex $bottomboxlist 1]
> set hbottombox [lindex $bottomboxlist 3]
>
> set htl [.pw sash 0 [expr {$ybottombox + $hbottombox + $adjust }]]
>
> puts "$hwin : $hpw : $adjust : $htl : $bottomboxlist : $ybottombox :
> $hbottombox"
> #300 : 295 : 5 : 169 : 2 145 110 19 : 145 : 19
Thanks Gregor,

That should do the trick! Too late to try it now, I'll have a go in the
morning and follow-up here.

Alan

1

rocksolid light 0.9.8
clearnet tor