def __init__(self, label, widget, layoutSpacing=None, layoutContentsMargins=(0, 0, 0, 0), labelStretch=0, spacerStretch=0, widgetStretch=1, parent=None): """ Constructor. :param widget: the 'wrapped' widget, which will be displayed on the right :param labelText: text given to the label :param parent: parent wigdet """ super(LabeledWidget, self).__init__(parent=parent) self.layout = QtWidgets.QHBoxLayout(self) self.layout.setContentsMargins(*layoutContentsMargins) if layoutSpacing is not None: self.layout.setSpacing(layoutSpacing) self.label = label self.widget = widget self.layout.addWidget(self.label, stretch=labelStretch) if spacerStretch: self.layout.addStretch(stretch=spacerStretch) self.layout.addWidget(self.widget, stretch=widgetStretch)
def __init__(self, inspectorActionGroup, parent=None): super(InspectorSelectionPane, self).__init__(parent=parent) # self.setFrameShape(QtWidgets.QFrame.Box) self.menuButton = QtWidgets.QPushButton(NO_INSPECTOR_LABEL) self.menuButton.setMinimumWidth(10) inspectorMenu = QtWidgets.QMenu("Change Inspector", parent=self.menuButton) for action in inspectorActionGroup.actions(): inspectorMenu.addAction(action) self.menuButton.setMenu(inspectorMenu) self.messageLabel = QtWidgets.QLabel("") self.messageLabel.setObjectName("message_label") self.messageLabel.setFrameStyle(QtWidgets.QFrame.Panel) self.messageLabel.setFrameShadow(QtWidgets.QFrame.Sunken) self.messageLabel.setTextInteractionFlags(Qt.TextSelectableByMouse) self.mainLayout = QtWidgets.QHBoxLayout() self.mainLayout.setContentsMargins(DOCK_MARGIN, DOCK_MARGIN, DOCK_MARGIN, DOCK_MARGIN) self.setLayout(self.mainLayout) self.mainLayout.addWidget(self.menuButton, stretch=0) self.mainLayout.addWidget(self.messageLabel, stretch=1) setWidgetSizePolicy(self.menuButton, hor=QtWidgets.QSizePolicy.Minimum) setWidgetSizePolicy(self.messageLabel, hor=QtWidgets.QSizePolicy.Ignored) setWidgetSizePolicy(self, hor=QtWidgets.QSizePolicy.MinimumExpanding, ver=QtWidgets.QSizePolicy.Fixed)
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 __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, cti, delegate, subEditors=None, parent=None): """ Wraps the child widgets in a horizontal layout and appends a reset button. Maintains a reference to the ConfigTreeItem (cti) and to delegate, this last reference is so that we can command the delegate to commit and close the editor. The subEditors must be a list of QWidgets. Note that the sub editors do not yet have to be initialized with editor data since setData will be called by the delegate after construction. There it can be taken care of. """ super(AbstractCtiEditor, self).__init__(parent=parent) # Prevent underlying table cell from being visible if the editor doesn't fill the cell self.setAutoFillBackground(True) self._subEditors = [] self.delegate = delegate self.cti = cti # From the QAbstractItemDelegate.createEditor docs: The returned editor widget should have # Qt.StrongFocus; otherwise, QMouseEvents received by the widget will propagate to the view. # The view's background will shine through unless the editor paints its own background # (e.g., with setAutoFillBackground()). self.setFocusPolicy(Qt.StrongFocus) self.hBoxLayout = QtWidgets.QHBoxLayout() self.hBoxLayout.setContentsMargins(0, 0, 0, 0) self.hBoxLayout.setSpacing(0) self.setLayout(self.hBoxLayout) self.resetButton = QtWidgets.QToolButton() self.resetButton.setText("Reset") self.resetButton.setToolTip("Reset to default value.") self.resetButton.setIcon( QtGui.QIcon(os.path.join(icons_directory(), 'reset-l.svg'))) self.resetButton.setFocusPolicy(Qt.NoFocus) self.resetButton.clicked.connect(self.resetEditorValue) self.hBoxLayout.addWidget(self.resetButton, alignment=Qt.AlignRight) self.cti.model.sigItemChanged.connect(self.modelItemChanged) for subEditor in (subEditors if subEditors is not None else []): self.addSubEditor(subEditor)
def __init__(self, execInspectorDialogAction, inspectorActionGroup, parent=None): super(InspectorSelectionPane, self).__init__(parent=parent) #self.setFrameShape(QtWidgets.QFrame.Box) self.layout = QtWidgets.QHBoxLayout() self.setLayout(self.layout) # self.label = QtWidgets.QLabel("Current inspector") # self.layout.addWidget(self.label) self.menuButton = QtWidgets.QPushButton("No inspector") self.layout.addWidget(self.menuButton) inspectorMenu = QtWidgets.QMenu("Change Inspector", parent=self.menuButton) addInspectorActionsToMenu(inspectorMenu, execInspectorDialogAction, inspectorActionGroup) self.menuButton.setMenu(inspectorMenu) sizePolicy = self.sizePolicy() sizePolicy.setVerticalPolicy(QtWidgets.QSizePolicy.Fixed) self.setSizePolicy(sizePolicy)
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, spinBox, slider=None, layoutSpacing=None, layoutContentsMargins=(0, 0, 0, 0), parent=None): """ Constructor. The settings (min, max, enabled, etc) from the SpinBox will be used for the slider as well. That is, the spin box is the master. """ super(SpinSlider, self).__init__(parent=parent) check_class(spinBox, QtWidgets.QSpinBox, allow_none=True) check_class(slider, QtWidgets.QSlider, allow_none=True) self.layout = QtWidgets.QHBoxLayout(self) self.layout.setContentsMargins(*layoutContentsMargins) if layoutSpacing is not None: self.layout.setSpacing(layoutSpacing) if spinBox is None: self.spinbox = QtWidgets.QSpinBox() else: self.spinbox = spinBox if slider is None: self.slider = QtWidgets.QSlider(Qt.Horizontal) else: self.slider = slider self.slider.setMinimum(self.spinbox.minimum()) self.slider.setMaximum(self.spinbox.maximum()) self.slider.setValue(self.spinbox.value()) self.slider.setEnabled(self.spinbox.isEnabled()) self.layout.addWidget(self.spinbox, stretch=0) self.layout.addWidget(self.slider, stretch=1) self.spinbox.valueChanged.connect(self.slider.setValue) self.slider.valueChanged.connect(self.spinbox.setValue)
def __init__(self, parent=None): super(ColorSelectWidget, self).__init__(parent=parent) self.mainLayout = QtWidgets.QHBoxLayout() self.mainLayout.setContentsMargins(0, 0, 0, 0) self.setLayout(self.mainLayout) self.lineEditor = QtWidgets.QLineEdit() self.lineEditor.setToolTip( "Color hex code: a '#' followed by 6 hex-digits.") self.mainLayout.addWidget(self.lineEditor) self.setFocusProxy(self.lineEditor) regExp = QtCore.QRegExp(r'#[0-9A-F]{6}', Qt.CaseInsensitive) validator = QtGui.QRegExpValidator(regExp, parent=self) self.lineEditor.setValidator(validator) self.pickButton = QtWidgets.QPushButton() self.pickButton.setText("Color Picker...") self.pickButton.setToolTip("Open color dialog.") self.pickButton.setFocusPolicy(Qt.NoFocus) self.pickButton.clicked.connect(self.openColorDialog) self.mainLayout.addWidget(self.pickButton)
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 __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)