tk variables

C

csjasnoch

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.
 
C

csjasnoch

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.
 
H

Hidetoshi NAGAI

From: "(e-mail address removed)" <[email protected]>
Subject: tk variables
Date: Tue, 30 Aug 2005 00:51:22 +0900
Message-ID: said:
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/ ).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,176
Messages
2,570,950
Members
47,504
Latest member
SherryFerr

Latest Threads

Top