本文整理汇总了Python中PySide.QtGui.QComboBox.addItems方法的典型用法代码示例。如果您正苦于以下问题:Python QComboBox.addItems方法的具体用法?Python QComboBox.addItems怎么用?Python QComboBox.addItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QComboBox
的用法示例。
在下文中一共展示了QComboBox.addItems方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: aLabeledPopup
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import addItems [as 别名]
class aLabeledPopup(QWidget):
def __init__(self, var, text, item_list, pos = "side", max_size = 200):
QWidget.__init__(self)
self.setContentsMargins(1, 1, 1, 1)
if pos == "side":
self.layout1=QHBoxLayout()
else:
self.layout1 = QVBoxLayout()
self.layout1.setContentsMargins(1, 1, 1, 1)
self.layout1.setSpacing(1)
self.setLayout(self.layout1)
self.item_combo = QComboBox()
self.item_combo.addItems(item_list)
self.item_combo.setFont(QFont('SansSerif', 12))
self.label = QLabel(text)
# self.label.setAlignment(Qt.AlignLeft)
self.label.setFont(QFont('SansSerif', 12))
self.layout1.addWidget(self.label)
self.layout1.addWidget(self.item_combo)
self.var = var
self.item_combo.textChanged.connect(self.when_modified)
self.item_combo.currentIndexChanged.connect(self.when_modified)
self.when_modified()
def when_modified(self):
self.var.set(self.item_combo.currentText())
def hide(self):
QWidget.hide(self)
示例2: DragPlotWidget
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import addItems [as 别名]
class DragPlotWidget(QFrame):
''' draggable widget plotting data and
a combo box to choose channel
'''
def __init__(self, parent=None):
super(DragPlotWidget, self).__init__(parent)
# transparent fill color and a frame with size 400x250
self.setStyleSheet("QFrame { border: 2px solid black; background-image: url(); }")
self.setGeometry(1,1,400,250)
# arrange elements in a gridLayout
l = QGridLayout()
self.setLayout(l)
self.p = pq.PlotWidget(self)
self.p.setYRange(-0.0002, 0.0002)
self.pl1 = self.p.plot(np.linspace(0,3.4, 1000)) # initial plot
self.box = QComboBox(self)
self.box.addItems(["EMG " + str(x+1) for x in range(16)])
self.box.currentIndexChanged.connect(self.changeChannel)
l.addWidget(self.p)
l.addWidget(self.box)
self.dragPos = QPoint(0,0)
def mousePressEvent(self, e):
''' enter drag mode by left click and save position '''
if e.buttons() != Qt.LeftButton:
return
self.dragPos = e.pos()
def mouseMoveEvent(self, e):
''' move by holding left mouse button and update position
- removing offset by subtracting saved dragPos
'''
if e.buttons() != Qt.LeftButton:
return
position = e.pos() + self.pos() - self.dragPos
self.move(position)
self.update()
self.parent().update()
def mouseReleaseEvent(self, e):
''' release left mouse button and exit drag mode '''
if e.buttons() != Qt.LeftButton:
return
position = e.pos() + self.pos() - self.dragPos
self.move(position)
def changeChannel(self, index):
''' change channel to index and clear plot '''
self.p.plot([0], clear=True)
def updatePlot(self, data):
''' plot new data '''
self.p.plot(data[self.box.currentIndex()], clear=True)
示例3: AddScenarioDlg
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import addItems [as 别名]
class AddScenarioDlg(QDialog):
def __init__(self, root_node, parent=None):
super(AddScenarioDlg, self).__init__(parent)
self.setWindowTitle("Add Scenario")
type_label = QLabel("&Scenario Type:")
self.type_combobox = QComboBox()
type_label.setBuddy(self.type_combobox)
self.type_combobox.addItems(["External Fire", "Liquid Overfill", "Regulator Failure"])
device_label = QLabel("&Associated Relief Device:")
self.device_combobox = QComboBox()
device_label.setBuddy(self.device_combobox)
for area in root_node.children:
for device in area.children:
self.device_combobox.addItem(device.name, device)
button_box = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
layout = QGridLayout()
layout.addWidget(type_label, 0, 0)
layout.addWidget(self.type_combobox, 0, 1)
layout.addWidget(device_label, 1, 0)
layout.addWidget(self.device_combobox, 1, 1)
layout.addWidget(button_box, 2, 1)
self.setLayout(layout)
button_box.accepted.connect(self.accept)
button_box.rejected.connect(self.reject)
def returnVals(self):
return (self.type_combobox.currentText(), self.device_combobox.itemData(self.device_combobox.currentIndex()))
示例4: ChooseMarkerDialog
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import addItems [as 别名]
class ChooseMarkerDialog(QDialog):
def __init__(self,markers):
super(ChooseMarkerDialog, self).__init__()
self.setWindowTitle('Select final marker...')
markerLabel = QLabel('Marker:')
self.marker = QComboBox()
self.marker.addItems(markers)
self.marker.setCurrentIndex(-1)
layout = QGridLayout()
layout.addWidget(markerLabel,0,0)
layout.addWidget(self.marker,0,1)
self.buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttons.accepted.connect(self.accept)
self.buttons.rejected.connect(self.reject)
layout.addWidget(self.buttons,100,0,1,2)
self.setLayout(layout)
def getMarker(self):
return self.marker.currentText()
@staticmethod
def run(markers,parent = None):
dialog = ChooseMarkerDialog(markers)
result = dialog.exec_()
marker = dialog.getMarker()
return (marker,result == QDialog.Accepted)
示例5: AddFilterDlg
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import addItems [as 别名]
class AddFilterDlg(QDialog):
def __init__(self, parent=None):
super(AddFilterDlg, self).__init__(parent)
self.setWindowTitle("Advanced Filtering Options")
note_label = QLabel("NOTE: These filtering options apply exclusively to relief devices, not to the relief device area they belong to or to their scenarios.")
pressure_label = QLabel("Filter where <b>Set Pressure</b> is")
self.pressure_combobox = QComboBox()
self.pressure_combobox.addItems(["Greater Than", "Less Than", "Equal To", "Not Equal To"])
self.pressure_value = QDoubleSpinBox()
pressure_layout = QHBoxLayout()
pressure_layout.addWidget(pressure_label)
pressure_layout.addWidget(self.pressure_combobox)
pressure_layout.addWidget(self.pressure_value)
button_box = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
layout = QGridLayout()
layout.addWidget(note_label, 0, 0)
layout.addLayout(pressure_layout, 1, 0)
layout.addWidget(button_box, 2, 0)
self.setLayout(layout)
button_box.accepted.connect(self.accept)
button_box.rejected.connect(self.reject)
def returnVals(self):
return (self.pressure_combobox.currentText(), self.pressure_value.value())
示例6: setup_toolbar
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import addItems [as 别名]
def setup_toolbar(self):
color_widget = ColorWidget()
color_widget.color_changed.connect(self.fourier.on_color_change)
self.toolBar.addWidget(QLabel("Color:"))
self.toolBar.addWidget(color_widget)
self.toolBar.addWidget(QLabel("Shape:"))
size_spin = QSpinBox(self.toolBar)
size_spin.setValue(20)
size_spin.valueChanged[int].connect(self.fourier.on_size_change)
shape_combo = QComboBox(self.toolBar)
shape_combo.activated[str].connect(self.fourier.on_shape_change)
shape_combo.addItems(brush_shapes)
self.toolBar.addWidget(shape_combo)
self.toolBar.addWidget(size_spin)
self.toolBar.addWidget(QLabel("Symmetry:"))
x_sym = QCheckBox(self.toolBar)
x_sym.toggled.connect(self.fourier.on_x_toggle)
opp_sym = QCheckBox(self.toolBar)
opp_sym.toggled.connect(self.fourier.on_opp_toggle)
self.toolBar.addWidget(QLabel("X"))
self.toolBar.addWidget(x_sym)
y_sym = QCheckBox(self.toolBar)
y_sym.toggled.connect(self.fourier.on_y_toggle)
self.toolBar.addWidget(QLabel("Y"))
self.toolBar.addWidget(y_sym)
self.toolBar.addWidget(QLabel("Center"))
self.toolBar.addWidget(opp_sym)
示例7: addFilter
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import addItems [as 别名]
def addFilter(self):
""" Add Filter Label and Combo Box to the UI """
label = QLabel("Filter: ", self.toolbar)
self.toolbar.addWidget(label)
comboBox = QComboBox(self.toolbar)
comboBox.addItems(__filter_order__)
comboBox.activated.connect(self.setTransactionFilter)
index = [__transaction_filters__[filterText] for filterText in __filter_order__].index(self.table_view.filters)
comboBox.setCurrentIndex(index)
self.toolbar.addWidget(comboBox)
示例8: createEditor
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import addItems [as 别名]
def createEditor(self, parent, option, index):
current_column = GridManagerColumns.Columns[index.column()]
# Using a combobox to the planes.
if( current_column == GridManagerColumns.Plane ):
combo_plane = QComboBox( parent )
combo_plane.addItems( GridPlanes.Planes )
return combo_plane
else:
# The rest of the controls are fine with the standard control
return super(VoxelGridDelegate,self).createEditor(parent, option, index)
示例9: newCombo
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import addItems [as 别名]
def newCombo(self):
taskList = [u'--請選擇--', u'值班', u'救護勤務', u'備勤', u'待命服勤', u'水源查察', u'消防查察', u'宣導勤務', u'訓(演)練', u'專案勤務', u'南山救護站']
nComboBox = QComboBox()
nComboBox.addItems(taskList)
for i in xrange(len(taskList)):
if i == 0:
nComboBox.setItemData(i, QColor('#550000'), Qt.BackgroundColorRole)
nComboBox.setItemData(i, Qt.AlignCenter, Qt.TextAlignmentRole)
nComboBox.setStyleSheet("text-align: right; font: bold 13px;")
return nComboBox
示例10: __init__
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import addItems [as 别名]
class DateToolbarSection:
""" Represents the Date Toolbar Section """
def __init__(self, toolbar, panel):
""" Initialize the Date Toolbar Section """
self.toolbar = toolbar
self.panel = panel
def addDateSection(self):
""" Add Date Section """
self.dateLabel = QLabel("Month: ", self.toolbar)
self.toolbar.addWidget(self.dateLabel)
self.setupMonthComboBox()
self.setupYearComboBox()
def setupMonthComboBox(self):
""" Setup the month combo box """
self.monthComboBox = QComboBox(self.toolbar)
self.monthComboBox.addItems(["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"])
self.monthComboBox.activated.connect(self.setMonth)
self.monthComboBox.setCurrentIndex(self.getCategoryStatistics().month-1)
self.toolbar.addWidget(self.monthComboBox)
def setupYearComboBox(self):
""" Setup the year combo box """
self.yearComboBox = QComboBox(self.toolbar)
self.getTransactionYears()
self.yearComboBox.addItems([str(year) for year in self.transactionYears])
self.yearComboBox.activated.connect(self.setYear)
self.yearComboBox.setCurrentIndex(self.transactionYears.index(self.getCategoryStatistics().year))
self.toolbar.addWidget(self.yearComboBox)
def getTransactionYears(self):
""" Get the possible transacttion years """
self.transactionYearsSet = Transactions.getAllYears()
self.transactionYearsSet.add(self.getCategoryStatistics().year)
self.transactionYears = list(self.transactionYearsSet)
self.transactionYears.sort()
def setMonth(self, index):
""" Set the month """
categoryStatistics = self.getCategoryStatistics()
categoryStatistics.month = index+1
self.panel.updatePanel()
def setYear(self, index):
""" Set the year """
categoryStatistics = self.getCategoryStatistics()
categoryStatistics.year = int(self.yearComboBox.currentText())
self.panel.updatePanel()
def getCategoryStatistics(self):
""" Returns the Category Statistics """
return self.panel.categoryStatistics
示例11: CreateSamplesRow
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import addItems [as 别名]
class CreateSamplesRow():
def __init__(self):
self.plate = QLineEdit()
self.parents = QSpinBox()
self.samples = QSpinBox()
self.loadedBy = QComboBox()
self.parents.setMaximum(8)
self.parents.setValue(2)
self.samples.setMaximum(96)
self.samples.setValue(94)
self.loadedBy.addItems(['Column','Row'])
def getPlate(self): return self.plate.text()
def getParents(self): return self.parents.value()
def getSamples(self): return self.samples.value()
def getLoadedBy(self): return self.loadedBy.currentText()
示例12: ScenarioPage
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import addItems [as 别名]
class ScenarioPage(QWidget):
def __init__(self, parent=None):
super(ScenarioPage, self).__init__(parent)
reqflow_label = QLabel("Required Flow:")
self.reqflow_spinbox = QSpinBox()
maxflow_label = QLabel("Maximum Flow:")
self.maxflow_spinbox = QSpinBox()
type_label = QLabel("Vapor or Liquid?:")
self.type_combobox = QComboBox()
self.type_combobox.addItems(["Vapor", "Liquid"])
pdropinlet_label = QLabel("% Pressure Drop (Inlet)")
self.pdropinlet_spinbox = QSpinBox()
pdropoutlet_label = QLabel("% Pressure Drop (Outlet)")
self.pdropoutlet_spinbox = QSpinBox()
layout = QGridLayout()
layout.addWidget(reqflow_label, 0, 0)
layout.addWidget(self.reqflow_spinbox, 0, 1)
layout.addWidget(maxflow_label, 1, 0)
layout.addWidget(self.maxflow_spinbox, 1, 1)
layout.addWidget(type_label, 2, 0)
layout.addWidget(self.type_combobox, 2, 1)
layout.addWidget(pdropinlet_label, 3, 0)
layout.addWidget(self.pdropinlet_spinbox, 3, 1)
layout.addWidget(pdropoutlet_label, 4, 0)
layout.addWidget(self.pdropoutlet_spinbox, 4, 1)
self.setLayout(layout)
self.mapper = QDataWidgetMapper()
def setModel(self, proxy_model):
self.proxy_model = proxy_model
self.mapper.setModel(self.proxy_model.sourceModel())
self.mapper.addMapping(self.reqflow_spinbox, 2)
self.mapper.addMapping(self.maxflow_spinbox, 3)
self.mapper.addMapping(self.type_combobox, 4, "currentIndex")
self.mapper.addMapping(self.pdropinlet_spinbox, 5)
self.mapper.addMapping(self.pdropoutlet_spinbox, 6)
def setSelection(self, current):
current = self.proxy_model.mapToSource(current)
parent = current.parent()
self.mapper.setRootIndex(parent)
self.mapper.setCurrentModelIndex(current)
示例13: _fill_table
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import addItems [as 别名]
def _fill_table(self):
colors = ["yellow", "orange", "green", "red"]
dimensions = self._parser_result.get_dimensions()
row = 0
for dimension in dimensions:
dimension_name = QLabel(dimension[0])
dimension_name.setStyleSheet("background: %s" % colors[row % len(colors)])
self.table_widget.setCellWidget(row, 0, dimension_name)
choices_widget = QComboBox()
choices = dimension[1]
choices.insert(0, "No choice")
choices_widget.addItems(choices)
choices_widget.setStyleSheet("background: white")
choices_widget.setStyleSheet("border: none")
choices_widget.currentIndexChanged.connect(self.on_choice_change)
self.table_widget.setCellWidget(row, 1, choices_widget)
row += 1
示例14: DevicePage
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import addItems [as 别名]
class DevicePage(QWidget):
def __init__(self, node, parent=None):
super(DevicePage, self).__init__(parent)
name_label = QLabel("Name:")
self.name_lineedit = QLineEdit()
setpressure_label = QLabel("Set Pressure:")
#self.setpressure_spinbox = QDoubleSpinBox()
self.setpressure_spinbox = CustomDoubleSpinBox(node, parent, setpressure_label.text())
modelnum_label = QLabel("Model Number:")
#self.modelnum_lineedit = QLineEdit()
self.modelnum_lineedit = CustomLineEdit(node, parent, modelnum_label.text())
orient_label = QLabel("Orientation:")
self.orient_combobox = QComboBox()
self.orient_combobox.addItems(["Horizontal", "Vertical"])
layout = QGridLayout()
layout.addWidget(name_label, 0, 0)
layout.addWidget(self.name_lineedit, 0, 1)
layout.addWidget(setpressure_label, 1, 0)
layout.addWidget(self.setpressure_spinbox, 1, 1)
layout.addWidget(modelnum_label, 2, 0)
layout.addWidget(self.modelnum_lineedit, 2, 1)
layout.addWidget(orient_label, 3, 0)
layout.addWidget(self.orient_combobox, 3, 1)
self.setLayout(layout)
self.mapper = QDataWidgetMapper()
def setModel(self, proxy_model):
self.proxy_model = proxy_model
self.mapper.setModel(self.proxy_model.sourceModel())
self.mapper.addMapping(self.name_lineedit, 0)
self.mapper.addMapping(self.setpressure_spinbox, 2)
self.mapper.addMapping(self.modelnum_lineedit, 3)
self.mapper.addMapping(self.orient_combobox, 4, "currentIndex")
def setSelection(self, current):
current = self.proxy_model.mapToSource(current)
parent = current.parent()
self.mapper.setRootIndex(parent)
self.mapper.setCurrentModelIndex(current)
示例15: SimpleComboboxOption
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import addItems [as 别名]
class SimpleComboboxOption(SimpleOption):
def __init__(self, settingsName, labelText, defaultValue, checkable=False, *options):
self.options = options
super(SimpleComboboxOption,self).__init__(settingsName, labelText, defaultValue, checkable)
def editor(self, defaultValue):
#options = ('Uniform','Exponential','Normal','Log Normal')
options = self.options
self.combo = QComboBox()
self.combo.addItems(options)
self.combo.setCurrentIndex(int(QSettings().value(self.settingsName, defaultValue)))
self.combo.setToolTip('Default value: %s' % defaultValue)
#self.combo.setAlignment(Qt.AlignLeft|Qt.AlignTop)
self.layout().addWidget(self.combo)
def setEnabled(self, e):
self.combo.setEnabled(e)
def getValue(self):
return self.combo.currentIndex()
def getName(self):
return self.combo.currentText()