| ||||
radiobutton Posted by dee00zee (dee00zee), 17 June 2005 I need a little help here..I try to make a simple gui using radiobutton. I want the gui to behave this way, when a user select Yes, only enable her to enter inputs at the entry, if she select No then, the entry will not be able to accept input. As you can see in my code, I try to config the background when the user select No, but it produce error. Code: #!/usr/local/bin/wish frame .top -borderwidth 5 pack .top -side top -fill x entry .top.ent -width 30 -relief sunken -background white -textvariable path radiobutton .top.rad1 -text Yes -variable choice -value Yes radiobutton .top.rad2 -text No -variable choice -value No -command {if $choice == No { \ .top.ent config - background grey }\ } label .top.lab -text "Macro KO Box" -pady 2 pack .top.ent -side right -padx 10 pack .top.lab -side left pack .top.rad1 .top.rad2 -side left Posted by admin (Graham Ellis), 17 June 2005 Tcl is interpretted at runtime, so error messages in the syntax are only shown up when you happen to run the fault piece of code and not at compile time. I think you have the following errors in the block that The - sign is part of the option - so you if you want to use the background option (for example) you shouldn't use spaces - in other words, write -background rather than - background. The { on the previous line should probably be a } (or is it just a } missing, or a { in the if missing?) The }\ looks to be excess to requirements and will also cause an error. (It may be correct if you need that extra } I just mentioned ... sorry ... my coding style would be a bit different: Code:
If you want to disable an entry button -state disabled will actually prevent the user from entering data there. Changing the background colour (as in your sample code) will just make it look inactive but won't stop a determined user. If you want to re-enable entry later, use -state normal This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
| ||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |