本文整理汇总了Python中AnyQt.QtWidgets.QToolButton.setEnabled方法的典型用法代码示例。如果您正苦于以下问题:Python QToolButton.setEnabled方法的具体用法?Python QToolButton.setEnabled怎么用?Python QToolButton.setEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QToolButton
的用法示例。
在下文中一共展示了QToolButton.setEnabled方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_button
# 需要导入模块: from AnyQt.QtWidgets import QToolButton [as 别名]
# 或者: from AnyQt.QtWidgets.QToolButton import setEnabled [as 别名]
def add_button(self, button: ToolbarButton, action=None):
btn = QToolButton(self)
btn.setMinimumSize(30, 30)
if self.layout() is not None:
self.layout().addWidget(btn)
btn.setCheckable(button.selectable)
if action:
btn.clicked.connect(action)
if button.icon:
btn.setIcon(button.icon)
btn.setToolTip(button.text)
setattr(self, button.attr_name, btn)
if button.attr_name == "buttonSendSelections":
btn.setEnabled(not self.auto_send)
return btn
示例2: SelectionSetsWidget
# 需要导入模块: from AnyQt.QtWidgets import QToolButton [as 别名]
# 或者: from AnyQt.QtWidgets.QToolButton import setEnabled [as 别名]
class SelectionSetsWidget(QFrame):
"""
Widget for managing multiple stored item selections
"""
selectionModified = Signal(bool)
def __init__(self, parent):
QFrame.__init__(self, parent)
self.setContentsMargins(0, 0, 0, 0)
layout = QVBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(1)
self._setNameLineEdit = QLineEdit(self)
layout.addWidget(self._setNameLineEdit)
self._setListView = QListView(self)
self._listModel = QStandardItemModel(self)
self._proxyModel = QSortFilterProxyModel(self)
self._proxyModel.setSourceModel(self._listModel)
self._setListView.setModel(self._proxyModel)
self._setListView.setItemDelegate(ListItemDelegate(self))
self._setNameLineEdit.textChanged.connect(
self._proxyModel.setFilterFixedString)
self._completer = QCompleter(self._listModel, self)
self._setNameLineEdit.setCompleter(self._completer)
self._listModel.itemChanged.connect(self._onSetNameChange)
layout.addWidget(self._setListView)
buttonLayout = QHBoxLayout()
self._addAction = QAction(
"+", self, toolTip="Add a new sort key")
self._updateAction = QAction(
"Update", self, toolTip="Update/save current selection")
self._removeAction = QAction(
"\u2212", self, toolTip="Remove selected sort key.")
self._addToolButton = QToolButton(self)
self._updateToolButton = QToolButton(self)
self._removeToolButton = QToolButton(self)
self._updateToolButton.setSizePolicy(
QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)
self._addToolButton.setDefaultAction(self._addAction)
self._updateToolButton.setDefaultAction(self._updateAction)
self._removeToolButton.setDefaultAction(self._removeAction)
buttonLayout.addWidget(self._addToolButton)
buttonLayout.addWidget(self._updateToolButton)
buttonLayout.addWidget(self._removeToolButton)
layout.addLayout(buttonLayout)
self.setLayout(layout)
self._addAction.triggered.connect(self.addCurrentSelection)
self._updateAction.triggered.connect(self.updateSelectedSelection)
self._removeAction.triggered.connect(self.removeSelectedSelection)
self._setListView.selectionModel().selectionChanged.connect(
self._onListViewSelectionChanged)
self.selectionModel = None
self._selections = []
def sizeHint(self):
size = QFrame.sizeHint(self)
return QSize(size.width(), 150)
def _onSelectionChanged(self, selected, deselected):
self.setSelectionModified(True)
def _onListViewSelectionChanged(self, selected, deselected):
try:
index = self._setListView.selectedIndexes()[0]
except IndexError:
return
self.commitSelection(self._proxyModel.mapToSource(index).row())
def _onSetNameChange(self, item):
self.selections[item.row()].name = str(item.text())
def _setButtonStates(self, val):
self._updateToolButton.setEnabled(val)
def setSelectionModel(self, selectionModel):
if self.selectionModel:
self.selectionModel.selectionChanged.disconnect(
self._onSelectionChanged)
self.selectionModel = selectionModel
self.selectionModel.selectionChanged.connect(self._onSelectionChanged)
def addCurrentSelection(self):
item = self.addSelection(
SelectionByKey(self.selectionModel.selection(),
name="New selection",
key=(1, 2, 3, 10)))
index = self._proxyModel.mapFromSource(item.index())
#.........这里部分代码省略.........