def play(self, *args, **kwargs): if self.__is_running: raise self.__task = Task(self.__tasklette) self.__is_running = True self.__task.start(*args, **kwargs)
class Playable(Widget): def play(self, *args, **kwargs): if self.__is_running: raise self.__task = Task(self.__tasklette) self.__is_running = True self.__task.start(*args, **kwargs) def stop(self): self.__is_running = False if self.__task: self.__task.stop() def kill(self): self.stop() if self.__task: self.__task.kill() def __init__(self, tasklette): Widget.__init__(self) gtk.quit_add(0, self.kill) self.__tasklette = tasklette self.__is_running = False self.__task = None