In Python, using wxPython Phoenix 4.1.1, I have created a timer using the wx.Timer
object like below. Later, at some point in the code, I want to delete the timer after I have stopped it from running. Please, what is the most clean and proper way to delete the timer?
The timer creation code is following. The self
variable refers to a wx.Dialog
object.
self.timerId = 1
self.timer = wx.Timer(self, self.timerId)
self.Bind(wx.EVT_TIMER, self.onTimer, self.timer)
self.timer.Start(10)
The timer deletion code I have so far is this:
self.timer.stop()
# Probably an 'unbind' method should be used here, but what is the exact syntax?
Thanks.
del self.timer
would do the job, although it will also be removed when the dialog gets deleted. – Rolf of Saxony