本文整理汇总了Python中PySide.QtGui.QComboBox.setHidden方法的典型用法代码示例。如果您正苦于以下问题:Python QComboBox.setHidden方法的具体用法?Python QComboBox.setHidden怎么用?Python QComboBox.setHidden使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QComboBox
的用法示例。
在下文中一共展示了QComboBox.setHidden方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SelectionOptions
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setHidden [as 别名]
class SelectionOptions(QWidget):
"""Widget for modifying the selected circuit or gate."""
def __init__(self, view):
super(SelectionOptions, self).__init__()
self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
self.view = view
self.view.scene().selectionChanged.connect(self.updateOptions)
self.gridLayout = QGridLayout(self)
self.nameLabel = QLabel(self.str_name, self)
self.gridLayout.addWidget(self.nameLabel, 0, 0, 1, 1)
self.nameLE = QLineEdit(self)
self.gridLayout.addWidget(self.nameLE, 0, 1, 1, 2)
self.nameLE.returnPressed.connect(self.setItemName)
self.showNameLabel = QLabel(self.str_showName, self)
self.gridLayout.addWidget(self.showNameLabel, 1, 0, 1, 1)
self.showNameCB = QCheckBox(self)
self.gridLayout.addWidget(self.showNameCB, 1, 1, 1, 1)
self.showNameCB.stateChanged.connect(self.setNameVisibility)
self.showCategoryLabel = QLabel(self.str_showCategory, self)
self.gridLayout.addWidget(self.showCategoryLabel, 2, 0, 1, 1)
self.showCategoryCB = QCheckBox(self)
self.gridLayout.addWidget(self.showCategoryCB, 2, 1, 1, 1)
self.showCategoryCB.stateChanged.connect(self.setCategoryVisibility)
self.nbInputsLabel = QLabel(self.str_nbInputs, self)
self.gridLayout.addWidget(self.nbInputsLabel, 3, 0, 1, 1)
self.nbInputsCB = QComboBox(self)
self.nbInputsCB.activated.connect(self.setNbInputs)
self.nbInputsCB.addItems([str(x) for x in range(2, 33)])
self.gridLayout.addWidget(self.nbInputsCB, 3, 1, 1, 2)
self.orientLabel = QLabel(self.str_orientation, self)
self.gridLayout.addWidget(self.orientLabel, 4, 0, 1, 1)
self.cwRotationButton = QPushButton(self)
self.cwRotationButton.setText("↻")
self.cwRotationButton.clicked.connect(
lambda: self.view.rotateItems(90))
self.gridLayout.addWidget(self.cwRotationButton, 4, 1, 1, 1)
self.acwRotationButton = QPushButton(self)
self.acwRotationButton.setText("↺")
self.acwRotationButton.clicked.connect(
lambda: self.view.rotateItems(-90))
self.gridLayout.addWidget(self.acwRotationButton, 4, 2, 1, 1)
self.updateOptions()
def updateOptions(self):
"""Hides irrelevant options, and sets reasonable values for the
visible options.
"""
selection = self.view.scene().selectedItems()
for widget in self.findChildren(QWidget): # Hide all options
widget.setHidden(True)
if not len(selection): # then return if no selection.
return
# The number of entries option only applies to gates (except NOT)
notAllGates = any([i.data.__class__ not in [
AndGate, NandGate, OrGate, NorGate, XorGate, XnorGate]
for i in selection])
self.nbInputsLabel.setHidden(notAllGates)
self.nbInputsCB.setHidden(notAllGates)
# Only circuits may display their category, we only show the
# option if at least one circuit is present
if any([isinstance(i, CircuitItem) for i in selection]):
self.showCategoryLabel.setHidden(False)
self.showCategoryCB.setHidden(False)
# Wires have no name; no need for name visibility
if not all([isinstance(i, WireItem) for i in selection]):
self.showNameLabel.setHidden(False)
self.showNameCB.setHidden(False)
# We only show the name if we have exactly one non-wire item
if len(selection) == 1 and not isinstance(selection[0], WireItem):
self.nameLabel.setHidden(False)
self.nameLE.blockSignals(True)
self.nameLE.setText(selection[0].data.name)
self.nameLE.blockSignals(False)
self.nameLE.setHidden(False)
def setCategoryVisibility(self, state):
"""Show/Hide the category of an item in the main view."""
for item in self.view.scene().selectedItems():
if isinstance(item, CircuitItem):
item.setCategoryVisibility(True if state else False)
def setItemName(self):
"""Show/Hide the category of an item in the main view."""
item = self.view.scene().selectedItems()[0]
item.data.setName(self.nameLE.text())
item.setupPaint()
#.........这里部分代码省略.........