2014-08-04, 22:48
Hi,
how can I detect a window close event in Python?
I want to stop the timer when I go to another window (not in the onClick or Timeout).
This is my code. I have a progress bar, a timer lib and a button.
Thanks in advance
how can I detect a window close event in Python?
I want to stop the timer when I go to another window (not in the onClick or Timeout).
This is my code. I have a progress bar, a timer lib and a button.
Code:
class ScreenTest(xbmcgui.WindowXML):
control_id_button_action = 3000
control_id_progress_timeout = 3010
def __init__(self, *args, **kwargs):
xbmcgui.WindowXML.__init__(self, *args, **kwargs)
def onInit(self):
self.button_action = self.getControl(self.control_id_button_action)
self.progress_timeout = self.getControl(self.control_id_progress_timeout)
rt = RepeatedTimer(0.5, self.incrementData, [self, "hola"])
rt.start()
def incrementData(self, name):
percent = self.progress_timeout.getPercent()
if(percent == 100):
self.close()
else:
self.progress_timeout.setPercent(percent+1)
def onClick(self, controlId):
if controlId == self.control_id_button_action:
self.doAction()
def doAction(self):
import resources.lib.SecondScreen as Screen
ui = Screen.SecondScreen ('SecondScreen.xml', addon.get_path(), 'default')
ui.doModal()
del ui
Thanks in advance