def async_window(self, connection, **kwargs): directory = os.path.dirname(kwargs["guiPath"]) name = os.path.basename(kwargs["guiPath"]) dialogClass = self.loadDialogClass(name, directory) instance, instanceId = self.createDialogInstance(dialogClass, self.application().currentWindow(), async = True) if "parameters" in kwargs and kwargs["parameters"]: instance.setParameters(plist.readPlistFromString(kwargs["parameters"])) instance.show() self.sendResult(connection, instanceId)
def modal_window(self, connection, **kwargs): parameters = plist.readPlistFromString(kwargs["parameters"]) directory = os.path.dirname(kwargs["guiPath"]) name = os.path.basename(kwargs["guiPath"]) dialogClass = self.loadDialogClass(name, directory) instance = self.createDialogInstance(dialogClass, self.application().currentWindow()) instance.setParameters(parameters) value = instance.execModal() self.sendResult(connection, {"result": value})
def test_readPlistFromString(self): data = { "dict": {}, "int":1, "str": "hello world", "list_of_ints": [1,2,3,4,5], "list_of_str": "hello world of prymatex".split() } string = plist.writePlistToString(data) self.assertEqual(plist.readPlistFromString(string), data)
def menu(self, **kwargs): parameters = plist.readPlistFromString(kwargs["parameters"]) def sendSelectedIndex(index): if index != -1: self.sendResult({"selectedIndex": index}) else: self.sendResult({}) if "menuItems" in parameters: self.application.currentEditor().showFlatPopupMenu(parameters["menuItems"], sendSelectedIndex)
def menu(self, connection, **kwargs): parameters = plist.readPlistFromString(kwargs["parameters"]) def sendSelectedIndex(connection): def _send(index): if index != -1: self.sendResult(connection, {"selectedIndex": index}) else: self.sendResult(connection, {}) return _send if "menuItems" in parameters: self.application().currentWindow().currentEditor().showFlatPopupMenu(parameters["menuItems"], sendSelectedIndex(connection))
def popup(self, **kwargs): suggestions = plist.readPlistFromString(kwargs["suggestions"]) if kwargs.get("returnChoice", False): def sendSelectedSuggestion(suggestion): if suggestion is not None: self.sendResult(suggestion) else: self.sendResult({}) self.application.currentEditor().runCompleter( suggestions = suggestions["suggestions"], already_typed = kwargs.get("alreadyTyped"), case_insensitive = kwargs.get("caseInsensitive", True), callback = sendSelectedSuggestion) else: self.application.currentEditor().runCompleter( suggestions = suggestions["suggestions"], already_typed = kwargs.get("alreadyTyped"), case_insensitive = kwargs.get("caseInsensitive", True)) self.sendResult()
def update_window(self, connection, **kwargs): parameters = plist.readPlistFromString(kwargs["parameters"]) instance = self.dialogInstance(int(kwargs["token"])) instance.setParameters(parameters) self.sendResult(connection)
def images(self, connection, parameters = ""): data = plist.readPlistFromString(parameters) for name, path in data["register"].items(): resources.set_resource("External", name, path) self.sendResult(connection)
def images(self, parameters = ""): data = plist.readPlistFromString(parameters) for name, path in data["register"].items(): resources.registerImagePath(name, path) self.sendResult()