def __setupViews(self): """ Creates the UI widgets. """ self._collector = Collector(self.windowNumber) self._collector.sigShowMessage.connect(self.sigShowMessage) self.configWidget = ConfigWidget(self._configTreeModel) self.repoWidget = RepoWidget(self.argosApplication.repo, self.collector) # self._configTreeModel.insertItem(self.repoWidget.repoTreeView.config) # No configurable items yet # Define a central widget that will be the parent of the inspector widget. # We don't set the inspector directly as the central widget to retain the size when the # inspector is changed. self.mainWidget = QtWidgets.QWidget() self.mainLayout = QtWidgets.QVBoxLayout(self.mainWidget) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.setSpacing(0) self.setCentralWidget(self.mainWidget) self.topPane = QtWidgets.QFrame() # self.topPane.setFrameStyle(QtWidgets.QFrame.Panel | QtWidgets.QFrame.Raised) # self.topPane.setLineWidth(1) self.mainLayout.addWidget(self.topPane) self.topLayout = QtWidgets.QHBoxLayout(self.topPane) self.topLayout.setContentsMargins(0, 0, 0, 0) self.topLayout.setSpacing(0) self.inspectorSelectionPane = InspectorSelectionPane(self.inspectorActionGroup) self.topLayout.addWidget(self.inspectorSelectionPane) self.sigInspectorChanged.connect(self.inspectorSelectionPane.updateFromInspectorRegItem) self.sigShowMessage.connect(self.inspectorSelectionPane.showMessage) showInspectorMenuAction = QtWidgets.QAction("ShowInspectorMenu", self, triggered=self.inspectorSelectionPane.menuButton.showMenu, checkable=False) showInspectorMenuAction.setShortcut("Ctrl+I") self.addAction(showInspectorMenuAction) self.wrapperWidget = QtWidgets.QWidget() self.mainLayout.addWidget(self.wrapperWidget) self.wrapperLayout = QtWidgets.QVBoxLayout(self.wrapperWidget) self.wrapperLayout.setContentsMargins(0, 0, 0, 0) self.wrapperLayout.setSpacing(0) self.wrapperLayout.addWidget(self.inspector) # Must be after setInspector since that already draws the inspector self.collector.sigContentsChanged.connect(self.collectorContentsChanged) self._configTreeModel.sigItemChanged.connect(self.configContentsChanged) # Populate table headers menu self.__addTableHeadersSubMenu("Data", self.repoWidget.repoTreeView) self.__addTableHeadersSubMenu("Settings", self.configWidget.configTreeView) self.__addTableHeadersSubMenu( "Properties", self.repoWidget.propertiesPane.table) self.__addTableHeadersSubMenu( "Attributes", self.repoWidget.attributesPane.table)
def __init__(self, repoTreeModel, collector, parent=None): """ Constructor. :param parent: """ super(RepoWidget, self).__init__(parent=parent) self.detailDockPanes = [] self.mainLayout = QtWidgets.QVBoxLayout() self.mainLayout.setSpacing(DOCK_SPACING) self.mainLayout.setContentsMargins(DOCK_MARGIN, DOCK_MARGIN, DOCK_MARGIN, DOCK_MARGIN) self.setLayout(self.mainLayout) self.mainSplitter = QtWidgets.QSplitter(orientation=Qt.Vertical) self.mainLayout.addWidget(self.mainSplitter) self.repoTreeView = RepoTreeView(repoTreeModel, collector) self.mainSplitter.addWidget(self.repoTreeView) self.mainSplitter.setCollapsible(0, False) self.tabWidget = QtWidgets.QTabWidget() self.mainSplitter.addWidget(self.tabWidget) self.mainSplitter.setCollapsible(1, True) self.propertiesPane = self.addDetailsPane( PropertiesPane(self.repoTreeView)) self.attributesPane = self.addDetailsPane( AttributesPane(self.repoTreeView)) self.repoTreeView.sigRepoItemChanged.connect(self.repoItemChanged) self.tabWidget.currentChanged.connect(self.tabChanged) self.tabWidget.setCurrentIndex( 1) # Show attributes the first time the program runs
def __init__(self, registry, onlyShowImported=False, parent=None): """ Constructor """ super(OpenInspectorDialog, self).__init__(parent=parent) self._registry = registry self.setWindowTitle('Open Inspector') self.setModal(True) layout = QtWidgets.QVBoxLayout(self) attrNames = ['name', 'library', 'nDims'] headerSizes = [250, 250, None] self.inspectorTab = RegistryTab(registry, attrNames=attrNames, headerSizes=headerSizes, onlyShowImported=onlyShowImported) self.inspectorTab.tableView.sortByColumn( 1, Qt.AscendingOrder) # sort by library layout.addWidget(self.inspectorTab) # Buttons buttonBox = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject) layout.addWidget(buttonBox) # Double clicking is equivalent to selecting it and clicking Ok. self.inspectorTab.tableView.doubleClicked.connect(self.accept) self.resize(QtCore.QSize(800, 600))
def __init__(self, parent=None, msg="", title="Error"): super(MessageDisplay, self).__init__(parent=parent) self.layout = QtWidgets.QVBoxLayout() self.setLayout(self.layout) self.titleLabel = QtWidgets.QLabel(title) self.titleLabel.setTextFormat(Qt.PlainText) self.titleLabel.setTextInteractionFlags(Qt.TextSelectableByMouse) self.titleLabel.setAlignment(Qt.AlignHCenter) self.layout.addWidget(self.titleLabel, stretch=0) font = QtGui.QFont() font.setFamily(MONO_FONT) font.setFixedPitch(True) font.setPointSize(FONT_SIZE) self.messageLabel = QtWidgets.QLabel(msg) self.messageLabel.setFont(font) self.messageLabel.setTextFormat(Qt.PlainText) self.messageLabel.setTextInteractionFlags(Qt.TextSelectableByMouse) self.messageLabel.setWordWrap(True) self.messageLabel.setAlignment(Qt.AlignTop) self.messageLabel.setFrameStyle(QtWidgets.QFrame.Panel | QtWidgets.QFrame.Plain) self.layout.addWidget(self.messageLabel, stretch=1)
def __init__(self, tableModel=None, parent=None): """ Constructor. """ super(TableEditWidget, self).__init__(parent=parent) self.setFocusPolicy(Qt.NoFocus) self.mainLayout = QtWidgets.QHBoxLayout() self.mainLayout.setContentsMargins(0, 0, 0, 0) self.setLayout(self.mainLayout) self.tableView = BaseTableView(tableModel) self.mainLayout.addWidget(self.tableView) buttonLayout = QtWidgets.QVBoxLayout() self.mainLayout.addLayout(buttonLayout) iconDir = icons_directory() iconSize = QtCore.QSize(20, 20) self.addButton = QtWidgets.QPushButton() self.addButton.setToolTip("Add new row.") self.addButton.setIcon( QtGui.QIcon(os.path.join(iconDir, 'plus-sign-l.svg'))) self.addButton.setIconSize(iconSize) self.addButton.clicked.connect(self.addRow) buttonLayout.addWidget(self.addButton) self.removeButton = QtWidgets.QPushButton() self.removeButton.setToolTip("Remove row.") self.removeButton.setIcon( QtGui.QIcon(os.path.join(iconDir, 'minus-sign-l.svg'))) self.removeButton.setIconSize(iconSize) self.removeButton.clicked.connect(self.removeRow) buttonLayout.addWidget(self.removeButton) buttonLayout.addSpacing(25) self.moveUpButton = QtWidgets.QPushButton() self.moveUpButton.setToolTip("Move row up") self.moveUpButton.setIcon( QtGui.QIcon(os.path.join(iconDir, 'circle-arrow-up-l.svg'))) self.moveUpButton.setIconSize(iconSize) self.moveUpButton.clicked.connect(lambda: self.moveRow(-1)) buttonLayout.addWidget(self.moveUpButton) self.moveDownButton = QtWidgets.QPushButton() self.moveDownButton.setToolTip("Move row down") self.moveDownButton.setIcon( QtGui.QIcon(os.path.join(iconDir, 'circle-arrow-down-l.svg'))) self.moveDownButton.setIconSize(iconSize) self.moveDownButton.clicked.connect(lambda: self.moveRow(+1)) buttonLayout.addWidget(self.moveDownButton) buttonLayout.addStretch() self.tableView.selectionModel().currentChanged.connect( self.onCurrentChanged) self.tableView.setFocus(Qt.NoFocusReason) self.updateWidgets()
def __init__(self, configTreeModel, parent=None): """ Constructor. :param parent: """ super(ConfigWidget, self).__init__(parent=parent) self.configTreeView = ConfigTreeView(configTreeModel, parent=self) self.mainLayout = QtWidgets.QVBoxLayout(self) self.mainLayout.addWidget(self.configTreeView) self.mainLayout.setSpacing(DOCK_SPACING) self.mainLayout.setContentsMargins(DOCK_MARGIN, DOCK_MARGIN, DOCK_MARGIN, DOCK_MARGIN)
def __init__(self, windowNumber): """ Constructor """ super(Collector, self).__init__() self._windowNumber = windowNumber self._rti = None self._rtiInfo = None self._signalsBlocked = False self.COL_FIRST_COMBO = 1 # Column that contains the first (left most) combobox self.AXIS_POST_FIX = "-axis" # Added to the axis label to give the combobox labels. self._axisNames = [ ] # Axis names. Correspond to the independent variables self._fullAxisNames = [] # Will be set in clearAndSetComboBoxes self._comboBoxes = [] # Will be set in clearAndSetComboBoxes self._spinBoxes = [] # Will be set in createSpinBoxes self._spinSliders = [] # Will be set in createSpinBoxes self.layout = QtWidgets.QHBoxLayout(self) self.layout.setSpacing(DOCK_SPACING) self.layout.setContentsMargins(DOCK_MARGIN, DOCK_MARGIN, DOCK_MARGIN, DOCK_MARGIN) self.buttonLayout = QtWidgets.QVBoxLayout() # self.layout.setContentsMargins(2, 0, 2, 0) # Add tree self.tree = CollectorTree(self) self.layout.addWidget(self.tree) # Add buttons (not yet implemented) # self.addVisItemButton = QtWidgets.QPushButton("Add") # self.addVisItemButton.setEnabled(False) # not yet implemented # self.buttonLayout.addWidget(self.addVisItemButton, stretch=0) # self.removeVisItemButton = QtWidgets.QPushButton("Remove") # self.removeVisItemButton.setEnabled(False) # not yet implemented # self.buttonLayout.addWidget(self.removeVisItemButton, stretch=0) # self.buttonLayout.addStretch(stretch=1) # self.layout.addLayout(self.buttonLayout, stretch=0) self._updateRtiInfo()
def __init__(self, inspectorRegistry=None, rtiRegistry=None, parent=None): """ Constructor """ super(PluginsDialog, self).__init__(parent=parent) self.setWindowTitle("Installed Argos Plugins") self.setModal(False) layout = QtWidgets.QVBoxLayout(self) self.tabWidget = QtWidgets.QTabWidget() layout.addWidget(self.tabWidget) attrNames = ['fullName', 'fullClassName', 'pythonPath'] headerSizes = [200, 300, None] if inspectorRegistry: inspectorTab = RegistryTab(inspectorRegistry, attrNames=attrNames, headerSizes=headerSizes) self.tabWidget.addTab(inspectorTab, "Inspectors") if rtiRegistry: rtiTab = RegistryTab(rtiRegistry, attrNames=attrNames, headerSizes=headerSizes) self.tabWidget.addTab(rtiTab, "File Formats") # Sort by fullName by default. for tabNr in range(self.tabWidget.count()): self.tabWidget.widget(tabNr).tableView.sortByColumn(0, Qt.AscendingOrder) # Buttons buttonBox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok) buttonBox.accepted.connect(self.accept) layout.addWidget(buttonBox) self.resize(QtCore.QSize(1100, 700))
def __init__(self, parent=None): """ Constructor """ super(AboutDialog, self).__init__(parent=parent) self.setModal(True) mainLayout = QtWidgets.QVBoxLayout() self.setLayout(mainLayout) progVersionLabel = QtWidgets.QLabel() progVersionLabel.setText("{} {}{}".format( PROJECT_NAME, VERSION, ' (debugging-mode)' if DEBUGGING else '')) progVersionLabel.setTextInteractionFlags( QtCore.Qt.TextSelectableByMouse) mainLayout.addWidget(progVersionLabel) font = QtGui.QFont() font.setFamily(MONO_FONT) font.setFixedPitch(True) font.setPointSize(FONT_SIZE) self.editor = QtWidgets.QPlainTextEdit() self.editor.setReadOnly(True) self.editor.setFont(font) self.editor.setWordWrapMode(QtGui.QTextOption.NoWrap) self.editor.clear() self.editor.setPlainText("Retrieving package info...") mainLayout.addWidget(self.editor) self.progressLabel = QtWidgets.QLabel() mainLayout.addWidget(self.progressLabel) buttonBox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok) buttonBox.accepted.connect(self.accept) mainLayout.addWidget(buttonBox) self.resize(QtCore.QSize(800, 400))
def __setupViews(self): """ Creates the UI widgets. """ self._collector = Collector(self.windowNumber) self.configWidget = ConfigWidget(self._configTreeModel) self.repoWidget = RepoWidget(self.argosApplication.repo, self.collector) # self._configTreeModel.insertItem(self.repoWidget.repoTreeView.config) # No configurable items yet # Define a central widget that will be the parent of the inspector widget. # We don't set the inspector directly as the central widget to retain the size when the # inspector is changed. widget = QtWidgets.QWidget() layout = QtWidgets.QVBoxLayout(widget) layout.setContentsMargins(CENTRAL_MARGIN, CENTRAL_MARGIN, CENTRAL_MARGIN, CENTRAL_MARGIN) layout.setSpacing(CENTRAL_SPACING) self.setCentralWidget(widget) # Must be after setInspector since that already draws the inspector self.collector.sigContentsChanged.connect( self.collectorContentsChanged) self._configTreeModel.sigItemChanged.connect( self.configContentsChanged)
def __init__(self, label, registry, parent=None): """ Constructor """ super(PluginsDialog, self).__init__(parent=parent) check_class(registry, BaseRegistry) self._label = label self._orgRegistry = registry self._registry = copy.deepcopy(registry) # make copy so changes can be canceled self._tableModel = self._registry.createTableModel(parent=self) self.mapper = QtWidgets.QDataWidgetMapper(parent=self) self.mapper.setModel(self._tableModel) self.setWindowTitle("Argos {} Plugins".format(label)) layout = QtWidgets.QVBoxLayout(self) self.verSplitter = QtWidgets.QSplitter(Qt.Vertical) #self.verSplitter.setCollapsible(1, False) self.verSplitter.setChildrenCollapsible(False) layout.addWidget(self.verSplitter) self.tableWidget = TableEditWidget(self._tableModel) self.verSplitter.addWidget(self.tableWidget) self._tableView = self.tableWidget.tableView self._tableView.installEventFilter(self) # Form self.horSplitter = QtWidgets.QSplitter(Qt.Horizontal) self.horSplitter.setChildrenCollapsible(False) self.verSplitter.addWidget(self.horSplitter) self.formWidget = QtWidgets.QWidget() self.formLayout = QtWidgets.QFormLayout() self.formLayout.setContentsMargins(0, 0, 0, 0) self.formWidget.setLayout(self.formLayout) self.horSplitter.addWidget(self.formWidget) self._editWidgets = [] itemCls = registry.ITEM_CLASS assert len(itemCls.LABELS) == len(itemCls.TYPES), \ "Regtype Mismatch: {} != {}".format(len(itemCls.LABELS), len(itemCls.TYPES)) for col, (label, regType) in enumerate(zip(itemCls.LABELS, itemCls.TYPES)): if regType == RegType.String: editWidget = QtWidgets.QLineEdit() self.mapper.addMapping(editWidget, col) elif regType == RegType.ShortCut: editWidget = ShortCutEditor() self.mapper.addMapping(editWidget, col) elif regType == RegType.ColorStr: editWidget = ColorSelectWidget() self.mapper.addMapping(editWidget.lineEditor, col) else: raise AssertionError("Unexpected regType: {}".format(regType)) editWidget.installEventFilter(self) self.formLayout.addRow(label, editWidget) self._editWidgets.append(editWidget) # Detail info widget font = QtGui.QFont() font.setFamily(MONO_FONT) font.setFixedPitch(True) font.setPointSize(FONT_SIZE) self.editor = QtWidgets.QTextEdit() self.editor.setReadOnly(True) #self.editor.setFocusPolicy(Qt.NoFocus) # Allow focus so that user can copy text from it. #self.editor.setFont(font) self.editor.setWordWrapMode(QtGui.QTextOption.WordWrap) self.editor.clear() self.horSplitter.addWidget(self.editor) self.horSplitter.setStretchFactor(0, 2) self.horSplitter.setStretchFactor(1, 3) self.verSplitter.setSizes([300, 150]) # Reset/Cancel/Save Buttons self.saveButton = QtWidgets.QPushButton("Save") self.saveButton.clicked.connect(self.accept) self.cancelButton = QtWidgets.QPushButton("Cancel") self.cancelButton.clicked.connect(self.reject) self.resetButton = QtWidgets.QPushButton("Reset Table to Defaults...") self.resetButton.clicked.connect(self.resetToDefaults) self.resetButton.setIcon(QtGui.QIcon(os.path.join(icons_directory(), 'reset-l.svg'))) # We use a button layout instead of a QButtonBox because there always will be a default # button (e.g. the Save button) that will light up, even if another widget has the focus. # From https://doc.qt.io/archives/qt-4.8/qdialogbuttonbox.html#details # However, if there is no default button set and to preserve which button is the default # button across platforms when using the QPushButton::autoDefault property, the first # push button with the accept role is made the default button when the QDialogButtonBox # is shown, self.buttonLayout = QtWidgets.QHBoxLayout() self.buttonLayout.addWidget(self.resetButton) self.buttonLayout.addStretch() if sys.platform == 'darwin': self.buttonLayout.addWidget(self.cancelButton) self.buttonLayout.addWidget(self.saveButton) else: self.buttonLayout.addWidget(self.saveButton) self.buttonLayout.addWidget(self.cancelButton) layout.addLayout(self.buttonLayout) # Connect signals and populate self.tableWidget.tableView.selectionModel().currentChanged.connect(self.currentItemChanged) self.tableWidget.tableView.model().sigItemChanged.connect(self._updateEditor) self.resize(QtCore.QSize(1100, 700)) self.tableWidget.tableView.setFocus(Qt.NoFocusReason) self.tryImportAllPlugins()
def main(): import sys app = QtWidgets.QApplication(sys.argv) window = QtWidgets.QWidget() layout = QtWidgets.QVBoxLayout(window) if 0: if 1: window.setStyleSheet(""" QLabel { background-color: #FF9900; } """) else: window.setStyleSheet(""" QLabel { margin: 5px; border: 0px solid blue; background-color: #FF9900; padding: 0px; } """) label0 = QtWidgets.QLabel('my great line edit') label1 = QtWidgets.QLabel('edit') label2 = QtWidgets.QLabel('combo') all_labels = [label0, label1, label2] for lbl in all_labels: _setLabelProps(lbl) harmonizeLabelsTextWidth(all_labels) maxWidth = labelsMaxTextWidth([label0, label1, label2]) print("\mmaxWidth: {}".format(maxWidth)) tableView = QtWidgets.QTableView() layout.addWidget(tableView) model = QtGui.QStandardItemModel(3, 2) tableView.setModel(model) tableView.horizontalHeader().resizeSection(0, 200) tableView.horizontalHeader().resizeSection(1, 300) layoutSpacing = 0 editor0 = QtWidgets.QSpinBox() editor0.setValue(5) editor0.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding) lw0 = LabeledWidget(label0, editor0, layoutSpacing=layoutSpacing) model.setData(model.index(0, 0), "A small") tableView.setIndexWidget(model.index(0, 1), lw0) editor1 = QtWidgets.QSpinBox() editor1.setValue(7) editor1.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding) lw1 = LabeledWidget(label1, editor1, layoutSpacing=layoutSpacing) model.setData(model.index(1, 0), "A SMALL seasoned curly") tableView.setIndexWidget(model.index(1, 1), lw1) comboBox = QtWidgets.QComboBox() comboBox.addItems([ "Half diet coke", "Half regular coke", "Junior western bacon cheese" ]) lw2 = LabeledWidget(label2, comboBox, layoutSpacing=layoutSpacing) model.setData(model.index(2, 0), "What else?") tableView.setIndexWidget(model.index(2, 1), lw2) window.resize(550, 400) window.show() window.raise_() sys.exit(app.exec_())
def __init__(self, configTreeModel, parent=None): """ Constructor. :param parent: """ super(ConfigWidget, self).__init__(parent=parent) # Actions that change the reset mode of the reset button self.modeActionGroup = QtWidgets.QActionGroup(self) self.modeActionGroup.setExclusive(True) self.modeAllAction = QtWidgets.QAction("Reset All", self.modeActionGroup) self.modeAllAction.setToolTip( "Changes button reset mode to reset all settings") self.modeAllAction.setCheckable(True) self.modeAllAction.triggered.connect( lambda: self.setResetMode(ResetMode.All)) self.modeRangeAction = QtWidgets.QAction("Reset Ranges", self.modeActionGroup) self.modeRangeAction.setToolTip( "Changes button reset mode to reset axes") self.modeRangeAction.setCheckable(True) self.modeRangeAction.triggered.connect( lambda: self.setResetMode(ResetMode.Ranges)) # Sanity check that actions have been added to action group assert self.modeActionGroup.actions( ), "Sanity check. resetActionGroup is empty" # Actions that actually reset the settings self.resetAllAction = QtWidgets.QAction("Reset All", self) self.resetAllAction.setToolTip("Resets all settings.") self.resetAllAction.setIcon( QtGui.QIcon(os.path.join(icons_directory(), 'reset-l.svg'))) self.resetAllAction.setShortcut("Ctrl+=") self.resetRangesAction = QtWidgets.QAction("Reset Ranges", self) self.resetRangesAction.setToolTip( "Resets range of all plots, color scales, table column/row sizes etc." ) self.resetRangesAction.setIcon( QtGui.QIcon(os.path.join(icons_directory(), 'reset-l.svg'))) self.resetRangesAction.setShortcut("Ctrl+0") self.resetButtonMenu = QtWidgets.QMenu() self.resetButtonMenu.addAction(self.resetAllAction) self.resetButtonMenu.addAction(self.resetRangesAction) self.resetButtonMenu.addSection("Default") self.resetButtonMenu.addAction(self.modeAllAction) self.resetButtonMenu.addAction(self.modeRangeAction) # Widgets self.mainLayout = QtWidgets.QVBoxLayout(self) self.mainLayout.setSpacing(5) self.mainLayout.setContentsMargins(DOCK_MARGIN, DOCK_MARGIN, DOCK_MARGIN, DOCK_MARGIN) self.configTreeView = ConfigTreeView(configTreeModel, parent=self) self.mainLayout.addWidget(self.configTreeView) self.buttonLayout = QtWidgets.QHBoxLayout() self.mainLayout.addLayout(self.buttonLayout) self.autoCheckBox = QtWidgets.QCheckBox("Auto") self.autoCheckBox.setToolTip( "Auto reset when a new item or axis is selected.") self.autoCheckBox.setChecked(True) self.resetButton = QtWidgets.QToolButton() self.resetButton.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.resetButton.setDefaultAction(self.resetButtonMenu.defaultAction()) self.resetButton.setPopupMode(QtWidgets.QToolButton.MenuButtonPopup) self.resetButton.setMenu(self.resetButtonMenu) # Set font size to the same as used for push buttons dummyButton = QtWidgets.QPushButton("dummy") fontSize = dummyButton.font().pointSize() del dummyButton logger.debug( "Setting QToolButtons font size to: {} point".format(fontSize)) font = self.resetButton.font() font.setPointSizeF(fontSize) self.resetButton.setFont(font) self.buttonLayout.addStretch() self.buttonLayout.addWidget(self.autoCheckBox) self.buttonLayout.addWidget(self.resetButton) self.buttonLayout.addStretch() self.autoCheckBox.stateChanged.connect(self.setAutoReset) self.resetRangesAction.triggered.connect( self.configTreeView.resetAllRanges) self.resetAllAction.triggered.connect( self.configTreeView.resetAllSettings) self.setResetMode(self.configTreeView.resetMode)
def __init__(self, registry, parent=None, attrNames=None, headerNames=None, headerSizes=None, onlyShowImported=False, importOnSelect=True): """ Constructor. If onlyShowImported is True, regItems that are not (successfully) imported are filtered from the table. By default onlyShowImported is False. If importOnSelect is True (the default), the item is imported if the user selects it. """ super(RegistryTab, self).__init__(parent=parent) self._importOnSelect = importOnSelect self._onlyShowImported = onlyShowImported self._registry = registry attrNames = [] if attrNames is None else attrNames headerNames = attrNames if headerNames is None else headerNames headerSizes = [] if headerSizes is None else headerSizes if headerSizes is None: headerSizes = [] else: assert len(headerSizes) == len(attrNames), \ "Size mismatch {} != {}".format(len(headerSizes), len(attrNames)) layout = QtWidgets.QVBoxLayout(self) statusLayout = QtWidgets.QHBoxLayout() layout.addLayout(statusLayout) self.statusLabel = QtWidgets.QLabel("") statusLayout.addWidget(self.statusLabel) statusLayout.setStretch(0, 1) self.loadAllButton = QtWidgets.QPushButton("Load all") self.loadAllButton.setFocusPolicy(Qt.ClickFocus) self.loadAllButton.clicked.connect(self.tryImportAllPlugins) statusLayout.addWidget(self.loadAllButton) statusLayout.setStretch(1, 0) splitter = QtWidgets.QSplitter(Qt.Vertical) layout.addWidget(splitter) # Table tableModel = RegistryTableModel(self._registry, attrNames=attrNames, parent=self) proxyTableModel = RegistryTableProxyModel(parent=self, onlyShowImported=self._onlyShowImported) proxyTableModel.setSourceModel(tableModel) self.tableView = RegistryTableView(proxyTableModel, onlyShowImported=self.onlyShowImported) tableHeader = self.tableView.horizontalHeader() for col, headerSize in enumerate(headerSizes): if headerSize: tableHeader.resizeSection(col, headerSize) selectionModel = self.tableView.selectionModel() selectionModel.currentRowChanged.connect(self.currentItemChanged) splitter.addWidget(self.tableView) splitter.setCollapsible(0, False) # Detail info widget font = QtGui.QFont() font.setFamily(MONO_FONT) font.setFixedPitch(True) font.setPointSize(FONT_SIZE) self.editor = QtWidgets.QTextEdit() self.editor.setReadOnly(True) self.editor.setFont(font) self.editor.setWordWrapMode(QtGui.QTextOption.NoWrap) self.editor.clear() splitter.addWidget(self.editor) splitter.setCollapsible(1, False) splitter.setSizes([300, 150]) self.tableView.setFocus(Qt.NoFocusReason)