def OnButton(self, evt): """Handle events from the buttons on the control bar""" e_id = evt.GetId() if e_id == ID_SETTINGS: app = wx.GetApp() win = app.GetWindowInstance(cfgdlg.ConfigDialog) if win is None: config = cfgdlg.ConfigDialog(self._mw, ftype=self._config['lang']) config.CentreOnParent() config.Show() else: win.Raise() elif e_id == ID_RUN: self.SetProcessRunning(not self._busy) if self._busy: util.Log("[Launch][info] Starting process") handler = handlers.GetHandlerById(self._config['lang']) cmd = self.FindWindowById(ID_EXECUTABLE).GetStringSelection() cmd = handler.GetCommand(cmd) path, fname = os.path.split(self._config['file']) args = self.FindWindowById(ID_ARGS).GetValue().split() self._worker = outbuff.ProcessThread(self._buffer, cmd, fname, args, path, handler.GetEnvironment()) self._worker.start() else: self._worker.Abort() self._worker = None elif e_id == wx.ID_CLEAR: self._buffer.Clear() else: evt.Skip()
def StartStopProcess(self): """Run or abort the context of the current process if possible""" if self._prefs.get('autoclear'): self._buffer.Clear() self.SetProcessRunning(not self._busy) if self._busy: util.Log("[Launch][info] Starting process") handler = handlers.GetHandlerById(self._config['lang']) cmd = self.FindWindowById(ID_EXECUTABLE).GetStringSelection() cmd = handler.GetCommand(cmd) path, fname = os.path.split(self._config['file']) args = self.FindWindowById(ID_ARGS).GetValue().split() self._worker = outbuff.ProcessThread(self._buffer, cmd, fname, args, path, handler.GetEnvironment()) self._worker.start() else: util.Log("[Launch][info] Aborting process") self._worker.Abort() self._worker = None
def Run(self, fname, cmd, args, ftype): """Run the given file @param fname: File path @param cmd: Command to run on file @param args: Executable arguments @param ftype: File type id """ # Find and save the file if it is modified nb = self._mw.GetNotebook() for ctrl in nb.GetTextControls(): tname = ctrl.GetFileName() if fname == tname: if ctrl.GetModify(): ctrl.SaveFile(tname) break handler = handlers.GetHandlerById(ftype) path, fname = os.path.split(fname) self._worker = outbuff.ProcessThread(self._buffer, cmd, fname, args, path, handler.GetEnvironment()) self._worker.start()