[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby/Tk : Accessing a Checkbox

u235321044

2/23/2006 1:30:00 PM

How can I find out whether a Checkbox is checked or unchecked in Ruby?

Here is my Checkbox definition (hope it is correct):

$bpmto_check=TkCheckButton.new(bpmto_frame);

How can I find the state of the checkbox? I tried the .value
member (like in the entry field), but this is not defined
for checkboxes.

I have searched several tutorials on Ruby/Tk, but did not find
one which covers checkboxes. Is there a reference manual
available, or man pages, which covers the Tk extensions of Ruby?

Ronald




--
Sent by mn-pg-p-e-b-consultant-3.com from siemens subdomain of com
This is a spam protected message. Please answer with reference header.
Posted via http://www.usenet-re...
3 Answers

dperkins

2/23/2006 2:19:00 PM

0

> How can I find out whether a Checkbox is checked or unchecked in Ruby?
>
> Here is my Checkbox definition (hope it is correct):
>
> $bpmto_check=TkCheckButton.new(bpmto_frame);
>
> How can I find the state of the checkbox? I tried the .value
> member (like in the entry field), but this is not defined
> for checkboxes.
>
> I have searched several tutorials on Ruby/Tk, but did not find
> one which covers checkboxes. Is there a reference manual
> available, or man pages, which covers the Tk extensions of Ruby?
>
> Ronald

You need a TkVariable associated with the checkbutton.

var = TkVariable.new

$pbmto_check = TkCheckButton.new(pbmto_frame) do
variable var
pack
end





Hidetoshi NAGAI

2/23/2006 3:11:00 PM

0

dperkins

2/23/2006 5:08:00 PM

0


> Latest Ruby/Tk supports a default variable of a checkbutton.
> So, you don't need define a TkVariable. For example,
> -------------------------------------------------------------
> irb(main):002:0> $pbmto_check = TkCheckButton.new(pbmto_frame)
> => #<TkCheckButton:0xb7c48a8c @path=".w00000.w00001">
> irb(main):003:0> $pbmto_check.get_value
> => "0"

Great! I'll add this to my Rubyt/Tk notes.