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
>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
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
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
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
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
>> 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
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
ok.
thanks Helmut.
jim