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
 
This week, we're updating our course layouts and descriptions. Presentation and materials always gently change over time, but just occasionally there's a need to make a step change to clear out some of the old and roll in the new. That's now happening - but over a long and complex site it's not instant and you'll see sections of the site changing up to and including 19th September.

See also [here] for status update
 
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:
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 www.opentalk.org.uk 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., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho