def __init__(self, parent=None): if parent is None: self._main = QtWidgets.QMainWindow() self._main.hide() parent = self._main super().__init__(parent) self.setupUi(self) self.uiNewPushButton.clicked.connect(self._newPushButtonSlot) self.uiDeletePushButton.clicked.connect(self._deletePushButtonSlot) # Center on screen screen = QtWidgets.QApplication.desktop().screenGeometry() self.move(screen.center() - self.rect().center()) if sys.platform.startswith("win"): appdata = os.path.expandvars("%APPDATA%") path = os.path.join(appdata, "GNS3") else: home = os.path.expanduser("~") path = os.path.join(home, ".config", "GNS3") self.profiles_path = os.path.join(path, "profiles") self.uiShowAtStartupCheckBox.setChecked( LocalConfig.instance().multiProfiles()) self._refresh()
self.uiCommandComboBox.currentData()) self.uiSavePushButton.hide() if self.uiCommandComboBox.currentText() in self._settings[ self._console_type].keys(): self.uiRemovePushButton.show() else: self.uiSavePushButton.show() @staticmethod def getCommand(parent, console_type="telnet", current=None): dialog = ConsoleCommandDialog(parent, console_type=console_type, current=current) dialog.show() if dialog.exec_(): return (True, dialog.uiCommandPlainTextEdit.toPlainText().replace( "\n", " ")) return (False, None) if __name__ == '__main__': import sys app = QtWidgets.QApplication(sys.argv) main = QtWidgets.QMainWindow() (ok, command) = ConsoleCommandDialog.getCommand( main, console_type="telnet", current=list(PRECONFIGURED_TELNET_CONSOLE_COMMANDS.items())[0][1]) print(ok) print(command)