Paul Carvalho
2007-May-31 20:34 UTC
[fxruby-users] How can I make a window stay open for a set amount of time?
Hi there, I have this script that I want to go away after a few minutes. I''m new to FxRuby and don''t know how to use the addTimeout() method though. Can someone please help me with this sample ''hello world'' script below? ---- require ''fox14'' include Fox application = FXApp.new("Hello", "FoxTest") main = FXMainWindow.new(application, "Hello", nil, nil, DECOR_ALL) FXButton.new(main, "&Hello, World!", nil, application, FXApp::ID_QUIT) application.create() delay = 5 * 1000 # (time is in milliseconds) application.addTimeout( delay, exit ) main.show(PLACEMENT_SCREEN) application.run() ---- I want the window to display for 5 seconds and disappear. When I run the above script nothing seems to happen though. The window never appears. Suggestions? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/fxruby-users/attachments/20070531/8a59b017/attachment.html
Joel VanderWerf
2007-May-31 20:39 UTC
[fxruby-users] How can I make a window stay open for a set amount of time?
Paul Carvalho wrote:> Hi there, I have this script that I want to go away after a few > minutes. I''m new to FxRuby and don''t know how to use the addTimeout() > method though. > > Can someone please help me with this sample ''hello world'' script below? > > ---- > require ''fox14'' > include Fox > > application = FXApp.new("Hello", "FoxTest") > main = FXMainWindow.new(application, "Hello", nil, nil, DECOR_ALL) > FXButton.new (main, "&Hello, World!", nil, application, FXApp::ID_QUIT) > application.create() > > delay = 5 * 1000 # (time is in milliseconds) > application.addTimeout( delay, exit ) > > main.show(PLACEMENT_SCREEN) > application.run()I tested this in 1.6, but I think it''s probably the same in 1.4: application.addTimeout( delay ) { application.exit } -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
Paul Carvalho
2007-May-31 20:54 UTC
[fxruby-users] How can I make a window stay open for a set amount of time?
Thank you!! It works perfectly. I never would have figured that out. Cheers! Paul. =) On 31/05/07, Joel VanderWerf wrote:> > I tested this in 1.6, but I think it''s probably the same in 1.4: > > application.addTimeout( delay ) { application.exit } >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/fxruby-users/attachments/20070531/d305249a/attachment.html
Joel VanderWerf
2007-May-31 22:03 UTC
[fxruby-users] How can I make a window stay open for a set amount of time?
Paul Carvalho wrote:> Thank you!! It works perfectly. I never would have figured that out. > > Cheers! Paul. =) > > On 31/05/07, *Joel VanderWerf* wrote: > > I tested this in 1.6, but I think it''s probably the same in 1.4: > > application.addTimeout( delay ) { application.exit }It''s a general ruby principle. If you are asking a library to execute some of your own code at a later time or after some event (i.e., a "callback"), it probably wants that code in the form of a block. Assuming the library is rubified... It never ceases to amaze me that a complex c++ library like Fox has been wrapped in a way that makes its ruby API look so natural. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407