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

Can one set an entry textvariable to a color of choice?

Status
Not open for further replies.

wm7506

Technical User
Jun 21, 2010
1
US
Hi,

Fairly new to Tcl so please excuse if
silly question....

I have an entry widget that includes a
-textvariable VMname that gets read in
by the user's input. I then use tk_messageBox
to output an error if a bad value is entered
for VMname, including in the error message
the value of VMname. My question, is there a
way to change the color of this textvariable to
perhaps red from within tk_messageBox -message $VMname ??

It looks like default is just black and no easy way
to change color? Any ideas, suggestions, tips, or
pointers to examples would be much appreciated!!


proc get_virtual {} {
set VMname ""
destroy .lab .ent
label .lab -text "Input your Virtual Machine Name:"
# Create an entry widget, named .ent
entry .ent -textvariable VMname
focus .ent
pack .lab
pack .ent
bind .ent <Return> {
puts "the virtual machine name is: $VMname";
if {[catch {exec /opt/SUNWuttsc/bin/uttsc -m -b -A 16 -r sound:low $VMname} result] } {
tk_messageBox -title Error -detail "Invalid Virtual Machine name:\n \"$VMname\"\n Please Re-Enter" -icon error -type ok
return
# error "$VMname: Invalid VM Name - Re-Input"
}
# set status [catch {exec /opt/SUNWuttsc/bin/uttsc -m -b -A 16 -r sound:low $VMname} result]
set VMname ""
destroy .lab .ent
}
}


Thanks in advance,
Bill

bill.mutchie@oracle.com




 
I think you'll have to get clever with tk_setPalette
tk_setPalette, tk_bisque - Modify the Tk color palette

SYNOPSIS
tk_setPalette background
tk_setPalette name value ?name value ...?
tk_bisque


DESCRIPTION
The tk_setPalette procedure changes the color scheme for Tk. It does this by modifying the colors of existing widgets and by changing the option database so that future widgets will use the new color scheme. If tk_setPalette is invoked with a single argument, the argument is the name of a color to use as the normal background color; tk_setPalette will compute a complete color palette from this background color. Alternatively, the arguments to tk_setPalette may consist of any number of name-value pairs, where the first argument of the pair is the name of an option in the Tk option database and the second argument is the new value to use for that option. The following database names are currently supported:

activeBackground foreground selectColor
activeForeground highlightBackground selectBackground
background highlightColor selectForeground
disabledForeground insertBackground troughColor

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top