[fxruby-users] How can I make a window stay open for a set amount of time?

Joel VanderWerf vjoel at path.berkeley.edu
Thu May 31 16:39:15 EDT 2007


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


More information about the fxruby-users mailing list