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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing colour for disabled text

Status
Not open for further replies.

spheniscus

Technical User
Feb 24, 2004
2
CH
Hello,

First I must explain I would not consider myself a "programer". Anyway, I have written a small program in tcl/tk.

My problem is that I used the "-state disabled" property to prevent users to change data in some input fields. This causes the text to be very pale.

On normal computer screens this is not a problem. However, I got the program to run a my PDA, it become unreadable.

Is there a way?
a) to change this colour
b) to prevent access to a field without giving it a desabled state

Thanks,

Thierry de Coulon
 
I assume the data input mechansim is an "entry widget. If so, the answer is "yes" to both.

from the spec for the "entry" widget:
Command-Line Name: -disabledforeground
Database Name: disabledForeground
Database Class: DisabledForeground
Specifies the foreground color to use when the entry is disabled. If this option is the empty string, the normal foreground color is used.

An alternative state (to 'disabled') is 'readonly'(the color will not be altered):
Command-Line Name: -state
Database Name: state
Database Class: State
Specifies one of three states for the entry: normal, disabled, or readonly. If the entry is readonly, then the value may not be changed using widget commands and no insertion cursor will be displayed, even if the input focus is in the widget; the contents of the widget may still be selected. If the entry is disabled, the value may not be changed, no insertion cursor will be displayed, the contents will not be selectable, and the entry may be displayed in a different color, depending on the values of the -disabledforeground and -disabledbackground options.

Then, if you're really keen on making this more complicated than it needs to be, you can use the -validate option and not allow any input at all:
Command-Line Name: -validate
Database Name: validate
Database Class: Validate
Specifies the mode in which validation should operate: none, focus, focusin, focusout, key, or all. It defaults to none. When you want validation, you must explicitly state which mode you wish to use. See Validation below for more.
Command-Line Name: -validatecommand or -vcmd
Database Name: validateCommand
Database Class: ValidateCommand
Specifies a script to eval when you want to validate the input into the entry widget. Setting it to {} disables this feature (the default). This command must return a valid tcl boolean value. If it returns 0 (or the valid tcl boolean equivalent) then it means you reject the new edition and it will not occur and the invalidCommand will be evaluated if it is set. If it returns 1, then the new edition occurs. See Validation below for more information.


Bob Rashkin
rrashkin@csc.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top