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 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
GUI problem....

Posted by triclosan (triclosan), 17 August 2003
Hello friends!

Can anybody tell why this script don't working...

Code:
entry .e -textvariable st
pack .e


frame .rbut -bd 2 -relief groove

radiobutton .rbut.rb1 -variable f -value "dis" -text "checkbutton disabled" -command {
set st "disabled"      
}
radiobutton .rbut.rb2 -variable f -value "norm" -text "checkbutton normal" -command {
set st "normal"      
}
.rbut.rb1 invoke
pack .rbut.rb1  -side left
pack .rbut.rb2  -side left
pack .rbut -fill x

checkbutton .ch1 -variable f1 -text "My checkbutton" -state $st
pack .ch1



Posted by admin (Graham Ellis), 17 August 2003
Probably  

Can you help me narrow the problem down by telling me
a) What you want it to do
b) What it's actually doing


Posted by triclosan (triclosan), 17 August 2003
Radiobuttons must determined state of checkbutton (disabled or normal). By variable $st (it take value "disabled" or "normal").

Posted by admin (Graham Ellis), 17 August 2003
Oh - I think I see.   Your code sets the state of the checkbutton at the time it is created - it doesn't tie the variable to the checkbutton in any way.  To solve this, within the -command section of the radiobutton definitions, you should set the state of the checkbutton explicitly.

Posted by triclosan (triclosan), 17 August 2003
Sorry, but I don't understend how set this.

Can you make small sample of code.

However my script works with -variable section:

entry .e -textvariable st1
pack .e

frame .rbut -bd 2 -relief groove

radiobutton .rbut.rb1 -variable f -value "dis" -text "checkbutton disabled" -command {
set st1 0
}
radiobutton .rbut.rb2 -variable f -value "norm" -text "checkbutton normal" -command {
set st1 1
}
.rbut.rb1 invoke
pack .rbut.rb1  -side left
pack .rbut.rb2  -side left
pack .rbut -fill x  

checkbutton .ch1 -variable st1 -text "My checkbutton"
pack .ch1




Posted by admin (Graham Ellis), 17 August 2003
Yes, it would work that way ....

The example you posted earlier set the status of the checkbutton to reflect the contents of the variable st at the time the checkbutton was created, but it didn't set the checkbutton to update automatically by tieing the variable in any way.   The second example that you posted does tie the variable to the checkbutton ... so the checkbutton will be effected each time the variable changes.

If you want a "halfway house", where the checkbutton is only effected by radio button presses, you'll need to put an explicit update in the -command section as you define the radio buttons  - something like
      .ch1  configure  -state  normal
and
      .ch1  configure  -state  disabled

Posted by triclosan (triclosan), 17 August 2003
Thanks!!

It works perfectly!




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., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho