Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #2: solar flares


comp / comp.lang.tcl / Re: tablelist and cellindex

SubjectAuthor
* tablelist and cellindexgreg
`* Re: tablelist and cellindexgreg
 `- Re: tablelist and cellindexgreg

1
Subject: tablelist and cellindex
From: greg
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sun, 19 May 2024 09:17 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gregor.ebbing@gmx.de (greg)
Newsgroups: comp.lang.tcl
Subject: tablelist and cellindex
Date: Sun, 19 May 2024 11:17:21 +0200
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <v2cg31$3adgp$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 19 May 2024 11:17:22 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5fd8bd58b3b2453f77f3f2cdc283e156";
logging-data="3487257"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19hSyK5HHG8K8JkiWt1VKqDZlKBbJMNa/A="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:iEf7NLeeZi/pYO7KU6/VDNyc6pw=
Content-Language: de-DE
View all headers

Hello,

I have a problem with cellindex.
Why is cellindex (ci) not as expected in my example?
So the wrong line.
But it will always output the correct column.

mfg
Gregor

#example script
package require tablelist
proc cmd {tbl W x y} {
set ci [$tbl cellindex @$x,$y]
set cia [$tbl cellindex active]
set ria [$tbl index active]
puts "$tbl $W $x $y :: cia: $cia ria: $ria :: ci $ci"
}

tablelist::tablelist .tbl -columns {0 "ID" right 10 "Name" left 0
"Class" center}
bind [.tbl bodytag] <Double-1> [list cmd .tbl %W %x %y ]
pack .tbl -fill both -expand true

..tbl insert end {0 Herbert 0a}
..tbl insert end {1 Anna 1a}
..tbl insert end {2 Lisa 2l}
..tbl insert end {3 Werner 3w}

#Output:
if {0} {
Output
..tbl .tbl.body 46 8 :: cia: 0,0 ria: 0 :: ci 0,1
..tbl .tbl.body 40 33 :: cia: 1,0 ria: 1 :: ci 0,1
..tbl .tbl.body 35 48 :: cia: 2,0 ria: 2 :: ci 1,1
..tbl .tbl.body 35 61 :: cia: 3,0 ria: 3 :: ci 1,1

expected Output
..tbl .tbl.body 46 8 :: cia: 0,0 ria: 0 :: ci 0,1
..tbl .tbl.body 40 33 :: cia: 1,0 ria: 1 :: ci 1,1
..tbl .tbl.body 35 48 :: cia: 2,0 ria: 2 :: ci 2,1
..tbl .tbl.body 35 61 :: cia: 3,0 ria: 3 :: ci 3,1
}

Subject: Re: tablelist and cellindex
From: greg
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sun, 19 May 2024 13:25 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: tablelist and cellindex
Date: Sun, 19 May 2024 15:25:00 +0200
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <v2cujd$3d774$1@dont-email.me>
References: <v2cg31$3adgp$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 19 May 2024 15:25:01 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5fd8bd58b3b2453f77f3f2cdc283e156";
logging-data="3579108"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/K8oqTFnypWfTWN9gD5YZ2FR6xFswD+oo="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:nTygZtvU49QKafq2JFd4wirNomk=
In-Reply-To: <v2cg31$3adgp$1@dont-email.me>
Content-Language: de-DE
View all headers

It works now.
I adjusted X and Y.
X and Y instead of x and y

mfg
Gregor

#example script:
package require tablelist
proc cmd {tbl W X Y} {
#set x [expr {$X - [winfo rootx $W]}]
#set y [expr {$Y - [winfo rooty $W]}]
set x [expr {$X - [winfo rootx $tbl]}]
set y [expr {$Y - [winfo rooty $tbl]}]

set ci [$tbl cellindex @$x,$y]
set cia [$tbl cellindex active,active]
set gia [$tbl getcell @$x,$y]
set ria [$tbl index active]
set coli [$tbl columnindex @$x,$y]
puts "$tbl $W $x $y :: cia: $cia ria: $ria :: ci $ci :: gia $gia
:: coli $coli"
}

tablelist::tablelist .tbl -columns {0 "ID" right 10 "Name" left 0
"Class" center}
bind [.tbl bodytag] <Double-1> [list cmd .tbl %W %X %Y]
pack .tbl -fill both -expand true

..tbl insert end {0 Herbert 0a}
..tbl insert end {1 Anna 1a}
..tbl insert end {2 Lisa 2l}
..tbl insert end {3 Werner 3w}

#Output:
if {0} {
Output
..tbl .tbl.body 59 31 :: cia: 0,0 ria: 0 :: ci 0,1 :: gia Herbert :: coli 1
..tbl .tbl.body 154 50 :: cia: 1,0 ria: 1 :: ci 1,2 :: gia 1a :: coli 2
..tbl .tbl.body 58 72 :: cia: 2,0 ria: 2 :: ci 2,1 :: gia Lisa :: coli 1
..tbl .tbl.body 146 94 :: cia: 3,0 ria: 3 :: ci 3,2 :: gia 3w :: coli 2

}

Subject: Re: tablelist and cellindex
From: greg
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Mon, 20 May 2024 05:02 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gregor.ebbing@gmx.de (greg)
Newsgroups: comp.lang.tcl
Subject: Re: tablelist and cellindex
Date: Mon, 20 May 2024 07:02:16 +0200
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <v2elgo$3qtui$1@dont-email.me>
References: <v2cg31$3adgp$1@dont-email.me> <v2cujd$3d774$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 20 May 2024 07:02:16 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="aed7108b87c95bb6e62f256f6f4ee3b1";
logging-data="4028370"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/C3YsS1oBLNVl4lf0QlHcF09OfXa6dQFc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Eimgc4kD6E53UabPPWSKiLz9XpM=
In-Reply-To: <v2cujd$3d774$1@dont-email.me>
Content-Language: de-DE
View all headers

It also works with x y
and tablelist::convEventFields

It's all in the Tablelist documentation. :-)

#https://www.nemethi.de/tablelist/tablelistBinding.html#convEventFields
#example script:
package require tablelist
proc cmd {tbl W x y} {
#difference x y or X Y
lassign [tablelist::convEventFields $W $x $y] convW x y

set ci [$tbl cellindex @$x,$y]
set cia [$tbl cellindex active]
set gia [$tbl getcell @$x,$y]
set ria [$tbl index active]
set coli [$tbl columnindex @$x,$y]
puts "$tbl $W $x $y :: cia: $cia ria: $ria :: ci $ci :: gia $gia
:: coli $coli"
}

tablelist::tablelist .tbl -columns {0 "ID" right 10 "Name" left 0
"Class" center}
#difference x y or X Y
bind [.tbl bodytag] <Double-1> [list cmd .tbl %W %x %y]
pack .tbl -fill both -expand true

..tbl insert end {0 Herbert 0a}
..tbl insert end {1 Anna 1a}
..tbl insert end {2 Lisa 2l}
..tbl insert end {3 Werner 3w}

1

rocksolid light 0.9.8
clearnet tor