def __init__(self, externalLaunchList, parent=None): super(ExternalLauncher, self).__init__(parent) self.externalLaunchList = externalLaunchList self.setMinimumSize(600, 230) self.setBackgroundRole(QtGui.QPalette.Background) self.setAutoFillBackground(True) mainLayout = QtGui.QVBoxLayout() label = QtGui.QLabel("Manage Launchers") label.setStyleSheet("font: 14px; color: grey;") mainLayout.addWidget(label) self.listWidget = QtGui.QListWidget() mainLayout.addWidget(self.listWidget) formLayout = QtGui.QFormLayout() mainLayout.addLayout(formLayout) self.pathLine = PathLineEdit() formLayout.addRow("Path:", self.pathLine) self.parametersLine = QtGui.QLineEdit() formLayout.addRow("Parameters:", self.parametersLine) hbox = QtGui.QHBoxLayout() self.removeButton = QtGui.QPushButton("Remove") self.removeButton.clicked.connect(self.removeLauncher) hbox.addWidget(self.removeButton) self.addButton = QtGui.QPushButton("Add") self.addButton.clicked.connect(self.addLauncher) hbox.addWidget(self.addButton) hbox.addStretch(1) self.closeButton = QtGui.QPushButton("Close") self.closeButton.clicked.connect(self.hide) hbox.addWidget(self.closeButton) mainLayout.addLayout(hbox) self.setLayout(mainLayout) self.manageLauncherAct = \ QtGui.QAction(QtGui.QIcon(os.path.join("Resources", "images", "settings")), "Manage Launchers", self, statusTip="Manage Launchers", triggered=self.showMe.emit) self.launcherMenu = QtGui.QMenu("Launch External...") self.loadExternalLaunchers()
class ExternalLauncher(QtGui.QLabel): showMe = QtCore.pyqtSignal() def __init__(self, externalLaunchList, parent=None): super(ExternalLauncher, self).__init__(parent) self.externalLaunchList = externalLaunchList self.setMinimumSize(600, 230) self.setObjectName("containerLabel") self.setStyleSheet(StyleSheet.toolWidgetStyle) self.setBackgroundRole(QtGui.QPalette.Background) self.setAutoFillBackground(True) self.setObjectName("containerLabel") mainLayout = QtGui.QVBoxLayout() hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) label = QtGui.QLabel("Manage Launchers") label.setObjectName("toolWidgetNameLabel") hbox.addWidget(label) hbox.addStretch(1) self.hideButton = QtGui.QToolButton() self.hideButton.setAutoRaise(True) self.hideButton.setIcon( QtGui.QIcon(os.path.join("Resources", "images", "cross_"))) self.hideButton.clicked.connect(self.hide) hbox.addWidget(self.hideButton) self.listWidget = QtGui.QListWidget() mainLayout.addWidget(self.listWidget) formLayout = QtGui.QFormLayout() mainLayout.addLayout(formLayout) self.pathLine = PathLineEdit() formLayout.addRow("Path:", self.pathLine) self.parametersLine = QtGui.QLineEdit() formLayout.addRow("Parameters:", self.parametersLine) hbox = QtGui.QHBoxLayout() formLayout.addRow('', hbox) self.removeButton = QtGui.QPushButton("Remove") self.removeButton.clicked.connect(self.removeLauncher) hbox.addWidget(self.removeButton) self.addButton = QtGui.QPushButton("Add") self.addButton.clicked.connect(self.addLauncher) hbox.addWidget(self.addButton) hbox.addStretch(1) self.setLayout(mainLayout) self.manageLauncherAct = \ QtGui.QAction( QtGui.QIcon(os.path.join("Resources", "images", "settings")), "Manage Launchers", self, statusTip="Manage Launchers", triggered=self.showMe.emit) self.launcherMenu = QtGui.QMenu("Launch External...") self.loadExternalLaunchers() def removeLauncher(self): path = self.listWidget.currentItem().text() del self.externalLaunchList[path] self.loadExternalLaunchers() def addLauncher(self): path = self.pathLine.text().strip() if path != '': if os.path.exists(path): if path not in self.externalLaunchList: self.externalLaunchList[path] = self.parametersLine.text( ).strip() self.loadExternalLaunchers() else: message = QtGui.QMessageBox.warning( self, "Add Launcher", "Path already exists in launchers!") else: message = QtGui.QMessageBox.warning(self, "Add Launcher", "Path does not exists!") else: message = QtGui.QMessageBox.warning(self, "Add Launcher", "Path cannot be empty!") def loadExternalLaunchers(self): self.launcherMenu.clear() self.listWidget.clear() if len(self.externalLaunchList) > 0: self.actionGroup = QtGui.QActionGroup(self) self.actionGroup.triggered.connect(self.launcherActivated) for path, param in self.externalLaunchList.items(): action = QtGui.QAction(Global.iconFromPath(path), path, self) self.actionGroup.addAction(action) self.launcherMenu.addAction(action) item = QtGui.QListWidgetItem(Global.iconFromPath(path), path) item.setToolTip(path) self.listWidget.addItem(item) self.launcherMenu.addSeparator() self.launcherMenu.addAction(self.manageLauncherAct) else: self.launcherMenu.addAction(self.manageLauncherAct) if len(self.externalLaunchList) == 0: self.removeButton.setDisabled(True) else: self.removeButton.setDisabled(False) def launcherActivated(self, action): path = action.text() param = self.externalLaunchList[path] if os.path.exists(path): if os.path.isdir(path): os.startfile(path) else: if param == '': os.startfile(path) else: process = QtCore.QProcess(self) process.startDetached(path, [param]) else: message = QtGui.QMessageBox.warning(self, "Launch", "Path is not available.")
def __init__(self, projectSettings, projectPathDict, useData, parent=None): QtGui.QLabel.__init__(self, parent) self.setMinimumSize(400, 220) self.setBackgroundRole(QtGui.QPalette.Background) self.setAutoFillBackground(True) self.setObjectName("containerLabel") self.setStyleSheet(StyleSheet.toolWidgetStyle) self.projectSettings = projectSettings self.useData = useData self.projectPathDict = projectPathDict mainLayout = QtGui.QVBoxLayout() hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) label = QtGui.QLabel("Run Parameters") label.setObjectName("toolWidgetNameLabel") hbox.addWidget(label) hbox.addStretch(1) self.hideButton = QtGui.QToolButton() self.hideButton.setAutoRaise(True) self.hideButton.setIcon( QtGui.QIcon(os.path.join("Resources", "images", "cross_"))) self.hideButton.clicked.connect(self.hide) hbox.addWidget(self.hideButton) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) self.runTypeBox = QtGui.QComboBox() self.runTypeBox.addItem("Run") self.runTypeBox.addItem("Profiler") self.runTypeBox.addItem("Trace") if self.projectSettings["RunType"] == 'Profiler': self.runTypeBox.setCurrentIndex(1) elif self.projectSettings["RunType"] == 'Trace': self.runTypeBox.setCurrentIndex(2) self.runTypeBox.currentIndexChanged.connect(self.saveArguments) self.runTypeBox.currentIndexChanged.connect(self.runTypeChanged) hbox.addWidget(self.runTypeBox) self.traceTypeBox = QtGui.QComboBox() self.traceTypeBox.addItem("Calling relationships") self.traceTypeBox.addItem("Functions called") self.traceTypeBox.addItem("Times lines are called") self.traceTypeBox.addItem("View currently running line of code") self.traceTypeBox.setCurrentIndex( int(self.projectSettings["TraceType"])) self.traceTypeBox.currentIndexChanged.connect(self.saveArguments) hbox.addWidget(self.traceTypeBox) if self.runTypeBox.currentIndex() != 2: self.traceTypeBox.hide() self.runWithArgsBox = QtGui.QCheckBox("Arguments:") if self.projectSettings["RunWithArguments"] == 'True': self.runWithArgsBox.setChecked(True) self.runWithArgsBox.toggled.connect(self.saveArguments) mainLayout.addWidget(self.runWithArgsBox) self.argumentsLine = PathLineEdit() self.argumentsLine.setText(self.projectSettings["RunArguments"]) self.argumentsLine.textChanged.connect(self.saveArguments) mainLayout.addWidget(self.argumentsLine) hbox = QtGui.QHBoxLayout() self.clearOutputBox = QtGui.QCheckBox("Clear output window") if self.projectSettings["ClearOutputWindowOnRun"] == 'True': self.clearOutputBox.setChecked(True) self.clearOutputBox.toggled.connect(self.saveArguments) hbox.addWidget(self.clearOutputBox) hbox.addStretch(1) hbox.addWidget(QtGui.QLabel("Max Output Size <lines>")) self.bufferSizeBox = QtGui.QSpinBox() self.bufferSizeBox.setMaximum(999) self.bufferSizeBox.setMinimumWidth(100) self.bufferSizeBox.setValue(int(self.projectSettings['BufferSize'])) self.bufferSizeBox.valueChanged.connect(self.saveArguments) hbox.addWidget(self.bufferSizeBox) mainLayout.addLayout(hbox) self.runPointBox = QtGui.QComboBox() self.runPointBox.addItem("Internal Console") self.runPointBox.addItem("External Console") if self.projectSettings["RunInternal"] == 'False': self.runPointBox.setCurrentIndex(1) self.runPointBox.currentIndexChanged.connect(self.saveArguments) mainLayout.addWidget(self.runPointBox) self.useVirtualEnvBox = QtGui.QCheckBox("Use Virtual Environment") if self.projectSettings["UseVirtualEnv"] == 'True': self.useVirtualEnvBox.setChecked(True) self.useVirtualEnvBox.toggled.connect(self.setDefaultInterpreter) mainLayout.addWidget(self.useVirtualEnvBox) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) self.installedPythonVersionBox = QtGui.QComboBox() self.installedPythonVersionBox.setMinimumWidth(200) self.updateInstalledInterpreters() self.installedPythonVersionBox.currentIndexChanged.connect( self.setDefaultInterpreter) hbox.addWidget(self.installedPythonVersionBox) hbox.addStretch(1) label = QtGui.QLabel("Installed Python") hbox.addWidget(label) self.setLayout(mainLayout) self.setDefaultInterpreter()
class SetRunParameters(QtGui.QLabel): def __init__(self, projectSettings, projectPathDict, useData, parent=None): QtGui.QLabel.__init__(self, parent) self.setMinimumSize(400, 220) self.setBackgroundRole(QtGui.QPalette.Background) self.setAutoFillBackground(True) self.setObjectName("containerLabel") self.setStyleSheet(StyleSheet.toolWidgetStyle) self.projectSettings = projectSettings self.useData = useData self.projectPathDict = projectPathDict mainLayout = QtGui.QVBoxLayout() hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) label = QtGui.QLabel("Run Parameters") label.setObjectName("toolWidgetNameLabel") hbox.addWidget(label) hbox.addStretch(1) self.hideButton = QtGui.QToolButton() self.hideButton.setAutoRaise(True) self.hideButton.setIcon( QtGui.QIcon(os.path.join("Resources", "images", "cross_"))) self.hideButton.clicked.connect(self.hide) hbox.addWidget(self.hideButton) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) self.runTypeBox = QtGui.QComboBox() self.runTypeBox.addItem("Run") self.runTypeBox.addItem("Profiler") self.runTypeBox.addItem("Trace") if self.projectSettings["RunType"] == 'Profiler': self.runTypeBox.setCurrentIndex(1) elif self.projectSettings["RunType"] == 'Trace': self.runTypeBox.setCurrentIndex(2) self.runTypeBox.currentIndexChanged.connect(self.saveArguments) self.runTypeBox.currentIndexChanged.connect(self.runTypeChanged) hbox.addWidget(self.runTypeBox) self.traceTypeBox = QtGui.QComboBox() self.traceTypeBox.addItem("Calling relationships") self.traceTypeBox.addItem("Functions called") self.traceTypeBox.addItem("Times lines are called") self.traceTypeBox.addItem("View currently running line of code") self.traceTypeBox.setCurrentIndex( int(self.projectSettings["TraceType"])) self.traceTypeBox.currentIndexChanged.connect(self.saveArguments) hbox.addWidget(self.traceTypeBox) if self.runTypeBox.currentIndex() != 2: self.traceTypeBox.hide() self.runWithArgsBox = QtGui.QCheckBox("Arguments:") if self.projectSettings["RunWithArguments"] == 'True': self.runWithArgsBox.setChecked(True) self.runWithArgsBox.toggled.connect(self.saveArguments) mainLayout.addWidget(self.runWithArgsBox) self.argumentsLine = PathLineEdit() self.argumentsLine.setText(self.projectSettings["RunArguments"]) self.argumentsLine.textChanged.connect(self.saveArguments) mainLayout.addWidget(self.argumentsLine) hbox = QtGui.QHBoxLayout() self.clearOutputBox = QtGui.QCheckBox("Clear output window") if self.projectSettings["ClearOutputWindowOnRun"] == 'True': self.clearOutputBox.setChecked(True) self.clearOutputBox.toggled.connect(self.saveArguments) hbox.addWidget(self.clearOutputBox) hbox.addStretch(1) hbox.addWidget(QtGui.QLabel("Max Output Size <lines>")) self.bufferSizeBox = QtGui.QSpinBox() self.bufferSizeBox.setMaximum(999) self.bufferSizeBox.setMinimumWidth(100) self.bufferSizeBox.setValue(int(self.projectSettings['BufferSize'])) self.bufferSizeBox.valueChanged.connect(self.saveArguments) hbox.addWidget(self.bufferSizeBox) mainLayout.addLayout(hbox) self.runPointBox = QtGui.QComboBox() self.runPointBox.addItem("Internal Console") self.runPointBox.addItem("External Console") if self.projectSettings["RunInternal"] == 'False': self.runPointBox.setCurrentIndex(1) self.runPointBox.currentIndexChanged.connect(self.saveArguments) mainLayout.addWidget(self.runPointBox) self.useVirtualEnvBox = QtGui.QCheckBox("Use Virtual Environment") if self.projectSettings["UseVirtualEnv"] == 'True': self.useVirtualEnvBox.setChecked(True) self.useVirtualEnvBox.toggled.connect(self.setDefaultInterpreter) mainLayout.addWidget(self.useVirtualEnvBox) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) self.installedPythonVersionBox = QtGui.QComboBox() self.installedPythonVersionBox.setMinimumWidth(200) self.updateInstalledInterpreters() self.installedPythonVersionBox.currentIndexChanged.connect( self.setDefaultInterpreter) hbox.addWidget(self.installedPythonVersionBox) hbox.addStretch(1) label = QtGui.QLabel("Installed Python") hbox.addWidget(label) self.setLayout(mainLayout) self.setDefaultInterpreter() def updateInstalledInterpreters(self): self.installedPythonVersionBox.clear() if len(self.useData.SETTINGS["InstalledInterpreters"]) > 0: for i in self.useData.SETTINGS["InstalledInterpreters"]: self.installedPythonVersionBox.addItem(i) if self.projectSettings["UseVirtualEnv"] == 'False': index = self.installedPythonVersionBox.findText( self.projectSettings["DefaultInterpreter"]) if index != -1: self.installedPythonVersionBox.setCurrentIndex(index) else: self.installedPythonVersionBox.addItem("<No Python installed>") def runTypeChanged(self, index): if index == 2: self.traceTypeBox.show() else: self.traceTypeBox.hide() def saveArguments(self): self.projectSettings["RunWithArguments"] = str( self.runWithArgsBox.isChecked()) self.projectSettings["RunArguments"] = self.argumentsLine.text().strip( ) self.projectSettings["ClearOutputWindowOnRun"] = str( self.clearOutputBox.isChecked()) self.projectSettings["BufferSize"] = str(self.bufferSizeBox.value()) self.projectSettings["RunType"] = self.runTypeBox.currentText() self.projectSettings["RunInternal"] = str( self.runPointBox.currentIndex() == 0) self.projectSettings["TraceType"] = str( self.traceTypeBox.currentIndex()) def setDefaultInterpreter(self): if self.useVirtualEnvBox.isChecked(): # FIXME: Needs to be corrected for each platform if sys.platform == 'win32': self.projectSettings["DefaultInterpreter"] = \ os.path.join(self.projectPathDict["venvdir"], "Scripts", "python.exe") elif sys.platform == 'darwin': self.projectSettings["DefaultInterpreter"] = \ os.path.join(self.projectPathDict["venvdir"], "Scripts", "python.exe") else: self.projectSettings["DefaultInterpreter"] = \ os.path.join(self.projectPathDict["venvdir"], "Scripts", "python.exe") else: if len(self.useData.SETTINGS["InstalledInterpreters"]) > 0: self.projectSettings["DefaultInterpreter"] = \ self.installedPythonVersionBox.currentText() else: self.projectSettings["DefaultInterpreter"] = 'None' self.projectSettings["UseVirtualEnv"] = str( self.useVirtualEnvBox.isChecked())
def __init__(self, projectSettings, projectPathDict, useData, parent=None): QtGui.QLabel.__init__(self, parent) self.setMinimumSize(400, 220) self.setBackgroundRole(QtGui.QPalette.Background) self.setAutoFillBackground(True) self.setObjectName("containerLabel") self.setStyleSheet(StyleSheet.toolWidgetStyle) self.projectSettings = projectSettings self.useData = useData self.projectPathDict = projectPathDict mainLayout = QtGui.QVBoxLayout() hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) label = QtGui.QLabel("Run Parameters") label.setObjectName("toolWidgetNameLabel") hbox.addWidget(label) hbox.addStretch(1) self.hideButton = QtGui.QToolButton() self.hideButton.setAutoRaise(True) self.hideButton.setIcon( QtGui.QIcon(os.path.join("Resources", "images", "cross_"))) self.hideButton.clicked.connect(self.hide) hbox.addWidget(self.hideButton) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) self.runTypeBox = QtGui.QComboBox() self.runTypeBox.addItem("Run") self.runTypeBox.addItem("Profiler") self.runTypeBox.addItem("Trace") if self.projectSettings["RunType"] == 'Profiler': self.runTypeBox.setCurrentIndex(1) elif self.projectSettings["RunType"] == 'Trace': self.runTypeBox.setCurrentIndex(2) self.runTypeBox.currentIndexChanged.connect(self.saveArguments) self.runTypeBox.currentIndexChanged.connect(self.runTypeChanged) hbox.addWidget(self.runTypeBox) self.traceTypeBox = QtGui.QComboBox() self.traceTypeBox.addItem("Calling relationships") self.traceTypeBox.addItem("Functions called") self.traceTypeBox.addItem("Times lines are called") self.traceTypeBox.addItem("View currently running line of code") self.traceTypeBox.setCurrentIndex(int( self.projectSettings["TraceType"])) self.traceTypeBox.currentIndexChanged.connect(self.saveArguments) hbox.addWidget(self.traceTypeBox) if self.runTypeBox.currentIndex() != 2: self.traceTypeBox.hide() self.runWithArgsBox = QtGui.QCheckBox("Arguments:") if self.projectSettings["RunWithArguments"] == 'True': self.runWithArgsBox.setChecked(True) self.runWithArgsBox.toggled.connect(self.saveArguments) mainLayout.addWidget(self.runWithArgsBox) self.argumentsLine = PathLineEdit() self.argumentsLine.setText(self.projectSettings["RunArguments"]) self.argumentsLine.textChanged.connect(self.saveArguments) mainLayout.addWidget(self.argumentsLine) hbox = QtGui.QHBoxLayout() self.clearOutputBox = QtGui.QCheckBox("Clear Output Window") if self.projectSettings["ClearOutputWindowOnRun"] == 'True': self.clearOutputBox.setChecked(True) self.clearOutputBox.toggled.connect(self.saveArguments) hbox.addWidget(self.clearOutputBox) hbox.addStretch(1) hbox.addWidget(QtGui.QLabel("Max Output Size <lines>")) self.bufferSizeBox = QtGui.QSpinBox() self.bufferSizeBox.setMaximum(999) self.bufferSizeBox.setMinimumWidth(100) self.bufferSizeBox.setValue(int(self.projectSettings['BufferSize'])) self.bufferSizeBox.valueChanged.connect(self.saveArguments) hbox.addWidget(self.bufferSizeBox) mainLayout.addLayout(hbox) self.runPointBox = QtGui.QComboBox() self.runPointBox.addItem("Internal Console") self.runPointBox.addItem("External Console") if self.projectSettings["RunInternal"] == 'False': self.runPointBox.setCurrentIndex(1) self.runPointBox.currentIndexChanged.connect(self.saveArguments) mainLayout.addWidget(self.runPointBox) self.useVirtualEnvBox = QtGui.QCheckBox("Use Virtual Environment") if self.projectSettings["UseVirtualEnv"] == 'True': self.useVirtualEnvBox.setChecked(True) self.useVirtualEnvBox.toggled.connect(self.setDefaultInterpreter) mainLayout.addWidget(self.useVirtualEnvBox) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) label = QtGui.QLabel("Python Interpreter") hbox.addWidget(label) hbox.addStretch(1) self.installedPythonVersionBox = QtGui.QComboBox() self.installedPythonVersionBox.setMinimumWidth(200) self.updateInstalledInterpreters() self.installedPythonVersionBox.currentIndexChanged.connect( self.setDefaultInterpreter) hbox.addWidget(self.installedPythonVersionBox) self.setLayout(mainLayout) self.setDefaultInterpreter()
class SetRunParameters(QtGui.QLabel): def __init__(self, projectSettings, projectPathDict, useData, parent=None): QtGui.QLabel.__init__(self, parent) self.setMinimumSize(400, 220) self.setBackgroundRole(QtGui.QPalette.Background) self.setAutoFillBackground(True) self.setObjectName("containerLabel") self.setStyleSheet(StyleSheet.toolWidgetStyle) self.projectSettings = projectSettings self.useData = useData self.projectPathDict = projectPathDict mainLayout = QtGui.QVBoxLayout() hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) label = QtGui.QLabel("Run Parameters") label.setObjectName("toolWidgetNameLabel") hbox.addWidget(label) hbox.addStretch(1) self.hideButton = QtGui.QToolButton() self.hideButton.setAutoRaise(True) self.hideButton.setIcon( QtGui.QIcon(os.path.join("Resources", "images", "cross_"))) self.hideButton.clicked.connect(self.hide) hbox.addWidget(self.hideButton) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) self.runTypeBox = QtGui.QComboBox() self.runTypeBox.addItem("Run") self.runTypeBox.addItem("Profiler") self.runTypeBox.addItem("Trace") if self.projectSettings["RunType"] == 'Profiler': self.runTypeBox.setCurrentIndex(1) elif self.projectSettings["RunType"] == 'Trace': self.runTypeBox.setCurrentIndex(2) self.runTypeBox.currentIndexChanged.connect(self.saveArguments) self.runTypeBox.currentIndexChanged.connect(self.runTypeChanged) hbox.addWidget(self.runTypeBox) self.traceTypeBox = QtGui.QComboBox() self.traceTypeBox.addItem("Calling relationships") self.traceTypeBox.addItem("Functions called") self.traceTypeBox.addItem("Times lines are called") self.traceTypeBox.addItem("View currently running line of code") self.traceTypeBox.setCurrentIndex(int( self.projectSettings["TraceType"])) self.traceTypeBox.currentIndexChanged.connect(self.saveArguments) hbox.addWidget(self.traceTypeBox) if self.runTypeBox.currentIndex() != 2: self.traceTypeBox.hide() self.runWithArgsBox = QtGui.QCheckBox("Arguments:") if self.projectSettings["RunWithArguments"] == 'True': self.runWithArgsBox.setChecked(True) self.runWithArgsBox.toggled.connect(self.saveArguments) mainLayout.addWidget(self.runWithArgsBox) self.argumentsLine = PathLineEdit() self.argumentsLine.setText(self.projectSettings["RunArguments"]) self.argumentsLine.textChanged.connect(self.saveArguments) mainLayout.addWidget(self.argumentsLine) hbox = QtGui.QHBoxLayout() self.clearOutputBox = QtGui.QCheckBox("Clear Output Window") if self.projectSettings["ClearOutputWindowOnRun"] == 'True': self.clearOutputBox.setChecked(True) self.clearOutputBox.toggled.connect(self.saveArguments) hbox.addWidget(self.clearOutputBox) hbox.addStretch(1) hbox.addWidget(QtGui.QLabel("Max Output Size <lines>")) self.bufferSizeBox = QtGui.QSpinBox() self.bufferSizeBox.setMaximum(999) self.bufferSizeBox.setMinimumWidth(100) self.bufferSizeBox.setValue(int(self.projectSettings['BufferSize'])) self.bufferSizeBox.valueChanged.connect(self.saveArguments) hbox.addWidget(self.bufferSizeBox) mainLayout.addLayout(hbox) self.runPointBox = QtGui.QComboBox() self.runPointBox.addItem("Internal Console") self.runPointBox.addItem("External Console") if self.projectSettings["RunInternal"] == 'False': self.runPointBox.setCurrentIndex(1) self.runPointBox.currentIndexChanged.connect(self.saveArguments) mainLayout.addWidget(self.runPointBox) self.useVirtualEnvBox = QtGui.QCheckBox("Use Virtual Environment") if self.projectSettings["UseVirtualEnv"] == 'True': self.useVirtualEnvBox.setChecked(True) self.useVirtualEnvBox.toggled.connect(self.setDefaultInterpreter) mainLayout.addWidget(self.useVirtualEnvBox) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) label = QtGui.QLabel("Python Interpreter") hbox.addWidget(label) hbox.addStretch(1) self.installedPythonVersionBox = QtGui.QComboBox() self.installedPythonVersionBox.setMinimumWidth(200) self.updateInstalledInterpreters() self.installedPythonVersionBox.currentIndexChanged.connect( self.setDefaultInterpreter) hbox.addWidget(self.installedPythonVersionBox) self.setLayout(mainLayout) self.setDefaultInterpreter() def updateInstalledInterpreters(self): self.installedPythonVersionBox.clear() if len(self.useData.SETTINGS["InstalledInterpreters"]) > 0: for i in self.useData.SETTINGS["InstalledInterpreters"]: self.installedPythonVersionBox.addItem(i) if self.projectSettings["UseVirtualEnv"] == 'False': index = self.installedPythonVersionBox.findText( self.projectSettings["DefaultInterpreter"]) if index != -1: self.installedPythonVersionBox.setCurrentIndex(index) else: self.installedPythonVersionBox.addItem("<No Python installed>") def runTypeChanged(self, index): if index == 2: self.traceTypeBox.show() else: self.traceTypeBox.hide() def saveArguments(self): self.projectSettings["RunWithArguments"] = str( self.runWithArgsBox.isChecked()) self.projectSettings[ "RunArguments"] = self.argumentsLine.text().strip() self.projectSettings["ClearOutputWindowOnRun"] = str( self.clearOutputBox.isChecked()) self.projectSettings["BufferSize"] = str(self.bufferSizeBox.value()) self.projectSettings["RunType"] = self.runTypeBox.currentText() self.projectSettings["RunInternal"] = str( self.runPointBox.currentIndex() == 0) self.projectSettings["TraceType"] = str( self.traceTypeBox.currentIndex()) def setDefaultInterpreter(self): if self.useVirtualEnvBox.isChecked(): # FIXME: Needs to be corrected for each platform if sys.platform == 'win32': self.projectSettings["DefaultInterpreter"] = \ os.path.join(self.projectPathDict["venvdir"], "Scripts", "python.exe") elif sys.platform == 'darwin': self.projectSettings["DefaultInterpreter"] = \ os.path.join(self.projectPathDict["venvdir"], "Scripts", "python.exe") else: self.projectSettings["DefaultInterpreter"] = \ os.path.join(self.projectPathDict["venvdir"], "Scripts", "python.exe") else: if len(self.useData.SETTINGS["InstalledInterpreters"]) > 0: self.projectSettings["DefaultInterpreter"] = \ self.installedPythonVersionBox.currentText() else: self.projectSettings["DefaultInterpreter"] = 'None' self.projectSettings["UseVirtualEnv"] = str( self.useVirtualEnvBox.isChecked())
class ExternalLauncher(QtGui.QLabel): showMe = QtCore.pyqtSignal() def __init__(self, externalLaunchList, parent=None): super(ExternalLauncher, self).__init__(parent) self.externalLaunchList = externalLaunchList self.setMinimumSize(600, 230) self.setObjectName("containerLabel") self.setStyleSheet(StyleSheet.toolWidgetStyle) self.setBackgroundRole(QtGui.QPalette.Background) self.setAutoFillBackground(True) self.setObjectName("containerLabel") mainLayout = QtGui.QVBoxLayout() hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) label = QtGui.QLabel("Manage Launchers") label.setObjectName("toolWidgetNameLabel") hbox.addWidget(label) hbox.addStretch(1) self.hideButton = QtGui.QToolButton() self.hideButton.setAutoRaise(True) self.hideButton.setIcon( QtGui.QIcon(os.path.join("Resources", "images", "cross_"))) self.hideButton.clicked.connect(self.hide) hbox.addWidget(self.hideButton) self.listWidget = QtGui.QListWidget() mainLayout.addWidget(self.listWidget) formLayout = QtGui.QFormLayout() mainLayout.addLayout(formLayout) self.pathLine = PathLineEdit() formLayout.addRow("Path:", self.pathLine) self.parametersLine = QtGui.QLineEdit() formLayout.addRow("Parameters:", self.parametersLine) hbox = QtGui.QHBoxLayout() formLayout.addRow('', hbox) self.removeButton = QtGui.QPushButton("Remove") self.removeButton.clicked.connect(self.removeLauncher) hbox.addWidget(self.removeButton) self.addButton = QtGui.QPushButton("Add") self.addButton.clicked.connect(self.addLauncher) hbox.addWidget(self.addButton) hbox.addStretch(1) self.setLayout(mainLayout) self.manageLauncherAct = \ QtGui.QAction( QtGui.QIcon(os.path.join("Resources", "images", "settings")), "Manage Launchers", self, statusTip="Manage Launchers", triggered=self.showMe.emit) self.launcherMenu = QtGui.QMenu("Launch External...") self.loadExternalLaunchers() def removeLauncher(self): path = self.listWidget.currentItem().text() del self.externalLaunchList[path] self.loadExternalLaunchers() def addLauncher(self): path = self.pathLine.text().strip() if path != '': if os.path.exists(path): if path not in self.externalLaunchList: self.externalLaunchList[ path] = self.parametersLine.text().strip() self.loadExternalLaunchers() else: message = QtGui.QMessageBox.warning( self, "Add Launcher", "Path already exists in launchers!") else: message = QtGui.QMessageBox.warning( self, "Add Launcher", "Path does not exists!") else: message = QtGui.QMessageBox.warning( self, "Add Launcher", "Path cannot be empty!") def loadExternalLaunchers(self): self.launcherMenu.clear() self.listWidget.clear() if len(self.externalLaunchList) > 0: self.actionGroup = QtGui.QActionGroup(self) self.actionGroup.triggered.connect( self.launcherActivated) for path, param in self.externalLaunchList.items(): action = QtGui.QAction(Global.iconFromPath(path), path, self) self.actionGroup.addAction(action) self.launcherMenu.addAction(action) item = QtGui.QListWidgetItem(Global.iconFromPath(path), path) item.setToolTip(path) self.listWidget.addItem(item) self.launcherMenu.addSeparator() self.launcherMenu.addAction(self.manageLauncherAct) else: self.launcherMenu.addAction(self.manageLauncherAct) if len(self.externalLaunchList) == 0: self.removeButton.setDisabled(True) else: self.removeButton.setDisabled(False) def launcherActivated(self, action): path = action.text() param = self.externalLaunchList[path] if os.path.exists(path): if os.path.isdir(path): os.startfile(path) else: if param == '': os.startfile(path) else: process = QtCore.QProcess(self) process.startDetached(path, [param]) else: message = QtGui.QMessageBox.warning(self, "Launch", "Path is not available.")
def __init__(self, projectData, useData, parent=None): QtGui.QLabel.__init__(self, parent) self.setMinimumSize(400, 280) self.setBackgroundRole(QtGui.QPalette.Background) self.setAutoFillBackground(True) self.projectData = projectData self.useData = useData mainLayout = QtGui.QVBoxLayout() label = QtGui.QLabel("Run Parameters") label.setStyleSheet("font: 14px; color: grey;") mainLayout.addWidget(label) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) self.runTypeBox = QtGui.QComboBox() self.runTypeBox.addItem("Run") self.runTypeBox.addItem("Profiler") self.runTypeBox.addItem("Trace") if self.projectData["RunType"] == 'Profiler': self.runTypeBox.setCurrentIndex(1) elif self.projectData["RunType"] == 'Trace': self.runTypeBox.setCurrentIndex(2) self.runTypeBox.currentIndexChanged.connect(self.saveArguments) self.runTypeBox.currentIndexChanged.connect(self.runTypeChanged) hbox.addWidget(self.runTypeBox) self.traceTypeBox = QtGui.QComboBox() self.traceTypeBox.addItem("Calling relationships") self.traceTypeBox.addItem("Functions called") self.traceTypeBox.addItem("Times lines are called") self.traceTypeBox.addItem("View currently running line of code") self.traceTypeBox.setCurrentIndex(int(self.projectData["TraceType"])) self.traceTypeBox.currentIndexChanged.connect(self.saveArguments) hbox.addWidget(self.traceTypeBox) if self.runTypeBox.currentIndex() != 2: self.traceTypeBox.hide() frame = QtGui.QFrame() frame.setFrameShape(QtGui.QFrame.HLine) frame.setFrameShadow(QtGui.QFrame.Sunken) mainLayout.addWidget(frame) self.runWithArgsBox = QtGui.QCheckBox("Arguments:") if self.projectData["RunWithArguments"] == 'True': self.runWithArgsBox.setChecked(True) self.runWithArgsBox.toggled.connect(self.saveArguments) mainLayout.addWidget(self.runWithArgsBox) self.argumentsLine = PathLineEdit() self.argumentsLine.setText(self.projectData["RunArguments"]) self.argumentsLine.textChanged.connect(self.saveArguments) mainLayout.addWidget(self.argumentsLine) hbox = QtGui.QHBoxLayout() self.clearOutputBox = QtGui.QCheckBox("Clear output window") if self.projectData["ClearOutputWindowOnRun"] == 'True': self.clearOutputBox.setChecked(True) self.clearOutputBox.toggled.connect(self.saveArguments) hbox.addWidget(self.clearOutputBox) hbox.addStretch(1) hbox.addWidget(QtGui.QLabel("Max Output Size <lines>")) self.bufferSizeBox = QtGui.QSpinBox() self.bufferSizeBox.setMaximum(999) self.bufferSizeBox.setMinimumWidth(100) self.bufferSizeBox.setValue(int(self.projectData['BufferSize'])) self.bufferSizeBox.valueChanged.connect(self.saveArguments) hbox.addWidget(self.bufferSizeBox) mainLayout.addLayout(hbox) self.runPointBox = QtGui.QComboBox() self.runPointBox.addItem("Internal Console") self.runPointBox.addItem("External Console") if self.projectData["RunInternal"] == 'False': self.runPointBox.setCurrentIndex(1) self.runPointBox.currentIndexChanged.connect(self.saveArguments) mainLayout.addWidget(self.runPointBox) self.useVirtualEnvBox = QtGui.QCheckBox("Use Virtual Environment:") if self.projectData["UseVirtualEnv"] == 'True': self.useVirtualEnvBox.setChecked(True) self.useVirtualEnvBox.toggled.connect(self.setDefaultInterpreter) mainLayout.addWidget(self.useVirtualEnvBox) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) self.venvBox = QtGui.QComboBox() self.venvBox.setMinimumWidth(200) hbox.addWidget(self.venvBox) self.venvVersionLabel = QtGui.QLabel() hbox.addWidget(self.venvVersionLabel) hbox.addStretch(1) label = QtGui.QLabel("Virtual Environment") hbox.addWidget(label) self.updateVirtualInterpreters() self.venvBox.currentIndexChanged.connect(self.setDefaultInterpreter) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) self.installedPythonVersionBox = QtGui.QComboBox() self.installedPythonVersionBox.setMinimumWidth(200) self.updateInstalledInterpreters() self.installedPythonVersionBox.currentIndexChanged.connect( self.setDefaultInterpreter) hbox.addWidget(self.installedPythonVersionBox) hbox.addStretch(1) label = QtGui.QLabel("Installed Python") hbox.addWidget(label) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) hbox.addStretch(1) self.okButton = QtGui.QPushButton("Close") self.okButton.clicked.connect(self.hide) hbox.addWidget(self.okButton) self.setLayout(mainLayout) self.setDefaultInterpreter()
class SetRunParameters(QtGui.QLabel): def __init__(self, projectData, useData, parent=None): QtGui.QLabel.__init__(self, parent) self.setMinimumSize(400, 280) self.setBackgroundRole(QtGui.QPalette.Background) self.setAutoFillBackground(True) self.projectData = projectData self.useData = useData mainLayout = QtGui.QVBoxLayout() label = QtGui.QLabel("Run Parameters") label.setStyleSheet("font: 14px; color: grey;") mainLayout.addWidget(label) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) self.runTypeBox = QtGui.QComboBox() self.runTypeBox.addItem("Run") self.runTypeBox.addItem("Profiler") self.runTypeBox.addItem("Trace") if self.projectData["RunType"] == 'Profiler': self.runTypeBox.setCurrentIndex(1) elif self.projectData["RunType"] == 'Trace': self.runTypeBox.setCurrentIndex(2) self.runTypeBox.currentIndexChanged.connect(self.saveArguments) self.runTypeBox.currentIndexChanged.connect(self.runTypeChanged) hbox.addWidget(self.runTypeBox) self.traceTypeBox = QtGui.QComboBox() self.traceTypeBox.addItem("Calling relationships") self.traceTypeBox.addItem("Functions called") self.traceTypeBox.addItem("Times lines are called") self.traceTypeBox.addItem("View currently running line of code") self.traceTypeBox.setCurrentIndex(int(self.projectData["TraceType"])) self.traceTypeBox.currentIndexChanged.connect(self.saveArguments) hbox.addWidget(self.traceTypeBox) if self.runTypeBox.currentIndex() != 2: self.traceTypeBox.hide() frame = QtGui.QFrame() frame.setFrameShape(QtGui.QFrame.HLine) frame.setFrameShadow(QtGui.QFrame.Sunken) mainLayout.addWidget(frame) self.runWithArgsBox = QtGui.QCheckBox("Arguments:") if self.projectData["RunWithArguments"] == 'True': self.runWithArgsBox.setChecked(True) self.runWithArgsBox.toggled.connect(self.saveArguments) mainLayout.addWidget(self.runWithArgsBox) self.argumentsLine = PathLineEdit() self.argumentsLine.setText(self.projectData["RunArguments"]) self.argumentsLine.textChanged.connect(self.saveArguments) mainLayout.addWidget(self.argumentsLine) hbox = QtGui.QHBoxLayout() self.clearOutputBox = QtGui.QCheckBox("Clear output window") if self.projectData["ClearOutputWindowOnRun"] == 'True': self.clearOutputBox.setChecked(True) self.clearOutputBox.toggled.connect(self.saveArguments) hbox.addWidget(self.clearOutputBox) hbox.addStretch(1) hbox.addWidget(QtGui.QLabel("Max Output Size <lines>")) self.bufferSizeBox = QtGui.QSpinBox() self.bufferSizeBox.setMaximum(999) self.bufferSizeBox.setMinimumWidth(100) self.bufferSizeBox.setValue(int(self.projectData['BufferSize'])) self.bufferSizeBox.valueChanged.connect(self.saveArguments) hbox.addWidget(self.bufferSizeBox) mainLayout.addLayout(hbox) self.runPointBox = QtGui.QComboBox() self.runPointBox.addItem("Internal Console") self.runPointBox.addItem("External Console") if self.projectData["RunInternal"] == 'False': self.runPointBox.setCurrentIndex(1) self.runPointBox.currentIndexChanged.connect(self.saveArguments) mainLayout.addWidget(self.runPointBox) self.useVirtualEnvBox = QtGui.QCheckBox("Use Virtual Environment:") if self.projectData["UseVirtualEnv"] == 'True': self.useVirtualEnvBox.setChecked(True) self.useVirtualEnvBox.toggled.connect(self.setDefaultInterpreter) mainLayout.addWidget(self.useVirtualEnvBox) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) self.venvBox = QtGui.QComboBox() self.venvBox.setMinimumWidth(200) hbox.addWidget(self.venvBox) self.venvVersionLabel = QtGui.QLabel() hbox.addWidget(self.venvVersionLabel) hbox.addStretch(1) label = QtGui.QLabel("Virtual Environment") hbox.addWidget(label) self.updateVirtualInterpreters() self.venvBox.currentIndexChanged.connect(self.setDefaultInterpreter) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) self.installedPythonVersionBox = QtGui.QComboBox() self.installedPythonVersionBox.setMinimumWidth(200) self.updateInstalledInterpreters() self.installedPythonVersionBox.currentIndexChanged.connect( self.setDefaultInterpreter) hbox.addWidget(self.installedPythonVersionBox) hbox.addStretch(1) label = QtGui.QLabel("Installed Python") hbox.addWidget(label) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) hbox.addStretch(1) self.okButton = QtGui.QPushButton("Close") self.okButton.clicked.connect(self.hide) hbox.addWidget(self.okButton) self.setLayout(mainLayout) self.setDefaultInterpreter() def updateInstalledInterpreters(self): self.installedPythonVersionBox.clear() if len(self.useData.SETTINGS["InstalledInterpreters"]) > 0: for key, value in self.useData.SETTINGS[ "InstalledInterpreters"].items(): self.installedPythonVersionBox.addItem(key) else: self.installedPythonVersionBox.addItem("<No Python installed>") def runTypeChanged(self, index): if index == 2: self.traceTypeBox.show() else: self.traceTypeBox.hide() def saveArguments(self): self.projectData["RunWithArguments"] = str( self.runWithArgsBox.isChecked()) self.projectData["RunArguments"] = self.argumentsLine.text().strip() self.projectData["ClearOutputWindowOnRun"] = str( self.clearOutputBox.isChecked()) self.projectData["BufferSize"] = str(self.bufferSizeBox.value()) self.projectData["RunType"] = self.runTypeBox.currentText() self.projectData["RunInternal"] = str( self.runPointBox.currentIndex() == 0) self.projectData["TraceType"] = str(self.traceTypeBox.currentIndex()) def getVesionFromVenv(self): venv = self.venvBox.currentText() path = os.path.join(self.projectData["venvdir"], venv, 'pyvenv.cfg') tempList = [] file = open(path, 'r') for i in file.readlines(): v = i.strip() if v == '': pass else: tempList.append(tuple(v.split(' = '))) file.close() settings = dict(tempList) return settings['version'] def updateVirtualInterpreters(self): self.venvBox.clear() for venv in os.listdir(self.projectData["venvdir"]): path = os.path.join(self.projectData["venvdir"], venv) if 'pyvenv.cfg' in os.listdir(path): self.venvBox.addItem(venv) if self.venvBox.count() > 0: index = self.venvBox.findText(self.projectData["DefaultVenv"]) if index != -1: self.venvBox.setCurrentIndex(index) venv = self.venvBox.currentText() self.projectData["DefaultVenv"] = venv self.venvVersionLabel.setText(self.getVesionFromVenv()) else: self.projectData["DefaultVenv"] = 'None' self.venvBox.addItem("<No Virtual Environment>") self.venvVersionLabel.clear() def setDefaultInterpreter(self): venv = self.venvBox.currentText() self.projectData["DefaultVenv"] = venv self.venvVersionLabel.setText(self.getVesionFromVenv()) if self.useVirtualEnvBox.isChecked(): self.projectData["DefaultInterpreter"] = \ os.path.join(self.projectData["venvdir"], venv, "Scripts", "python.exe") else: if len(self.useData.SETTINGS["InstalledInterpreters"]) > 0: self.projectData["DefaultInterpreter"] = \ self.useData.SETTINGS["InstalledInterpreters"][ self.installedPythonVersionBox.currentText()] else: self.projectData["DefaultInterpreter"] = 'None' self.projectData["UseVirtualEnv"] = str( self.useVirtualEnvBox.isChecked())
def __init__(self, projectData, useData, parent=None): QtGui.QLabel.__init__(self, parent) self.setMinimumSize(400, 280) self.setBackgroundRole(QtGui.QPalette.Background) self.setAutoFillBackground(True) self.projectData = projectData self.useData = useData mainLayout = QtGui.QVBoxLayout() label = QtGui.QLabel("Run Parameters") label.setStyleSheet("font: 14px; color: grey;") mainLayout.addWidget(label) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) self.runTypeBox = QtGui.QComboBox() self.runTypeBox.addItem("Run") self.runTypeBox.addItem("Profiler") self.runTypeBox.addItem("Trace") if self.projectData["RunType"] == 'Profiler': self.runTypeBox.setCurrentIndex(1) elif self.projectData["RunType"] == 'Trace': self.runTypeBox.setCurrentIndex(2) self.runTypeBox.currentIndexChanged.connect(self.saveArguments) self.runTypeBox.currentIndexChanged.connect(self.runTypeChanged) hbox.addWidget(self.runTypeBox) self.traceTypeBox = QtGui.QComboBox() self.traceTypeBox.addItem("Calling relationships") self.traceTypeBox.addItem("Functions called") self.traceTypeBox.addItem("Times lines are called") self.traceTypeBox.addItem("View currently running line of code") self.traceTypeBox.setCurrentIndex(int( self.projectData["TraceType"])) self.traceTypeBox.currentIndexChanged.connect(self.saveArguments) hbox.addWidget(self.traceTypeBox) if self.runTypeBox.currentIndex() != 2: self.traceTypeBox.hide() frame = QtGui.QFrame() frame.setFrameShape(QtGui.QFrame.HLine) frame.setFrameShadow(QtGui.QFrame.Sunken) mainLayout.addWidget(frame) self.runWithArgsBox = QtGui.QCheckBox("Arguments:") if self.projectData["RunWithArguments"] == 'True': self.runWithArgsBox.setChecked(True) self.runWithArgsBox.toggled.connect(self.saveArguments) mainLayout.addWidget(self.runWithArgsBox) self.argumentsLine = PathLineEdit() self.argumentsLine.setText(self.projectData["RunArguments"]) self.argumentsLine.textChanged.connect(self.saveArguments) mainLayout.addWidget(self.argumentsLine) hbox = QtGui.QHBoxLayout() self.clearOutputBox = QtGui.QCheckBox("Clear output window") if self.projectData["ClearOutputWindowOnRun"] == 'True': self.clearOutputBox.setChecked(True) self.clearOutputBox.toggled.connect(self.saveArguments) hbox.addWidget(self.clearOutputBox) hbox.addStretch(1) hbox.addWidget(QtGui.QLabel("Max Output Size <lines>")) self.bufferSizeBox = QtGui.QSpinBox() self.bufferSizeBox.setMaximum(999) self.bufferSizeBox.setMinimumWidth(100) self.bufferSizeBox.setValue(int(self.projectData['BufferSize'])) self.bufferSizeBox.valueChanged.connect(self.saveArguments) hbox.addWidget(self.bufferSizeBox) mainLayout.addLayout(hbox) self.runPointBox = QtGui.QComboBox() self.runPointBox.addItem("Internal Console") self.runPointBox.addItem("External Console") if self.projectData["RunInternal"] == 'False': self.runPointBox.setCurrentIndex(1) self.runPointBox.currentIndexChanged.connect(self.saveArguments) mainLayout.addWidget(self.runPointBox) self.useVirtualEnvBox = QtGui.QCheckBox("Use Virtual Environment:") if self.projectData["UseVirtualEnv"] == 'True': self.useVirtualEnvBox.setChecked(True) self.useVirtualEnvBox.toggled.connect(self.setDefaultInterpreter) mainLayout.addWidget(self.useVirtualEnvBox) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) self.venvBox = QtGui.QComboBox() self.venvBox.setMinimumWidth(200) hbox.addWidget(self.venvBox) self.venvVersionLabel = QtGui.QLabel() hbox.addWidget(self.venvVersionLabel) hbox.addStretch(1) label = QtGui.QLabel("Virtual Environment") hbox.addWidget(label) self.updateVirtualInterpreters() self.venvBox.currentIndexChanged.connect(self.setDefaultInterpreter) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) self.installedPythonVersionBox = QtGui.QComboBox() self.installedPythonVersionBox.setMinimumWidth(200) self.updateInstalledInterpreters() self.installedPythonVersionBox.currentIndexChanged.connect( self.setDefaultInterpreter) hbox.addWidget(self.installedPythonVersionBox) hbox.addStretch(1) label = QtGui.QLabel("Installed Python") hbox.addWidget(label) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) hbox.addStretch(1) self.okButton = QtGui.QPushButton("Close") self.okButton.clicked.connect(self.hide) hbox.addWidget(self.okButton) self.setLayout(mainLayout) self.setDefaultInterpreter()
class SetRunParameters(QtGui.QLabel): def __init__(self, projectData, useData, parent=None): QtGui.QLabel.__init__(self, parent) self.setMinimumSize(400, 280) self.setBackgroundRole(QtGui.QPalette.Background) self.setAutoFillBackground(True) self.projectData = projectData self.useData = useData mainLayout = QtGui.QVBoxLayout() label = QtGui.QLabel("Run Parameters") label.setStyleSheet("font: 14px; color: grey;") mainLayout.addWidget(label) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) self.runTypeBox = QtGui.QComboBox() self.runTypeBox.addItem("Run") self.runTypeBox.addItem("Profiler") self.runTypeBox.addItem("Trace") if self.projectData["RunType"] == 'Profiler': self.runTypeBox.setCurrentIndex(1) elif self.projectData["RunType"] == 'Trace': self.runTypeBox.setCurrentIndex(2) self.runTypeBox.currentIndexChanged.connect(self.saveArguments) self.runTypeBox.currentIndexChanged.connect(self.runTypeChanged) hbox.addWidget(self.runTypeBox) self.traceTypeBox = QtGui.QComboBox() self.traceTypeBox.addItem("Calling relationships") self.traceTypeBox.addItem("Functions called") self.traceTypeBox.addItem("Times lines are called") self.traceTypeBox.addItem("View currently running line of code") self.traceTypeBox.setCurrentIndex(int( self.projectData["TraceType"])) self.traceTypeBox.currentIndexChanged.connect(self.saveArguments) hbox.addWidget(self.traceTypeBox) if self.runTypeBox.currentIndex() != 2: self.traceTypeBox.hide() frame = QtGui.QFrame() frame.setFrameShape(QtGui.QFrame.HLine) frame.setFrameShadow(QtGui.QFrame.Sunken) mainLayout.addWidget(frame) self.runWithArgsBox = QtGui.QCheckBox("Arguments:") if self.projectData["RunWithArguments"] == 'True': self.runWithArgsBox.setChecked(True) self.runWithArgsBox.toggled.connect(self.saveArguments) mainLayout.addWidget(self.runWithArgsBox) self.argumentsLine = PathLineEdit() self.argumentsLine.setText(self.projectData["RunArguments"]) self.argumentsLine.textChanged.connect(self.saveArguments) mainLayout.addWidget(self.argumentsLine) hbox = QtGui.QHBoxLayout() self.clearOutputBox = QtGui.QCheckBox("Clear output window") if self.projectData["ClearOutputWindowOnRun"] == 'True': self.clearOutputBox.setChecked(True) self.clearOutputBox.toggled.connect(self.saveArguments) hbox.addWidget(self.clearOutputBox) hbox.addStretch(1) hbox.addWidget(QtGui.QLabel("Max Output Size <lines>")) self.bufferSizeBox = QtGui.QSpinBox() self.bufferSizeBox.setMaximum(999) self.bufferSizeBox.setMinimumWidth(100) self.bufferSizeBox.setValue(int(self.projectData['BufferSize'])) self.bufferSizeBox.valueChanged.connect(self.saveArguments) hbox.addWidget(self.bufferSizeBox) mainLayout.addLayout(hbox) self.runPointBox = QtGui.QComboBox() self.runPointBox.addItem("Internal Console") self.runPointBox.addItem("External Console") if self.projectData["RunInternal"] == 'False': self.runPointBox.setCurrentIndex(1) self.runPointBox.currentIndexChanged.connect(self.saveArguments) mainLayout.addWidget(self.runPointBox) self.useVirtualEnvBox = QtGui.QCheckBox("Use Virtual Environment:") if self.projectData["UseVirtualEnv"] == 'True': self.useVirtualEnvBox.setChecked(True) self.useVirtualEnvBox.toggled.connect(self.setDefaultInterpreter) mainLayout.addWidget(self.useVirtualEnvBox) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) self.venvBox = QtGui.QComboBox() self.venvBox.setMinimumWidth(200) hbox.addWidget(self.venvBox) self.venvVersionLabel = QtGui.QLabel() hbox.addWidget(self.venvVersionLabel) hbox.addStretch(1) label = QtGui.QLabel("Virtual Environment") hbox.addWidget(label) self.updateVirtualInterpreters() self.venvBox.currentIndexChanged.connect(self.setDefaultInterpreter) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) self.installedPythonVersionBox = QtGui.QComboBox() self.installedPythonVersionBox.setMinimumWidth(200) self.updateInstalledInterpreters() self.installedPythonVersionBox.currentIndexChanged.connect( self.setDefaultInterpreter) hbox.addWidget(self.installedPythonVersionBox) hbox.addStretch(1) label = QtGui.QLabel("Installed Python") hbox.addWidget(label) hbox = QtGui.QHBoxLayout() mainLayout.addLayout(hbox) hbox.addStretch(1) self.okButton = QtGui.QPushButton("Close") self.okButton.clicked.connect(self.hide) hbox.addWidget(self.okButton) self.setLayout(mainLayout) self.setDefaultInterpreter() def updateInstalledInterpreters(self): self.installedPythonVersionBox.clear() if len(self.useData.SETTINGS["InstalledInterpreters"]) > 0: for key, value in self.useData.SETTINGS["InstalledInterpreters"].items(): self.installedPythonVersionBox.addItem(key) else: self.installedPythonVersionBox.addItem("<No Python installed>") def runTypeChanged(self, index): if index == 2: self.traceTypeBox.show() else: self.traceTypeBox.hide() def saveArguments(self): self.projectData["RunWithArguments"] = str( self.runWithArgsBox.isChecked()) self.projectData[ "RunArguments"] = self.argumentsLine.text().strip() self.projectData["ClearOutputWindowOnRun"] = str( self.clearOutputBox.isChecked()) self.projectData["BufferSize"] = str(self.bufferSizeBox.value()) self.projectData["RunType"] = self.runTypeBox.currentText() self.projectData["RunInternal"] = str( self.runPointBox.currentIndex() == 0) self.projectData["TraceType"] = str( self.traceTypeBox.currentIndex()) def getVesionFromVenv(self): venv = self.venvBox.currentText() path = os.path.join(self.projectData["venvdir"], venv, 'pyvenv.cfg') tempList = [] file = open(path, 'r') for i in file.readlines(): v = i.strip() if v == '': pass else: tempList.append(tuple(v.split(' = '))) file.close() settings = dict(tempList) return settings['version'] def updateVirtualInterpreters(self): self.venvBox.clear() for venv in os.listdir(self.projectData["venvdir"]): path = os.path.join(self.projectData["venvdir"], venv) if 'pyvenv.cfg' in os.listdir(path): self.venvBox.addItem(venv) if self.venvBox.count() > 0: index = self.venvBox.findText(self.projectData["DefaultVenv"]) if index != -1: self.venvBox.setCurrentIndex(index) venv = self.venvBox.currentText() self.projectData["DefaultVenv"] = venv self.venvVersionLabel.setText(self.getVesionFromVenv()) else: self.projectData["DefaultVenv"] = 'None' self.venvBox.addItem("<No Virtual Environment>") self.venvVersionLabel.clear() def setDefaultInterpreter(self): venv = self.venvBox.currentText() self.projectData["DefaultVenv"] = venv self.venvVersionLabel.setText(self.getVesionFromVenv()) if self.useVirtualEnvBox.isChecked(): self.projectData["DefaultInterpreter"] = \ os.path.join(self.projectData["venvdir"], venv, "Scripts", "python.exe") else: if len(self.useData.SETTINGS["InstalledInterpreters"]) > 0: self.projectData["DefaultInterpreter"] = \ self.useData.SETTINGS["InstalledInterpreters"][ self.installedPythonVersionBox.currentText()] else: self.projectData["DefaultInterpreter"] = 'None' self.projectData["UseVirtualEnv"] = str( self.useVirtualEnvBox.isChecked())