Hi I have a requirement where i need to create table and the cells would be readonly. But along with readonly mode, the cells need to have colored background. Now with the given options, i tried doing something like below but with no luck. Since I am learning GUI designing, I am not sure if getting colored background with readonly mode is possible with given commands :
package require Tk
set val1 "12";
set cols 5;
set rows 5;
set cell 0;
set mytable [table .tb -cols $cols -rows $rows];
set myentry [entry .e1 -textvariable val1 -state readonly -background red];
#set myentry [entry .e1 -textvariable val1 -background red];
set myentry1 [entry .e2 -textvariable val1 -state readonly -background yellow];
#set myentry1 [entry .e2 -textvariable val1 -background yellow];
$mytable window configure 0,1 -window $myentry;
$mytable window configure 3,0 -window $myentry1;
pack $mytable -fill both -expand true;
So if I use the state readonly, then it greys out the cells and the background color gets hidden or something, but if I remove the state readonly, the background color shows up but the cells are editable.
I am wondering if there is a way to get the desired background color of the cell along with readonly state. I don't know much but was thinking that if I can bind button-1 event in some way that if user clicks, the cell won't do anything.
In this wiki page in "Widget States" section, it does say that in disabled state the selection is not allowed, but in readonly the selection is allowed and different background is used. But it doesn't say that if the different background is used, then how to set it?? or does it just mean that a different shade of grey is used...
Not sure if my thought is correct so please any comments???
The manual page for entry, specifies that the -readonlybackground
option will change the background color for entry widgets in read-only mode.