Hello all,
Actually i need to close a dialog automatically after 5-6 seconds.
For it what should i do,please help me.I am using wxTimer

        self.MB = wx.Dialog(self,-1,"hello",pos=(-1,-1),size=(200,100),style=wx.NO_3D)
        self.SB = wx.StaticBox(self.MB,"Here description of atelier will come")
        self.timer = wx.Timer(5,self.Step(self))

def Step:
       if self.timer.IsRunning():
            print ""

Is this code is not correct or what?
Please help me.

Edited 4 Years Ago by happygeek: fixed formatting

So it turns out that Timer objects don't receive normal callback functions, but event handler objects. If you don't feel like making one, then you can subclass the Timer and make your own Notify() method for it.

That's what I did here:

import wx

class MyTimer(wx.Timer):

    def Notify(self):
        m.frame.MB.Close(True)  # << No need to check for self.IsRunning!
class MyFrame(wx.Frame):

    def __init__(self, parent=None, id=-1, size=(300,400)):
        wx.Frame.__init__(self, parent=parent, id=id, size=size)

        self.MB = wx.Dialog(self,-1,"hello",pos=(-1,-1),size=(200,100),style=wx.NO_3D)
        self.SB = wx.StaticBox(parent=self.MB,label="Here description of atelier will come") ## << these are not positional parameters; they need the keywords 'parent' and 'label'
        self.timer = MyTimer() # << Timer.__init__() does not accept a time value.
        self.timer.Start(5000)  # << times measured in msec, not sec.

m = wx.App()
m.frame = MyFrame()


This question has already been answered. Start a new discussion instead.