Tk variables

Is it possible to initialize the tk variables so the effect is shown in
say buttons.

For example a checkbox:

check1 = TkVariable.new
TkCheckButton.new(buttonFrm){
      variable check1
      command active1ButtonChecked
    }.pack('side'=>'left')

The idea is I want it to open as my file states it should... So I have
a string
0:0:0:1:0:1:0:0:0

so if these were some check box variables when the program starts there
is read and I want to initialize the 4th and 6th check box to
"checked" and the rest unchecked.

I also want to be able to do this with buttons with image binded.

Thank you for you help.

I am able to handle the button image as I had already created a method
to handle this. Now I just do a call to this durring initialize (after
my file has been read)... however I can't find away to configure check
boxes.

Message-ID: <1125330668.043332.268500@g43g2000cwa.googlegroups.com>

For example a checkbox:

check1 = TkVariable.new
TkCheckButton.new(buttonFrm){
      variable check1
      command active1ButtonChecked
    }.pack('side'=>'left')

The idea is I want it to open as my file states it should... So I have
a string
0:0:0:1:0:1:0:0:0

TkVariable.new accepts an initial value.
For example,

···

From: "csjasnoch@wisc.edu" <csjasnoch@wisc.edu>
Subject: tk variables
Date: Tue, 30 Aug 2005 00:51:22 +0900
-------------------------------------------------
buttonFrm = TkFrame.new.pack
s = '0:0:0:1:0:1:0:0:0:1:0:0'
v_list =
s.split(':').each_with_index{|val, idx|
    v_list << (v = TkVariable.new(val))
    TkCheckButton.new(buttonFrm, :variable=>v,
                      :text=>"state #{idx}").pack(:anchor=>:w, :fill=>:x)
}
-------------------------------------------------

I also want to be able to do this with buttons with image binded.

Please use 'image', 'selectimage' and 'indicatoron' option of
checkbutton widgets.

# See also "icon.rb" which is part of "Ruby/Tk widget demo"
# ( <ruby source>/ext/tk/sample/demo-en/ ).
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)