def event_loop(self): window.wait_for_property(PREFIX_INSTANCE, 'True', True) while not self.xbmc_monitor.abortRequested() and not self.exit: # Path added so let's put it in the queue if window.get_property(PREFIX_ADDPATH): self._on_add() # Exit called so let's exit elif window.get_property(PREFIX_COMMAND) == 'exit': self._call_exit() # Path changed so let's update elif self.current_path != self.added_path: self._on_change() self.xbmc_monitor.waitForAbort(0.5) # User force quit so let's exit elif not window.is_visible(self.window_id): self._call_exit() # User pressed back and closed video info window elif not window.is_visible(ID_VIDEOINFO): self._on_back() self.xbmc_monitor.waitForAbort(0.5) # Nothing happened this round so let's loop and wait else: self.xbmc_monitor.waitForAbort(0.5) self._on_exit()
def restart_service_monitor(): if get_property('ServiceStarted') == 'True': wait_for_property('ServiceStop', value='True', set_property=True) # Stop service wait_for_property('ServiceStop', value=None) # Wait until Service clears property Thread(target=ServiceMonitor().run).start()
def add_path(self, path): path = _configure_path(path) # Check that user didn't click twice by accident if path == window.get_property(PREFIX_CURRENT): return # Set our path to the window property so we can add it window.wait_for_property(PREFIX_ADDPATH, path, True) self.call_auto()
def _on_back(self): # Get current position and clear it name = '{}{}'.format(PREFIX_PATH, self.position) window.wait_for_property(name, None, True) # If it was first position then let's exit if not self.position > 1: return self._call_exit(True) # Otherwise set previous position to current position self.position -= 1 name = '{}{}'.format(PREFIX_PATH, self.position) self.set_properties(self.position, window.get_property(name))
def _on_add(self): self.position += 1 self.set_properties(self.position, window.get_property(PREFIX_ADDPATH)) window.wait_for_property(PREFIX_ADDPATH, None, True) # Clear property before continuing
def close_dialog(self): window.wait_for_property(PREFIX_COMMAND, 'exit', True) window.wait_for_property(PREFIX_INSTANCE, None) self._call_exit() self._on_exit() self.call_window()