require ‘wx’
require ‘Eyes.rb’
require ‘date.rb’
I am trying to close then mainframe window cleanly so I don’t have to
shut down ruby1.9 via `kill -9 …’. When I press cancel on the
first
(welcome) window it does exit cleanly. However when I try to shut
down
the main window using the close box, it hangs. It doesn’t even use
the
on_window_close window event. How do I rectify this situation? Any
help would be appreciated. If you want more info just ask. Thanks
Happy new year everyone!
Philip
class Main_Frame < EyesFrame
def on_init()
evt_close {|event| on_window_close(event)}
end
def on_window_close(event)
puts ("************")
destroy()
end
end
class EW_Dialog < EW_dialog
def on_init()
set_affirmative_id(Wx::ID_OK)
set_escape_id(Wx::ID_CANCEL)
end
end
class Waiter
This method waits x seconds to allow other processing to
take place such as opening a new window
def initialize(secs)
startTime = Time.new()
startSecs = startTime.hour() * 60 * 60
startSecs += (startTime.min() * 60)
startSecs += startTime.sec()
puts "startSecs #{startSecs}"
endSecs = startSecs + secs
puts "endSecs #{endSecs}"
currSecs = startSecs
while (currSecs < endSecs)
currTime = Time.new
currSecs = currTime.hour() * 60 * 60
currSecs += (currTime.min() * 60)
currSecs += currTime.sec()
puts ("currentsecs: #{currSecs}")
end
end
end
class MyApp < Wx::App
def on_init()
@screen1 = EW_Dialog.new
# show welcome dialog
case @screen1.show_modal()
when Wx::ID_CANCEL then
@screen1.close
puts(“Cancel”)
exit_main_loop()
when Wx::ID_OK
@screen1.close
@screen2 = Main_Frame.new()
@screen2.show
set_top_window(@screen2)
Waiter.new(1) #wait x seconds
end #case
end #def
end # class
app = MyApp.new
app.main_loop