def __init__(self, parent=None): super().__init__(parent) layout = QtWidgets.QHBoxLayout() layout.setContentsMargins(5, 5, 5, 5) self.addButton = QtWidgets.QPushButton(createIcon("list-add"), self.tr("Add..."), self) self.addButton.clicked.connect(lambda: self.addTriggered.emit()) layout.addWidget(self.addButton) layout.addStretch(10) self.editButton = QtWidgets.QPushButton(createIcon("text-editor"), self.tr("Edit..."), self) self.editButton.clicked.connect(lambda: self.editTriggered.emit()) layout.addWidget(self.editButton) self.copyButton = QtWidgets.QPushButton(createIcon("edit-copy"), self.tr("Copy..."), self) self.copyButton.clicked.connect(lambda: self.copyTriggered.emit()) layout.addWidget(self.copyButton) self.removeButton = QtWidgets.QPushButton(createIcon("list-remove"), self.tr("Remove"), self) self.removeButton.clicked.connect(lambda: self.removeTriggered.emit()) layout.addWidget(self.removeButton) self.moveButton = QtWidgets.QPushButton(createIcon("select-index"), self.tr("Move"), self) self.moveButton.clicked.connect(lambda: self.moveTriggered.emit()) layout.addWidget(self.moveButton) self.setLayout(layout) self.setAutoFillBackground(True)
def setupUi(self): self.setWindowIcon(createIcon("wizard-ext-signal")) self.setWindowTitle(self.tr("External Signal Editor")) self.resize(640, 280) self.signalLabel = QtWidgets.QLabel(self.tr("Signal"), self) self.signalLabel.setSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed) self.signalComboBox = QtWidgets.QComboBox(self) self.signalComboBox.setSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed) for signal in self.menu.extSignals.extSignals: self.signalComboBox.addItem(miniIcon('ext'), '_'.join((kEXT, signal[kName]))) self.offsetSpinBox = PrefixedSpinBox(self) self.offsetSpinBox.setRange(-2, 2) self.offsetSpinBox.setValue(0) self.offsetSpinBox.setSuffix(self.tr(" BX")) self.infoTextEdit = QtWidgets.QTextEdit(self) self.infoTextEdit.setReadOnly(True) self.infoTextEdit.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding) self.buttonBox = QtWidgets.QDialogButtonBox(self) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) layout = QtWidgets.QGridLayout() layout.addWidget(self.signalLabel, 0, 0) hbox = QtWidgets.QHBoxLayout() hbox.addWidget(self.signalComboBox) hbox.addWidget(self.offsetSpinBox) layout.addLayout(hbox, 0, 1) layout.addWidget(self.infoTextEdit, 0, 2, 3, 1) layout.addWidget(self.buttonBox, 3, 0, 1, 3) self.setLayout(layout)
def createAlgorithmsPage(self): model = AlgorithmsModel(self.menu(), self) tableView = self.newProxyTableView("algorithmsTableView", model) tableView.resizeColumnsToContents() self.algorithmsPage = self.addPage(self.tr("Algorithms/Seeds"), tableView, self.menuPage) self.algorithmsPage.setIcon(0, createIcon("expression"))
def setupUi(self): self.setWindowTitle(self.tr("Import")) self.setMinimumWidth(500) # Filter bar self.filterWidget = TextFilterWidget(self, spacer=True) self.filterWidget.textChanged.connect(self.setFilterText) # Table view model = AlgorithmsModel(self.menu, self) proxyModel = QtCore.QSortFilterProxyModel(self) proxyModel.setFilterKeyColumn(-1) # Filter all collumns proxyModel.setFilterCaseSensitivity(QtCore.Qt.CaseInsensitive) proxyModel.setSourceModel(model) self.tableView = TableView(self) self.tableView.setObjectName("importDialogTabelView") self.tableView.setStyleSheet("#importDialogTabelView { border: 0; }") self.tableView.setModel(proxyModel) self.tableView.sortByColumn(0, QtCore.Qt.AscendingOrder) # Button box buttonBox = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) buttonBox.accepted.connect(self.importSelected) buttonBox.rejected.connect(self.reject) # Create layout. layout = QtWidgets.QGridLayout() layout.addWidget(self.filterWidget) layout.addWidget(self.tableView) layout.addWidget( IconLabel(createIcon("info"), self.tr("Select available algorithms to import."), self)) layout.addWidget(buttonBox) self.setLayout(layout)
def createCutsPage(self): model = CutsModel(self.menu(), self) tableView = self.newProxyTableView("cutsTableView", model, proxyclass=CutsModelProxy) tableView.resizeColumnsToContents() self.cutsPage = self.addPage(self.tr("Cuts"), tableView, self.menuPage) self.cutsPage.setIcon(0, createIcon("path-cut"))
def setupUi(self): self.setWindowIcon(createIcon("wizard-object")) self.setWindowTitle(self.tr("Object Requirement Editor")) self.resize(640, 380) self.objectLabel = QtWidgets.QLabel(self.tr("Object"), self) self.objectLabel.setSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed) self.typeComboBox = ComboBoxPlus(self) self.typeComboBox.setSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed) self.compareComboBox = QtWidgets.QComboBox(self) self.compareComboBox.addItem('>=', tmGrammar.GE) self.compareComboBox.addItem('==', tmGrammar.EQ) self.thresholdSpinBox = QtWidgets.QDoubleSpinBox(self) self.offsetSpinBox = PrefixedSpinBox(self) self.offsetSpinBox.setRange(-2, 2) self.offsetSpinBox.setValue(0) self.offsetSpinBox.setSuffix(self.tr(" BX")) self.cutLabel = QtWidgets.QLabel(self.tr("Cuts"), self) self.cutLabel.setSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed) self.cutListView = QtWidgets.QListView(self) self.cutListView.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection) self.cutListView.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) self.filterWidget = TextFilterWidget(self) self.addCutButton = QtWidgets.QPushButton(createIcon("list-add"), self.tr("Add..."), self) self.infoTextEdit = QtWidgets.QTextEdit(self) self.infoTextEdit.setReadOnly(True) self.infoTextEdit.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding) self.buttonBox = QtWidgets.QDialogButtonBox(self) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) layout = QtWidgets.QGridLayout() layout.addWidget(self.objectLabel, 0, 0) hbox = QtWidgets.QHBoxLayout() hbox.addWidget(self.typeComboBox) hbox.addWidget(self.compareComboBox) hbox.addWidget(self.thresholdSpinBox) hbox.addWidget(self.offsetSpinBox) layout.addLayout(hbox, 0, 1, 1, 2) layout.addWidget(self.cutLabel, 1, 0) layout.addWidget(self.cutListView, 1, 1, 1, 2) layout.addWidget(self.filterWidget, 2, 1) layout.addWidget(self.addCutButton, 2, 2) layout.addWidget(self.infoTextEdit, 0, 3, 3, 1) layout.addWidget(self.buttonBox, 3, 0, 1, 4) self.setLayout(layout)
def setupUi(self): self.setWindowIcon(createIcon("wizard-function")) self.setWindowTitle(self.tr("Function Editor")) self.functionComboBox = QtWidgets.QComboBox(self) self.functionComboBox.addItem(self.tr("{} (combination)").format(tmGrammar.comb), tmGrammar.comb) self.functionComboBox.addItem(self.tr("{} (correlation)").format(tmGrammar.dist), tmGrammar.dist) self.functionComboBox.addItem(self.tr("{} (invariant mass)").format(tmGrammar.mass_inv), tmGrammar.mass_inv) self.functionComboBox.addItem(self.tr("{} (invariant mass unconstrained pt)").format(tmGrammar.mass_inv_upt), tmGrammar.mass_inv_upt) self.functionComboBox.addItem(self.tr("{} (invariant mass/delta-R)").format(tmGrammar.mass_inv_dr), tmGrammar.mass_inv_dr) self.functionComboBox.addItem(self.tr("{} (invariant mass of 3 particles)").format(tmGrammar.mass_inv_3), tmGrammar.mass_inv_3) self.functionComboBox.addItem(self.tr("{} (transverse mass)").format(tmGrammar.mass_trv), tmGrammar.mass_trv) self.functionComboBox.addItem(self.tr("{} (combination + overlap removal)").format(tmGrammar.comb_orm), tmGrammar.comb_orm) self.functionComboBox.addItem(self.tr("{} (correlation + overlap removal)").format(tmGrammar.dist_orm), tmGrammar.dist_orm) self.functionComboBox.addItem(self.tr("{} (invariant mass + overlap removal)").format(tmGrammar.mass_inv_orm), tmGrammar.mass_inv_orm) self.functionComboBox.currentIndexChanged.connect(self.onUpdateObjectHelpers) self.objectHelpers = [FunctionReqHelper(i, self) for i in range(self.ObjectReqs)] self.cutListView = QtWidgets.QListView(self) self.cutListView.activated.connect(self.updateInfoText) self.cutListView.clicked.connect(self.updateInfoText) self.filterWidget = TextFilterWidget(self) self.addCutButton = QtWidgets.QPushButton(createIcon("list-add"), self.tr("Add..."), self) self.infoTextEdit = QtWidgets.QTextEdit(self) self.infoTextEdit.setReadOnly(True) self.infoTextEdit.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding) self.buttonBox = QtWidgets.QDialogButtonBox(self) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) layout = QtWidgets.QGridLayout() layout.addWidget(QtWidgets.QLabel(self.tr("Function"), self), 0, 0) layout.addWidget(self.functionComboBox, 0, 1, 1, 2) for helper in self.objectHelpers: layout.addWidget(helper.label, 1+helper.index, 0) layout.addWidget(helper.lineEdit, 1+helper.index, 1) layout.addWidget(helper.editButton, 1+helper.index, 2) helper.lineEdit.textChanged.connect(self.updateInfoText) layout.addWidget(QtWidgets.QLabel(self.tr("Cuts"), self), 6, 0) layout.addWidget(self.cutListView, 6, 1, 1, 2) hbox = QtWidgets.QHBoxLayout() hbox.addWidget(self.filterWidget) hbox.addWidget(self.addCutButton) layout.addLayout(hbox, 7, 1, 1, 2) layout.addWidget(self.infoTextEdit, 0, 3, 7, 1) layout.addWidget(self.buttonBox, 8, 0, 1, 4) self.setLayout(layout)
def addDocument(self, document): """Adds document to MDI area. Prevents adding the same document twice. Returns index of tab of added document. """ # Do no re-open a document, just raise its tab. duplicate = self.findDocument(document.filename()) if duplicate: self.setCurrentWidget(duplicate) return self.currentIndex() document.modified.connect(self.documentModified) return self.addTab(document, createIcon("document"), document.name())
def __init__(self, parent=None): super().__init__(parent) self.setMaximumHeight(31) self.icon = QtWidgets.QLabel(self) self.icon.setPixmap(createIcon("dialog-warning").pixmap(16, 16)) self.icon.setFixedSize(16, 16) self.message = QtWidgets.QLabel(self) self.message.linkActivated.connect(self.onLinkActivated) layout = QtWidgets.QHBoxLayout() layout.setContentsMargins(10, 10, 0, 0) layout.addWidget(self.icon) layout.addWidget(self.message) self.setLayout(layout)
def __init__(self, parent=None): super().__init__(parent) # Setup window self.setWindowTitle(self.tr("Select Index")) self.resize(480, 300) # Button box with cancel button self.buttonBox = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self) self.buttonBox.button( QtWidgets.QDialogButtonBox.Cancel).setAutoDefault(False) self.buttonBox.button( QtWidgets.QDialogButtonBox.Cancel).clicked.connect(self.reject) # Layout to add Buttons gridLayout = QtWidgets.QGridLayout() gridLayout.setHorizontalSpacing(2) gridLayout.setVerticalSpacing(2) self.gridWidget = QtWidgets.QWidget(self) # Variable to iterate over all indices. index = 0 # Add items to the grid in the scroll area self.buttons = [] for row in range(self.RowCount): for column in range(self.ColumnCount): if index >= MaxAlgorithms: break button = QtWidgets.QPushButton(format(index), self) button.index = index button.setCheckable(True) button.setMaximumWidth(50) #self._setButtonStyle(button, self.Green) button.clicked.connect(self._updateIndex) self.buttons.append(button) gridLayout.addWidget(button, row, column) # Increment index. index += 1 # Create a scroll area for the preview self.scrollArea = QtWidgets.QScrollArea(self) self.scrollArea.setWidgetResizable(True) # Layout for Dailog Window self.gridWidget.setLayout(gridLayout) self.scrollArea.setWidget(self.gridWidget) layout = QtWidgets.QVBoxLayout() layout.addWidget(self.scrollArea) bottomLayout = QtWidgets.QHBoxLayout() bottomLayout.addWidget( IconLabel(createIcon("info"), self.tr("Select a free algorithm index."), self)) bottomLayout.addWidget(self.buttonBox) layout.addLayout(bottomLayout) self.setLayout(layout)
def createActions(self): """Create actions.""" self.parseAct = QtWidgets.QAction(self.tr("&Check expression"), self) self.parseAct.setIcon(createIcon("view-refresh")) self.parseAct.triggered.connect(self.onParse) self.undoAct = QtWidgets.QAction(self.tr("&Undo"), self) self.undoAct.setShortcut(QtGui.QKeySequence.Undo) self.undoAct.setIcon(createIcon("edit-undo")) self.undoAct.triggered.connect(self.onUndo) self.redoAct = QtWidgets.QAction(self.tr("&Redo"), self) self.redoAct.setShortcut(QtGui.QKeySequence.Redo) self.redoAct.setIcon(createIcon("edit-redo")) self.redoAct.triggered.connect(self.onRedo) self.selectIndexAct = QtWidgets.QAction(self.tr("Select &Index"), self) self.selectIndexAct.setIcon(createIcon("select-index")) self.selectIndexAct.triggered.connect(self.onSelectIndex) self.insertObjectAct = QtWidgets.QAction(self.tr("&Object..."), self) self.insertObjectAct.setToolTip(self.tr("Insert Object...")) self.insertObjectAct.setIcon(createIcon("wizard-object")) self.insertObjectAct.triggered.connect(self.onInsertObject) self.insertExtSignalAct = QtWidgets.QAction( self.tr("External &Signal..."), self) self.insertExtSignalAct.setToolTip( self.tr("Insert External Signal...")) self.insertExtSignalAct.setIcon(createIcon("wizard-ext-signal")) self.insertExtSignalAct.triggered.connect(self.onInsertExtSignal) self.insertFunctionAct = QtWidgets.QAction(self.tr("&Function..."), self) self.insertFunctionAct.setToolTip(self.tr("Insert Function...")) self.insertFunctionAct.setIcon(createIcon("wizard-function")) self.insertFunctionAct.triggered.connect(self.onInsertFunction) self.editObjectAct = QtWidgets.QAction(self.tr("Edit &Object..."), self) self.editObjectAct.setIcon(createIcon("wizard-edit-object")) self.editObjectAct.setEnabled(False) self.editExtSignalAct = QtWidgets.QAction( self.tr("Edit External &Signal..."), self) self.editExtSignalAct.setIcon(createIcon("wizard-edit-ext-signal")) self.editExtSignalAct.setEnabled(False) self.editFunctionAct = QtWidgets.QAction(self.tr("Edit &Function..."), self) self.editFunctionAct.setIcon(createIcon("wizard-edit-function")) self.editFunctionAct.setEnabled(False) self.editObjectAct.triggered.connect( lambda: self.textEdit.editObject.emit(self.objToken)) self.editExtSignalAct.triggered.connect( lambda: self.textEdit.editExtSignal.emit(self.extToken)) self.editFunctionAct.triggered.connect( lambda: self.textEdit.editFunction.emit(self.funcToken)) self.formatCollapseAct = QtWidgets.QAction(self.tr("&Collapse"), self) self.formatCollapseAct.setIcon(createIcon("format-compact")) self.formatCollapseAct.triggered.connect(self.onFormatCollapse) self.formatExpandAct = QtWidgets.QAction(self.tr("&Expand"), self) self.formatExpandAct.setIcon(createIcon("format-cascade")) self.formatExpandAct.triggered.connect(self.onFormatExpand)