By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,957 Members | 1,936 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,957 IT Pros & Developers. It's quick & easy.

wxtimer...I need to close a dialog after a particular time...

P: 17
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
[code]
self.MB = wx.Dialog(self,-1,"hello",pos=(-1,-1),size=(200,100),style=wx.NO_3D)
self.MB.Show(True)
self.timer = wx.Timer(5,self.Step(self))
self.timer.Start()


def Step:
if self.timer.IsRunning():
print ""
else:
self.MB.Close(True)
[code]
Is this code is not correct or what?
Please help me.
Mar 12 '08 #1
Share this Question
Share on Google+
1 Reply


jlm699
100+
P: 314
Expand|Select|Wrap|Line Numbers
  1. self.MB = wx.Dialog(self,-1,"hello",pos=(-1,-1),size=(200,100),style=wx.NO_3D)
  2. self.MB.Show(True)
  3. self.timer = wx.Timer(5,self.Step(self))
  4. self.timer.Start()
  5.  
  6.  
  7. def Step:
  8. if self.timer.IsRunning():
  9. print ""
  10. else:
  11. self.MB.Close(True)
  12.  
Is this code is not correct or what?
Please help me.
No this code is not correct.
Expand|Select|Wrap|Line Numbers
  1. self.MB = wx.Dialog(self,-1,"hello",pos=(-1,-1),size=(200,100),style=wx.NO_3D)
  2. self.MB.Show(True)
  3. # wrong initialization of timer
  4. self.timer = wx.Timer(self.Step())
  5. ## self.timer = wx.Timer(5,self.Step(self))
  6. # Start needs the time in milliseconds
  7. self.timer.Start(5000)
  8. ## self.timer.Start()
  9.  
  10. # Function declaration needs () argument list
  11. def Step(self):
  12.     if self.timer.IsRunning():
  13.         print ""
  14.     else:
  15.         self.MB.Close(True)
  16.  
Also, I hope that your formatting is correct and you simply lost it because you didn't use code tags...
Mar 12 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.