473,473 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to close app after x seconds.

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
Jun 27 '08 #1
1 1399
CM
On Jun 8, 8:51 pm, ralphz <ralphza...@sbcglobal.netwrote:
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()

Ralphhttp://TheOrangeIT.org
It works for me just fine. How is it not working for you?

By the way, showing your message in the statusbar is not a
good display method--it's small and it is only seen in conjunction
with a frame above it that is doing something. You could just put
the message as staticText.
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Graham | last post by:
What I currently have is a page that opens another browser at 800x600, once that is loaded I would like to close the orginal page down while keeping the page that it has just opened open (To make...
3
by: Daniel | last post by:
TcpClient close() method socket leak when i use TcpClient to open a connection, send data and close the TcpClient with myTcpClientInstance.Close(); it takes 60 seconds for the actual socket on...
4
by: Chris Tanger | last post by:
Context: C# System.Net.Sockets Socket created with constructor prarmeters Internetwork, Stream and TCP everything else is left at the default parameters and options except linger may be changed...
2
by: Daniel | last post by:
TcpClient close() method socket leak when i use TcpClient to open a connection, send data and close the TcpClient with myTcpClientInstance.Close(); it takes 60 seconds for the actual socket on...
3
by: Daniel | last post by:
TcpClient close() method socket leak when i use TcpClient to open a connection, send data and close the TcpClient with myTcpClientInstance.Close(); it takes 60 seconds for the actual socket on...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.