本文整理匯總了Python中Qt.QtWidgets.QComboBox方法的典型用法代碼示例。如果您正苦於以下問題:Python QtWidgets.QComboBox方法的具體用法?Python QtWidgets.QComboBox怎麽用?Python QtWidgets.QComboBox使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Qt.QtWidgets
的用法示例。
在下文中一共展示了QtWidgets.QComboBox方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: createInputWidgets
# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QComboBox [as 別名]
def createInputWidgets(self, inputsCategory, inGroup=None, pins=True):
preIndex = inputsCategory.Layout.count()
if pins:
super(UIFloatRamp, self).createInputWidgets(inputsCategory, inGroup)
inputVal = inputsCategory.getWidgetByName("input")
if not self._rawNode.input.isArray():
inputVal.setMinimum(0.0)
inputVal.setMaximum(1.0)
ramp = pyf_RampSpline(self._rawNode.ramp, bezier=self._rawNode._curveTypes[self._rawNode._curveType] == "bezier")
ramp.tickClicked.connect(self.rampChanged)
ramp.tickAdded.connect(self.rampChanged)
ramp.tickRemoved.connect(self.rampChanged)
ramp.tickMoved.connect(self.rampChanged)
rampRef = weakref.ref(ramp)
self.ramps.append(rampRef)
selector = QtWidgets.QComboBox()
selectorRef = weakref.ref(selector)
self.selectors.append(selectorRef)
for i in self._rawNode._curveTypes:
selector.addItem(i)
selector.setCurrentIndex(self._rawNode._curveType)
selector.activated.connect(self.changeCurveType)
inputsCategory.insertWidget(preIndex, "CurveType", selector,group=inGroup)
inputsCategory.insertWidget(preIndex+1, "Ramp", ramp,group=inGroup)
示例2: setupUi
# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QComboBox [as 別名]
def setupUi(self, QSpectrumAnalyzerPersistence):
QSpectrumAnalyzerPersistence.setObjectName("QSpectrumAnalyzerPersistence")
QSpectrumAnalyzerPersistence.resize(250, 130)
self.verticalLayout = QtWidgets.QVBoxLayout(QSpectrumAnalyzerPersistence)
self.verticalLayout.setObjectName("verticalLayout")
self.formLayout = QtWidgets.QFormLayout()
self.formLayout.setObjectName("formLayout")
self.label_2 = QtWidgets.QLabel(QSpectrumAnalyzerPersistence)
self.label_2.setObjectName("label_2")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label_2)
self.decayFunctionComboBox = QtWidgets.QComboBox(QSpectrumAnalyzerPersistence)
self.decayFunctionComboBox.setObjectName("decayFunctionComboBox")
self.decayFunctionComboBox.addItem("")
self.decayFunctionComboBox.addItem("")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.decayFunctionComboBox)
self.label = QtWidgets.QLabel(QSpectrumAnalyzerPersistence)
self.label.setObjectName("label")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label)
self.persistenceLengthSpinBox = QtWidgets.QSpinBox(QSpectrumAnalyzerPersistence)
self.persistenceLengthSpinBox.setProperty("value", 5)
self.persistenceLengthSpinBox.setObjectName("persistenceLengthSpinBox")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.persistenceLengthSpinBox)
self.verticalLayout.addLayout(self.formLayout)
spacerItem = QtWidgets.QSpacerItem(20, 5, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.verticalLayout.addItem(spacerItem)
self.buttonBox = QtWidgets.QDialogButtonBox(QSpectrumAnalyzerPersistence)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.verticalLayout.addWidget(self.buttonBox)
self.label_2.setBuddy(self.decayFunctionComboBox)
self.label.setBuddy(self.persistenceLengthSpinBox)
self.retranslateUi(QSpectrumAnalyzerPersistence)
self.decayFunctionComboBox.setCurrentIndex(1)
self.buttonBox.accepted.connect(QSpectrumAnalyzerPersistence.accept)
self.buttonBox.rejected.connect(QSpectrumAnalyzerPersistence.reject)
QtCore.QMetaObject.connectSlotsByName(QSpectrumAnalyzerPersistence)
QSpectrumAnalyzerPersistence.setTabOrder(self.decayFunctionComboBox, self.persistenceLengthSpinBox)
QSpectrumAnalyzerPersistence.setTabOrder(self.persistenceLengthSpinBox, self.buttonBox)
示例3: createInputWidgets
# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QComboBox [as 別名]
def createInputWidgets(self, inputsCategory, inGroup=None, pins=True):
self.ramps.clear()
self.colors.clear()
preIndex = inputsCategory.Layout.count()
if pins:
super(UIColorRamp, self).createInputWidgets(inputsCategory, inGroup)
inputVal = inputsCategory.getWidgetByName("input")
if not self._rawNode.input.isArray():
inputVal.setMinimum(0.0)
inputVal.setMaximum(1.0)
ramp = pyf_RampColor(self._rawNode.ramp, bezier=self._rawNode._curveTypes[self._rawNode._curveType] == "bezier", parent=inputsCategory)
ramp.tickClicked.connect(self.rampChanged)
ramp.tickAdded.connect(self.rampChanged)
ramp.tickRemoved.connect(self.rampChanged)
ramp.tickMoved.connect(self.rampChanged)
rampRef = weakref.ref(ramp)
self.ramps.append(rampRef)
selector = QtWidgets.QComboBox()
selectorRef = weakref.ref(selector)
self.selectors.append(selectorRef)
for i in self._rawNode._curveTypes:
selector.addItem(i)
colorChanger = pyf_ColorSlider(type="int", parent=inputsCategory)
colorRef = weakref.ref(colorChanger)
self.colors.append(colorRef)
colorChanger.valueChanged.connect(ramp.setColor)
ramp.colorClicked.connect(self.colorClicked)
selector.setCurrentIndex(self._rawNode._curveType)
selector.activated.connect(self.changeCurveType)
inputsCategory.insertWidget(preIndex, "CurveType", selector, group=inGroup)
inputsCategory.insertWidget(preIndex + 1, "Ramp", ramp, group=inGroup)
inputsCategory.insertWidget(preIndex + 1, "Selected Color", colorChanger, group=inGroup)
示例4: createInputWidgets
# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QComboBox [as 別名]
def createInputWidgets(self, inputsCategory, inGroup=None, pins=True):
inputVal = None
preIndex = inputsCategory.Layout.count()
if pins:
super(UIConstantNode, self).createInputWidgets(inputsCategory, inGroup)
inputVal = inputsCategory.getWidgetByName("in")
selector = QComboBox()
for i in self._rawNode.pinTypes:
selector.addItem(i)
if self.input.dataType in self._rawNode.pinTypes:
selector.setCurrentIndex(
self._rawNode.pinTypes.index(self.input.dataType))
structSelector = QComboBox()
for i in [i.name for i in list(StructureType)]:
structSelector.addItem(i)
structSelector.inputsCategory = inputsCategory
structSelector.setCurrentIndex(self.input._rawPin._currStructure)
selector.activated.connect(self._rawNode.updateType)
selector.activated.connect(
lambda: self.updateType(inputVal, inputsCategory, inGroup))
structSelector.activated.connect(self._rawNode.selectStructure)
structSelector.activated.connect(
lambda: self.selectStructure(inputVal, inputsCategory, inGroup))
inputsCategory.insertWidget(
preIndex, "DataType", selector, group=inGroup)
inputsCategory.insertWidget(preIndex + 1, "Structure", structSelector, group=inGroup)
示例5: createInputWidgets
# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QComboBox [as 別名]
def createInputWidgets(self, inputsCategory, inGroup=None, pins=True):
if pins:
super(UIMakeDictNode, self).createInputWidgets(inputsCategory, inGroup)
selector = QComboBox()
for i in self.input._rawPin._defaultSupportedDataTypes:
selector.addItem(i)
selector.setCurrentIndex(self.input._rawPin._defaultSupportedDataTypes.index(
self.input._rawPin.dataType))
selector.activated.connect(self.changeType)
inputsCategory.insertWidget(0, "DataType", selector, group=inGroup)
示例6: createInputWidgets
# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QComboBox [as 別名]
def createInputWidgets(self, inputsCategory, group=None, pins=True):
preIndex = inputsCategory.Layout.count()
if pins:
super(UIConvertToNode, self).createInputWidgets(inputsCategory, group)
selector = QComboBox()
for i in self._rawNode.pinTypes:
selector.addItem(i)
if self.output.dataType in self._rawNode.pinTypes:
selector.setCurrentIndex(
self._rawNode.pinTypes.index(self.output.dataType))
selector.activated.connect(self._rawNode.updateType)
inputsCategory.insertWidget(preIndex, "DataType", selector, group=group)
示例7: test_load_ui_existingLayoutOnDialog
# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QComboBox [as 別名]
def test_load_ui_existingLayoutOnDialog():
"""Tests to see if loading a ui onto a layout in a Dialog works"""
import sys
from Qt import QtWidgets, QtCompat
msgs = 'QLayout: Attempting to add QLayout "" to QDialog ' \
'"Dialog", which already has a layout'
with ignoreQtMessageHandler([msgs]):
app = QtWidgets.QApplication(sys.argv)
win = QtWidgets.QDialog()
QtWidgets.QComboBox(win)
QtWidgets.QHBoxLayout(win)
QtCompat.loadUi(self.ui_qdialog, win)
app.exit()
示例8: test_load_ui_existingLayoutOnMainWindow
# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QComboBox [as 別名]
def test_load_ui_existingLayoutOnMainWindow():
"""Tests to see if loading a ui onto a layout in a MainWindow works"""
import sys
from Qt import QtWidgets, QtCompat
msgs = 'QLayout: Attempting to add QLayout "" to QMainWindow ' \
'"", which already has a layout'
with ignoreQtMessageHandler([msgs]):
app = QtWidgets.QApplication(sys.argv)
win = QtWidgets.QMainWindow()
QtWidgets.QComboBox(win)
QtWidgets.QHBoxLayout(win)
QtCompat.loadUi(self.ui_qmainwindow, win)
app.exit()
示例9: test_load_ui_existingLayoutOnDockWidget
# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QComboBox [as 別名]
def test_load_ui_existingLayoutOnDockWidget():
"""Tests to see if loading a ui onto a layout in a DockWidget works"""
import sys
from Qt import QtWidgets, QtCompat
msgs = 'QLayout: Attempting to add QLayout "" to QDockWidget ' \
'"", which already has a layout'
with ignoreQtMessageHandler([msgs]):
app = QtWidgets.QApplication(sys.argv)
win = QtWidgets.QDockWidget()
QtWidgets.QComboBox(win)
QtWidgets.QHBoxLayout(win)
QtCompat.loadUi(self.ui_qdockwidget, win)
app.exit()
示例10: test_load_ui_existingLayoutOnWidget
# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QComboBox [as 別名]
def test_load_ui_existingLayoutOnWidget():
"""Tests to see if loading a ui onto a layout in a Widget works"""
import sys
from Qt import QtWidgets, QtCompat
msgs = 'QLayout: Attempting to add QLayout "" to QWidget ' \
'"Form", which already has a layout'
with ignoreQtMessageHandler([msgs]):
app = QtWidgets.QApplication(sys.argv)
win = QtWidgets.QWidget()
QtWidgets.QComboBox(win)
QtWidgets.QHBoxLayout(win)
QtCompat.loadUi(self.ui_qwidget, win)
app.exit()
示例11: setupUi
# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QComboBox [as 別名]
def setupUi(self, QSpectrumAnalyzerSmoothing):
QSpectrumAnalyzerSmoothing.setObjectName("QSpectrumAnalyzerSmoothing")
QSpectrumAnalyzerSmoothing.resize(250, 130)
self.verticalLayout = QtWidgets.QVBoxLayout(QSpectrumAnalyzerSmoothing)
self.verticalLayout.setObjectName("verticalLayout")
self.formLayout = QtWidgets.QFormLayout()
self.formLayout.setObjectName("formLayout")
self.label = QtWidgets.QLabel(QSpectrumAnalyzerSmoothing)
self.label.setObjectName("label")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label)
self.windowFunctionComboBox = QtWidgets.QComboBox(QSpectrumAnalyzerSmoothing)
self.windowFunctionComboBox.setObjectName("windowFunctionComboBox")
self.windowFunctionComboBox.addItem("")
self.windowFunctionComboBox.addItem("")
self.windowFunctionComboBox.addItem("")
self.windowFunctionComboBox.addItem("")
self.windowFunctionComboBox.addItem("")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.windowFunctionComboBox)
self.label_2 = QtWidgets.QLabel(QSpectrumAnalyzerSmoothing)
self.label_2.setObjectName("label_2")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label_2)
self.windowLengthSpinBox = QtWidgets.QSpinBox(QSpectrumAnalyzerSmoothing)
self.windowLengthSpinBox.setMinimum(3)
self.windowLengthSpinBox.setMaximum(1001)
self.windowLengthSpinBox.setProperty("value", 11)
self.windowLengthSpinBox.setObjectName("windowLengthSpinBox")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.windowLengthSpinBox)
self.verticalLayout.addLayout(self.formLayout)
spacerItem = QtWidgets.QSpacerItem(20, 1, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.verticalLayout.addItem(spacerItem)
self.buttonBox = QtWidgets.QDialogButtonBox(QSpectrumAnalyzerSmoothing)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.verticalLayout.addWidget(self.buttonBox)
self.label.setBuddy(self.windowFunctionComboBox)
self.label_2.setBuddy(self.windowLengthSpinBox)
self.retranslateUi(QSpectrumAnalyzerSmoothing)
self.windowFunctionComboBox.setCurrentIndex(1)
self.buttonBox.accepted.connect(QSpectrumAnalyzerSmoothing.accept)
self.buttonBox.rejected.connect(QSpectrumAnalyzerSmoothing.reject)
QtCore.QMetaObject.connectSlotsByName(QSpectrumAnalyzerSmoothing)
QSpectrumAnalyzerSmoothing.setTabOrder(self.windowFunctionComboBox, self.windowLengthSpinBox)
QSpectrumAnalyzerSmoothing.setTabOrder(self.windowLengthSpinBox, self.buttonBox)
示例12: buildUI
# 需要導入模塊: from Qt import QtWidgets [as 別名]
# 或者: from Qt.QtWidgets import QComboBox [as 別名]
def buildUI(self):
# Like in the LightWidget we show our
layout = QtWidgets.QGridLayout(self)
# We create a combobox
# Comboboxes are essentially dropdown selectionwidgets
self.lightTypeCB = QtWidgets.QComboBox()
# We populate it with the items in our lightTypes dictionary
# I like to have my items alphabetically so I sort it to begin with
for lightType in sorted(self.lightTypes):
# We add the option to the combobox
self.lightTypeCB.addItem(lightType)
# Finally we add it to the layout in row 0, column 0
# We tell it take 1 row and two columns worth of space
layout.addWidget(self.lightTypeCB, 0, 0, 1, 2)
# We create a button to create the chosen lights
createBtn = QtWidgets.QPushButton('Create')
# We connect the button so it calls the createLight method when its clicked
createBtn.clicked.connect(self.createLight)
# We add it to the layout in row 0, column 2
layout.addWidget(createBtn, 0, 2)
# We want to put all the LightWidgets inside a scrolling container
# We first need a container widget
scrollWidget = QtWidgets.QWidget()
# We want to make sure this widget only tries to be the maximum size of its contents
scrollWidget.setSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum)
# Then we give it a vertical layout because we want everything arranged vertically
self.scrollLayout = QtWidgets.QVBoxLayout(scrollWidget)
# Finally we create a scrollArea that will be in charge of scrolling its contents
scrollArea = QtWidgets.QScrollArea()
# Make sure it's resizable so it resizes as the UI grows or shrinks
scrollArea.setWidgetResizable(True)
# Then we set it to use our container widget to scroll
scrollArea.setWidget(scrollWidget)
# Then we add this scrollArea to the main layout, at row 1, column 0
# We tell it to take 1 row and 3 columns of space
layout.addWidget(scrollArea, 1, 0, 1, 3)
# We add the save button to save our lights
saveBtn = QtWidgets.QPushButton('Save')
# When clicked it will call the saveLights method
saveBtn.clicked.connect(self.saveLights)
# We add it to row 2, column 0
layout.addWidget(saveBtn, 2, 0)
# We also add an import button to import our lights
importBtn = QtWidgets.QPushButton('Import')
# When clicked it will call the importLights method
importBtn.clicked.connect(self.importLights)
# We add it to row 2, column 1
layout.addWidget(importBtn, 2, 1)
# We need a refresh button to manually force the UI to refresh on changes
refreshBtn = QtWidgets.QPushButton('Refresh')
# We'll connect this to the refresh method
refreshBtn.clicked.connect(self.refresh)
# Finally we add it to the layout at row 2, column 2
layout.addWidget(refreshBtn, 2, 2)