How to close app after x seconds.

ralphz ralphzajac at sbcglobal.net
Sun Jun 8 20:51:53 EDT 2008


Hi

I have small app that I want to close tself after x seconds. Basically 
start show some message and close.

I come up with something like this but it does not work. Can anyone help 
me with it?

#!/usr/bin/env python

import wx
import time

class MyFrame(wx.Frame):
     def __init__(self, title, pos, size):
         wx.Frame.__init__(self, None, -1, title, pos, size)
         self.CreateStatusBar()
         self.SetStatusText("Some message here")

class MyApp(wx.App):
     def OnInit(self):

         self.frame = MyFrame('TITLE', (100, 100), (400,100))
         self.frame.Show()

         self.SetTopWindow(self.frame)
         self.ID_Timer = wx.NewEventType()
         self.timer = wx.Timer(self, self.ID_Timer)
         self.timer.Start(5000, False)
         self.Bind(wx.EVT_TIMER, self.appclose, self.timer)
#        wx.EVT_TIMER(self, self.ID_Timer, self.appclose)
         return True

     def appclose(self, evt):
         self.frame.Destroy()

if __name__ == '__main__':
     app = MyApp(0)
     app.MainLoop()

Ralph
http://TheOrangeIT.org



More information about the Python-list mailing list