Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #6984
| Newsgroups | comp.lang.ruby |
|---|---|
| Date | 2014-06-02 07:42 -0700 |
| Message-ID | <23f95ed8-7cd2-4170-8515-e1a834533aa7@googlegroups.com> (permalink) |
| Subject | how to change the status of a checkbutton interactively |
| From | chen1069osu@gmail.com |
Hi all,
I am new to tk. I try to build a simple GUI with several widgets following the tutorials from this website:http://www.tkdocs.com/tutorial/widgets.html#checkbutton
One of the widgets I copy from website is checkbutton as following:
require 'tk'
require 'tkextlib/tile'
root = TkRoot.new {title "Feet to Meters"}
$measureSystem = TkVariable.new
check = Tk::Tile::CheckButton.new(root) {
text 'Use Metric';
command 'metricChanged';
variable $measureSystem;
onvalue 'metric';
offvalue 'imperial';
pack
}
Tk.mainloop
when I check the checkbutton, I get an error message as following:
NameError: undefined local variable or method `metricChanged' for main:Object
---< backtrace of Ruby side >-----
C:/Ruby200-x64/lib/ruby/2.0.0/tk.rb:1456:in `cb_eval'
C:/Ruby200-x64/lib/ruby/2.0.0/tk.rb:1456:in `eval_cmd'
C:/Ruby200-x64/lib/ruby/2.0.0/tk.rb:1456:in `cb_eval'
C:/Ruby200-x64/lib/ruby/2.0.0/tk.rb:1403:in `call'
C:/Ruby200-x64/lib/ruby/2.0.0/tk.rb:1599:in `block in callback'
C:/Ruby200-x64/lib/ruby/2.0.0/tk.rb:1598:in `catch'
C:/Ruby200-x64/lib/ruby/2.0.0/tk.rb:1598:in `callback'
C:/Ruby200-x64/lib/ruby/2.0.0/tk.rb:1305:in `mainloop'
C:/Ruby200-x64/lib/ruby/2.0.0/tk.rb:1305:in `block in <module:TkCore>'
---< backtrace of Tk side >-------
invoked from within
"rb_out c00001"
invoked from within
".w00000 invoke "
invoked from within
".w00000 instate !disabled { .w00000 invoke } "
invoked from within
".w00000 instate pressed { .w00000 state !pressed; .w00000 instate !disabled { .w00000 invoke } } "
(command bound to event)
so my question is that why this happens? How come I cannot set the check or uncheck from user end or set its status interactively?
Thank you so much in advance for your help.
Back to comp.lang.ruby | Previous | Next | Find similar
how to change the status of a checkbutton interactively chen1069osu@gmail.com - 2014-06-02 07:42 -0700
csiph-web