Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

entry widget into table

Status
Not open for further replies.

daniele391

Programmer
May 12, 2008
4
0
0
IT
Hi,
I have to make a table whit every cell contain entry widget.
I saw from website and I find that example:

tixScrolledWindow .swin -scrollbar auto
set w [.swin subwidget window]
for {set x 0} {$x < 10} {incr x} {
pack [frame $w.f$x] -side left -fill y -expand yes
for {set y 0} {$y < 10} {incr y} {
pack [entry $w.f$x.e$y] -fill x -expand yes
}
}

The problem is that: I use tixGrid, and not tixScrolledWindows. I white that:

set grid [[tixScrolledGrid .sg -bd 0]subwidget grid]
$grid configure -formatcmd "SimpleFormat $grid"\
-height $row -width $column -background white
$grid set 0 0 -itemtype text -text "COLUMN 1"
$grid set 0 1 -itemtype text -text "COLUMN 2"

for {set i 1} {$i <= $row} {incr i} {
set valueList [lindex $list [expr $i-1]]
for {set j 1} {$j <= $column} {incr j} {
$grid set 0 $i -itemtype text -text [lindex $valueList 0]
$grid set 1 $i -itemtype text -text [lindex $valueList 1]
}
}

pack .sg

In this way, I see my table with correct value.
If I want to see entry widget into table's cells, instead of text? How I can do it?
Thanks and sorry for my English, but I'm italian.
Daniele


 
Daniele,
I have never used tix so I don't know how or if it supports what you want. However, I use the tkTable widget all the time and it is certainly adequate for what you describe.

Consider:
Code:
#scrolled table
package require Tktable 2.8
pack [table .tb1 -cols 5 -rows 12 -ysc ".ys set"] -side left
pack [scrollbar .ys -command ".tb1 yview"] -side right -fill y
entry .e1 -textvariable val1
.tb1 window configure 0,0 -window .e1
set val1 12

This makes a table in the main window (table .tb1 you could easily stick it into a sub-frame) of 5 columns (-cols 5) and 12 rows (-rows 12,either number can be anything), and attaches a vertical scrollbar. I define a single entry (entry .e1 -textvariable val1), but you can see how that could be any number of entries. I put the entry into the cell at 0,0, that is, the upper-most, left-most cell: .tb1 window configure 0,0 -window .e1

_________________
Bob Rashkin
 
Note, however, that the default behavior of cells in the tkTable widget is that of an entry. If instead of adding entries you simply assigned a -variable then the values entered into the table would be associated with matrix elements:
Code:
#scrolled table
package require Tktable 2.8
pack [table .tb1 -cols 5 -rows 12 -ysc ".ys set"] -side left
pack [scrollbar .ys -command ".tb1 yview"] -side right -fill y
.tb1 configure [red]-variable arrA[/red]
set arrA(3,3) 42

_________________
Bob Rashkin
 
Thanks for your help, but I've, now, another problem. My application can't find package Tktable 2.8

Another questions: I have to use tix widget because this is require from my client. The problem is:
if I use second code, the result is ok. If I use the second code with some piece of code from first code, the resutl is a table with one column, that contains correctly entry widget, but the windows blinks.
What's the problem?

Now I post the code that takes me problem:

set grid [[tixScrolledGrig .sg -bd 0] subwidget grid]
$grid configure -formatcmd "SimpleFormat $grid"\
-height $rows -width $columns -background white
$grid set 0 0 -itemtype text -text "COLUMN 1"
$grid set 0 1 -itemtype text -text "COLUMN 2"

for {set i 1} {$i <= $rows} {incr i} {
<font color="red">pack [frame .sg.f$i]</font>
set valueList [lindex $list [expr $i-1]]
for {set j 1} {$j <= $columns} {incr j} {
pack [entry .sg.f$i.e$j]
}
}

In the red piece of code, if I cut <font color="red">pack</font> the windows doesn't blink, but into table's cells I don't have entry widget.
If I write <font color="red">pack</font> te table's cells contains entry widget but the windows blink.
Do you understand me?
Daniele



 
Again, I don't have any idea of the proper syntax for tix. In the Table widget, you don't pack other widgets into the cell, but rather, as in my example above, you use a special window configure command. Is it possible that tix uses something similar?

Also, I assume your variables, $rows and $columns are properly set?

As far as the Tktable 2.8 package, you might have a newer (or older) version than I do. I'm using ActiveTcl 8.4.5.0, Tktable is part of that installation.

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top