From: "csjasnoch / wisc.edu" <csjasnoch / wisc.edu> Subject: tk variables Date: Tue, 30 Aug 2005 00:51:22 +0900 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, ------------------------------------------------- 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)