How to make TkLabel update immediately?

Hi,

I’m putting out some text in a window using a TkLabel. The problem is
that the text only seems to appear once the method has finished.
Is there a way to make labels update after .configure immediately?

Code example:
btnExit = TkButton.new() do
text "Exit"
command {
label.configure (“text” => ‘Good bye!’) #never appears!
sleep 2
exit
}
end

Thanks!
Ralf.

pm. Is there an “official” tk and/or gtk newsgroup? Where can I find the
archive of this Ruby group?

I found the archive.
(http://blade.nagaokaut.ac.jp/ruby/comp.lang.ruby/index.shtml#comp.lang.ruby)

···

Hi,

I’m putting out some text in a window using a TkLabel. The problem is
that the text only seems to appear once the method has finished.
Is there a way to make labels update after .configure immediately?

Code example:
btnExit = TkButton.new() do
text “Exit”
command {
label.configure (“text” => ‘Good bye!’) #never appears!
sleep 2
exit
}
end

Thanks!
Ralf.

pm. Is there an “official” tk and/or gtk newsgroup? Where can I find the
archive of this Ruby group?

Hi,

···

From: Ralf lausianne@gmx.net
Subject: How to make TkLabel update immediately?
Date: Fri, 17 Jan 2003 18:05:12 +0900
Message-ID: 3e27c499$1@epflnews.epfl.ch

I’m putting out some text in a window using a TkLabel. The problem is
that the text only seems to appear once the method has finished.
Is there a way to make labels update after .configure immediately?

Tk re-draws widgets on a idle-task.
Because an operation of the ‘command’ option is one event-task,
Tk never call an idle-task before ‘exit’ of your script.
You must call ‘Tk.update’ or ‘Tk.update(true)’.
‘Tk.update(true)’ forces to run Tk’s idle-task.
For example,

Code example:
btnExit = TkButton.new() do
text “Exit”
command {
label.configure (“text” => ‘Good bye!’) #never appears!

     Tk.update    # <= You need this !!
   sleep 2
   exit
 }

end


Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)