def item_Tips(self,menuItem,interface): self.interface=interface self.tipsWindow = TipsWindow(None,interface.get_base_path()) self.tipsWindow.showTips(True)
class mnu_EDUCIAA: def __init__(self): self.configManager = ConfigManager() self.console = None self.loadScriptWindow = None self.interface=None self.p = None def item_Console(self,menuItem,interface): self.console = Console(interface.get_base_path()) config = self.__getConfigData() if self.console.showConsole(config["port"]): self.console.addText(config["port"] + " Opened.\n") else: interface.message("Error opening serial port: "+config["port"]) self.console.closeConsole() self.console = None def item_Load_Script(self,menuItem,interface): if self.console!=None: self.console.closeConsole() self.console = None config = self.__getConfigData() if self.loadScriptWindow==None: protocol = Protocol(config["port"]) self.loadScriptWindow = LoadScriptWindow(protocol,interface.get_filename(),self.__loadScriptWindowCloseEvent,interface.get_base_path()) # show status window def item_Snippets(self,menuItem,interface): self.interface=interface self.snippetsW = SnippetsWindow(self.__callbackInsertSnippet,interface.get_base_path()) def item_Configuration(self,menuItem,interface): config = self.configManager.readConfig() print(config) self.configW = ConfigWindow(self.__callbackPort,config["port"],interface.get_base_path(),config["pathEmulator"]) # show config window def item_Emulator(self,menuItem,interface): config = self.__getConfigData() signal.signal(signal.SIGINT,signal.SIG_IGN) signal.signal(signal.SIGTERM,signal.SIG_IGN) try: parts = config["pathEmulator"].split(" ") if len(parts)>=2 and parts[0]=="python": self.p = subprocess.Popen(["python",parts[1], interface.get_filename()]) else: self.p = subprocess.Popen([config["pathEmulator"], interface.get_filename()]) #self.p.communicate() except Exception as e: interface.message("Error opening emulator:"+str(e)) def item_Tips(self,menuItem,interface): self.interface=interface self.tipsWindow = TipsWindow(None,interface.get_base_path()) self.tipsWindow.showTips(True) def __callbackInsertSnippet(self,data): code = data[0] self.interface.insert(code) def __callbackPort(self,data): self.configManager.writeConfig(data[0],data[1]) def __getConfigData(self): config = self.configManager.readConfig() if config.has_key("port")==False: ports = list(serial.tools.list_ports.comports()) config["port"] = ports[0][0] #default port return config def __loadScriptWindowCloseEvent(self): self.loadScriptWindow = None