def __init__(self, parent, paramTextList, paramName, spectrumNames, currentSpectrum, returnFunc): """ Initializes the ConnectParamsWindow. Parameters ---------- parent : QWidget The parent of the ConnectParamsWindow. This value is passed to QWidget. paramTextList : list of str List with the names of all parameters. paramName : str Name of the lineedit from which this window was opened. spectrumNames : list of str A list of the names of the spectra being fit. currentSpectrum : str The name of the spectrum that is currently open. returnFunc : function The function that should be called when the ok button is pressed. """ super(ConnectParamsWindow, self).__init__(parent) self.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.Tool) self.setWindowTitle("Connect Parameter") self.paramTextList = paramTextList self.paramText = paramName self.spectrumNames = spectrumNames self.currentSpectrum = self.spectrumNames.index(currentSpectrum) self.returnFunc = returnFunc self.layout = QtWidgets.QGridLayout(self) self.grid = QtWidgets.QGridLayout() self.layout.addLayout(self.grid, 0, 0, 1, 2) self.grid.addWidget(QtWidgets.QLabel("Parameter:"), 0, 0) self.paramNameEntry = QtWidgets.QComboBox() self.paramNameEntry.addItems(self.paramTextList) self.paramNameEntry.setCurrentIndex(self.paramTextList.index(self.paramText)) self.grid.addWidget(self.paramNameEntry, 0, 1) self.grid.addWidget(QtWidgets.QLabel("Data:"), 1, 0) self.spectrumNameEntry = QtWidgets.QComboBox() self.spectrumNameEntry.addItems(self.spectrumNames) self.spectrumNameEntry.setCurrentIndex(self.currentSpectrum) self.grid.addWidget(self.spectrumNameEntry, 1, 1) self.grid.addWidget(QtWidgets.QLabel("Line:"), 2, 0) self.lineEntry = QtWidgets.QSpinBox() self.grid.addWidget(self.lineEntry, 2, 1) self.grid.addWidget(QtWidgets.QLabel("Multiplier:"), 3, 0) self.multEntry = QLineEdit("1.0") self.grid.addWidget(self.multEntry, 3, 1) self.grid.addWidget(QtWidgets.QLabel("Offset:"), 4, 0) self.addEntry = QLineEdit("0.0") self.grid.addWidget(self.addEntry, 4, 1) self.cancelButton = QtWidgets.QPushButton("&Cancel") self.cancelButton.clicked.connect(self.closeEvent) self.okButton = QtWidgets.QPushButton("&Ok") self.okButton.clicked.connect(self.applyAndClose) self.okButton.setFocus() self.box = QtWidgets.QDialogButtonBox() self.box.addButton(self.cancelButton, QtWidgets.QDialogButtonBox.RejectRole) self.box.addButton(self.okButton, QtWidgets.QDialogButtonBox.AcceptRole) self.layout.addWidget(self.box, 2, 0) self.show()
def __init__(self, parent): """ Initializes the update window. Parameters ---------- parent : MainProgram The mainprogram object of ssNake. """ super(UpdateWindow, self).__init__(parent) self.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.Tool) self.father = parent try: req = urlopen('https://api.github.com/repos/smeerten/ssnake/tags') if sys.version_info >= (3, 0): info = json.loads(str(req.read().decode('utf-8'))) else: info = json.loads(str(req.read())) req.close() self.nameList = [u'develop'] self.urlList = [ u'https://api.github.com/repos/smeerten/ssnake/zipball/develop' ] for i, _ in enumerate(info): self.nameList.append(info[i]['name']) self.urlList.append(info[i]['zipball_url']) except Exception: raise sc.SsnakeException("Could not connect to the server") self.setWindowTitle("Update ssNake") layout = QtWidgets.QGridLayout(self) grid = QtWidgets.QGridLayout() layout.addLayout(grid, 0, 0, 1, 2) grid.addWidget(QtWidgets.QLabel("Update to version:"), 0, 0) self.versionDrop = QtWidgets.QComboBox(parent=self) self.versionDrop.addItems(self.nameList) self.versionDrop.setCurrentIndex(1) grid.addWidget(self.versionDrop, 1, 0) grid.addWidget( QtWidgets.QLabel("Current version: " + self.father.VERSION), 2, 0) cancelButton = QtWidgets.QPushButton("&Cancel") cancelButton.clicked.connect(self.closeEvent) okButton = QtWidgets.QPushButton("&Ok") okButton.clicked.connect(self.applyAndClose) box = QtWidgets.QDialogButtonBox() box.addButton(cancelButton, QtWidgets.QDialogButtonBox.RejectRole) box.addButton(okButton, QtWidgets.QDialogButtonBox.AcceptRole) layout.addWidget(box, 2, 0) layout.setColumnStretch(1, 1) self.show()
def __init__(self, parent, paramTextList, paramName, spectrumNames, currentSpectrum, returnFunc): super(ConnectParamsWindow, self).__init__(parent) self.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.Tool) self.setWindowTitle("Connect Parameter") self.paramTextList = paramTextList self.paramText = paramName self.spectrumNames = spectrumNames self.currentSpectrum = self.spectrumNames.index(currentSpectrum) self.returnFunc = returnFunc self.layout = QtWidgets.QGridLayout(self) self.grid = QtWidgets.QGridLayout() self.layout.addLayout(self.grid, 0, 0, 1, 2) self.grid.addWidget(QtWidgets.QLabel("Parameter:"), 0, 0) self.paramNameEntry = QtWidgets.QComboBox() self.paramNameEntry.addItems(self.paramTextList) self.paramNameEntry.setCurrentIndex( self.paramTextList.index(self.paramText)) self.grid.addWidget(self.paramNameEntry, 0, 1) self.grid.addWidget(QtWidgets.QLabel("Data:"), 1, 0) self.spectrumNameEntry = QtWidgets.QComboBox() self.spectrumNameEntry.addItems(self.spectrumNames) self.spectrumNameEntry.setCurrentIndex(self.currentSpectrum) self.grid.addWidget(self.spectrumNameEntry, 1, 1) self.grid.addWidget(QtWidgets.QLabel("Line:"), 2, 0) self.lineEntry = QtWidgets.QSpinBox() self.grid.addWidget(self.lineEntry, 2, 1) self.grid.addWidget(QtWidgets.QLabel("Multiplier:"), 3, 0) self.multEntry = QLineEdit("1.0") self.grid.addWidget(self.multEntry, 3, 1) self.grid.addWidget(QtWidgets.QLabel("Offset:"), 4, 0) self.addEntry = QLineEdit("0.0") self.grid.addWidget(self.addEntry, 4, 1) self.cancelButton = QtWidgets.QPushButton("&Cancel") self.cancelButton.clicked.connect(self.closeEvent) self.okButton = QtWidgets.QPushButton("&Ok") self.okButton.clicked.connect(self.applyAndClose) self.okButton.setFocus() self.box = QtWidgets.QDialogButtonBox() self.box.addButton(self.cancelButton, QtWidgets.QDialogButtonBox.RejectRole) self.box.addButton(self.okButton, QtWidgets.QDialogButtonBox.AcceptRole) self.layout.addWidget(self.box, 2, 0) self.show()