Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.

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.



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:

radiobutton .top.rad2 -text No -variable choice -value No -command {
        if {$choice == No} {  
                   .top.ent config -background grey

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 and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho