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

simple tktable help

5 views
Skip to first unread message

3rdshiftcoder

unread,
Oct 12, 2008, 2:38:01 PM10/12/08
to
array set cells {
0,1 London 0,2 Reading
0,3 Gloucester 0,4 Swindon
}

AccountTbl configure -variable cells -rows 3 -cols 3

hi- i am not sure how to get the values in the array "cells"
to appear in the tktable. AccountTbl is an alias??
what is the equivalent of "activate" to get the array
to show in the grid??

------------------------------------------------------------
for a textentry control i do something like this:
AccountName configure -text $ACCOUNTNAME

and the textentry populates with some data i coded
with sqlite tcl api (not shown here).

thanks for any tips..
3rdshiftcoder

Helmut Giese

unread,
Oct 12, 2008, 4:17:09 PM10/12/08
to
On Sun, 12 Oct 2008 18:38:01 GMT, 3rdshiftcoder <n...@email.address>
wrote:

>array set cells {
>0,1 London 0,2 Reading
>0,3 Gloucester 0,4 Swindon
>}
>
>AccountTbl configure -variable cells -rows 3 -cols 3
>
>hi- i am not sure how to get the values in the array "cells"
>to appear in the tktable. AccountTbl is an alias??
>what is the equivalent of "activate" to get the array
>to show in the grid??

Hi,
does this get you started?
---
package require Tktable
array set cells {
0,0 London 0,1 Reading
0,2 Gloucester 0,3 Swindon
}
set tbl [table .accountTbl -rows 1 -cols 4 \
-variable cells]
pack $tbl
---
Notes:
1) Row _and_ column indices start at 0.
2) The table is a widget so it has to conform to the naming rules for
widgets:
- The name starts with a '.' and
- the first letter must not be a capital letter.

If you got the ActiveState distro (if not, you should get it) you find
several examples in the .../demos/tktable subdir.
HTH
Helmut Giese

3rdshiftcoder

unread,
Oct 12, 2008, 4:19:02 PM10/12/08
to
hi-
here is my code from the procedure window in visual tcl
guibuilder. how come the last line of code listed below
wont update the tktable display? configure command doesnt seem to
work like it did with the textentry widget.

i hope this is a little clearer than my original question.
thanks for any help. i am very stuck on this and am wasting
hours on my weekend trying to solve it. i am frustrated
that the book i bought has not one mention of tktable
anywhere in the book.

global widget

load /home/thirdshift/sqlite/tclsqlite-3.6.3.so sqlite3

sqlite3 db1 /home/thirdshift/sqlite/account1.db

set testval [AccountId cget -text]

set val [db1 eval {Select * from Accounts}]

# tk_messageBox -message $val -type ok
db1 eval {SELECT * FROM Accounts } values {

}


db1 eval {Select * from Accounts where ACCOUNTID = $testval } {

}

set fail [catch {expr $ACCOUNTID * 1} result]

if {$fail} {
error "empty sql"
# non numeric data test
} else {
AccountName configure -text $ACCOUNTNAME
}

db1 close

3rdshiftcoder

unread,
Oct 12, 2008, 4:54:12 PM10/12/08
to
Hi Helmut-

i used your exact code except i changed the
window path so it would appear on my screen.
a 1 row table displays but there are no values
in the cells. i can type values into the cells like
numbers and they appear but using code seems to display
no values in the cells. it is the same issue i have had
all afternoon :-(

here is what i used.

thanks for helping me,
jim

package require Tktable
array set cells {
0,0 London 0,1 Reading
0,2 Gloucester 0,3 Swindon
}

set tbl [table .top86.not87.fpage1.fra119.tab129 -rows 1 -cols 4 \
-variable cells]
pack $tbl

Helmut Giese

unread,
Oct 12, 2008, 5:54:11 PM10/12/08
to
Hi,
when I doubleclick on the file containing the following code I see a
table with three rows (changed from the first example) and four
columns with the first row containing the names of the cities.
--- file tbl.tcl ---

package require Tktable
array set cells {
0,0 London 0,1 Reading
0,2 Gloucester 0,3 Swindon
}
set tbl [table .accountTbl -rows 3 -cols 4 \
-variable cells]
pack $tbl
---
If you don't see this I have no idea what the reason might be - it
works for me (on Windows XP) under Tcl 8.4 as well as 8.5.
I _strongly_ suggest creating a stand alone file containing just the
above lines - I am pretty sure that it will work.

Now, how to add values to (currently empty) cells: In an interactive
session I did this:
(tmp) 31 % source tbl.tcl
(tmp) 32 % $tbl set 1,0 abc
(tmp) 33 % $tbl set 1,1 def
(tmp) 34 % $tbl set 2,0 ABC
(tmp) 35 % parray cells
cells(0,0) = London
cells(0,1) = Reading
cells(0,2) = Gloucester
cells(0,3) = Swindon
cells(1,0) = abc
cells(1,1) = def
cells(2,0) = ABC
cells(active) =
(tmp) 36 %
and after every command "$tbl set ..." the value showed up in the
chosen cell. The last command (parray cells) shows that the
corresponding entry in the 'cells' array fills accordingly.

I am turning off now - my shift is over :)
Good luck
Helmut Giese

3rdshiftcoder

unread,
Oct 12, 2008, 6:29:55 PM10/12/08
to
> I am turning off now - my shift is over :) Good luck
> Helmut Giese

thanks Helmut.

it didnt solve it. yes i see that the code works as advertised
but it is not working in visual tcl.
so there lies the problem.

i cant use configure in visual tcl to set the
array for the table and view my changes.

i dont know why at the moment.

it really stressed me out today.

i really appreciating you taking the time to help me on that.
if i dont solve it soon, i think i will go crazy.
at least i know that i had the logic right and to look elsewhere.

thanks

3rdshiftcoder

unread,
Oct 12, 2008, 8:01:01 PM10/12/08
to
On Sun, 12 Oct 2008 22:29:55 +0000, 3rdshiftcoder wrote:

>> I am turning off now - my shift is over :) Good luck Helmut Giese
>
> thanks Helmut.
>

hi Helmut-
i had to add
global cells to the top of my proc
window in visual tcl so they could see
the value in cells array i had set from
inside the proc.

something so simple. i thought i had tried
that earlier but i am sure something else
confounded things.

so my wonderful weekend of productivity was
not so productive.

thanks so much

Helmut Giese

unread,
Oct 13, 2008, 11:38:07 AM10/13/08
to
Hi,

>hi Helmut-
>i had to add
>global cells to the top of my proc
>window in visual tcl so they could see
>the value in cells array i had set from
>inside the proc.
glad you solved the problem.

Maybe a tip for the future:
If you are fighting with a widget or a particular language feature or
whatever:
- Leave your current context - in your example: forget about the DB
and Visual Tcl - they only add complexity.
- Concentrate _only_ on the problem at hand. In a couple of lines you
can create a basic setup with which to experiment (see e.g. my tktable
example).
- If you don't find a solution: Post this 'minimal setup' here. People
than can actually run it - nobody could have run the code you posted -
which greatly increases the chance that someone will be able to help.

Best regards
Helmut Giese

3rdshiftcoder

unread,
Oct 13, 2008, 3:58:31 PM10/13/08
to

re: eliminating db stuff and gui builder stuff etc.
when posting for help (code samples).
sounds cool.

ok.

thanks Helmut.

jim

0 new messages