V
Valen Onish
I have:
1. $lb_1 = TkLabel.new(root){..} - label
2. bt_toss=TkButton.new(root){..} - button
I want when I press the button: 1. label's background is changed
to blue
2. display changed label's
background
3. sleep(0.5)
4. label's background is changed
to green
5. display changed label's
background
but I see only the last colour.
here the code:
require 'tk'
root = TkRoot.new { title "Ruby/Tk Example" }
$lb_1 = TkLabel.new(root){
background "red"
foreground "blue"
text "Your area"
font "system,12"
place('relx'=>0.4, 'rely'=>0.08)
}
bt_toss=TkButton.new(root){
text "Toss"
command proc{change_colour}
place('relx'=>0.2, 'rely'=>0.78)
}
def change_colour
$lb_1.configure('background'=>'blue')
sleep(0.5)
$lb_1.configure('background'=>'green')
sleep(0.5)
$lb_1.configure('background'=>'gray')
end
Tk.mainloop
1. $lb_1 = TkLabel.new(root){..} - label
2. bt_toss=TkButton.new(root){..} - button
I want when I press the button: 1. label's background is changed
to blue
2. display changed label's
background
3. sleep(0.5)
4. label's background is changed
to green
5. display changed label's
background
but I see only the last colour.
here the code:
require 'tk'
root = TkRoot.new { title "Ruby/Tk Example" }
$lb_1 = TkLabel.new(root){
background "red"
foreground "blue"
text "Your area"
font "system,12"
place('relx'=>0.4, 'rely'=>0.08)
}
bt_toss=TkButton.new(root){
text "Toss"
command proc{change_colour}
place('relx'=>0.2, 'rely'=>0.78)
}
def change_colour
$lb_1.configure('background'=>'blue')
sleep(0.5)
$lb_1.configure('background'=>'green')
sleep(0.5)
$lb_1.configure('background'=>'gray')
end
Tk.mainloop