本文整理汇总了Python中AnyQt.QtWidgets.QComboBox.setModel方法的典型用法代码示例。如果您正苦于以下问题:Python QComboBox.setModel方法的具体用法?Python QComboBox.setModel怎么用?Python QComboBox.setModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QComboBox
的用法示例。
在下文中一共展示了QComboBox.setModel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createEditor
# 需要导入模块: from AnyQt.QtWidgets import QComboBox [as 别名]
# 或者: from AnyQt.QtWidgets.QComboBox import setModel [as 别名]
def createEditor(self, parent, _QStyleOptionViewItem, index):
combo = QComboBox(parent)
attr = index.model()[index.row()][0]
combo.setModel(self._combo_continuous_model if attr.is_continuous else
self._combo_discrete_model if attr.is_discrete else
self._combo_string_model)
return combo
示例2: __init__
# 需要导入模块: from AnyQt.QtWidgets import QComboBox [as 别名]
# 或者: from AnyQt.QtWidgets.QComboBox import setModel [as 别名]
def __init__(self):
super().__init__()
# Diagram update is in progress
self._updating = False
# Input update is in progress
self._inputUpdate = False
# All input tables have the same domain.
self.samedomain = True
# Input datasets in the order they were 'connected'.
self.data = OrderedDict()
# Extracted input item sets in the order they were 'connected'
self.itemsets = OrderedDict()
# GUI
box = gui.vBox(self.controlArea, "Info")
self.info = gui.widgetLabel(box, "No data on input.\n")
self.identifiersBox = gui.radioButtonsInBox(
self.controlArea,
self,
"useidentifiers",
[],
box="Data Instance Identifiers",
callback=self._on_useidentifiersChanged,
)
self.useequalityButton = gui.appendRadioButton(self.identifiersBox, "Use instance equality")
self.useidentifiersButton = rb = gui.appendRadioButton(self.identifiersBox, "Use identifiers")
self.inputsBox = gui.indentedBox(self.identifiersBox, sep=gui.checkButtonOffsetHint(rb))
self.inputsBox.setEnabled(bool(self.useidentifiers))
for i in range(5):
box = gui.vBox(self.inputsBox, "Data set #%i" % (i + 1), addSpace=False)
box.setFlat(True)
model = itemmodels.VariableListModel(parent=self)
cb = QComboBox(minimumContentsLength=12, sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLengthWithIcon)
cb.setModel(model)
cb.activated[int].connect(self._on_inputAttrActivated)
box.setEnabled(False)
# Store the combo in the box for later use.
box.combo_box = cb
box.layout().addWidget(cb)
gui.rubber(self.controlArea)
box = gui.vBox(self.controlArea, "Output")
gui.checkBox(box, self, "output_duplicates", "Output duplicates", callback=lambda: self.commit())
gui.auto_commit(box, self, "autocommit", "Send Selection", "Send Automatically", box=False)
# Main area view
self.scene = QGraphicsScene()
self.view = QGraphicsView(self.scene)
self.view.setRenderHint(QPainter.Antialiasing)
self.view.setBackgroundRole(QPalette.Window)
self.view.setFrameStyle(QGraphicsView.StyledPanel)
self.mainArea.layout().addWidget(self.view)
self.vennwidget = VennDiagram()
self.vennwidget.resize(400, 400)
self.vennwidget.itemTextEdited.connect(self._on_itemTextEdited)
self.scene.selectionChanged.connect(self._on_selectionChanged)
self.scene.addItem(self.vennwidget)
self.resize(self.controlArea.sizeHint().width() + 550, max(self.controlArea.sizeHint().height(), 550))
self._queue = []
示例3: FeatureEditor
# 需要导入模块: from AnyQt.QtWidgets import QComboBox [as 别名]
# 或者: from AnyQt.QtWidgets.QComboBox import setModel [as 别名]
class FeatureEditor(QFrame):
FUNCTIONS = dict(chain([(key, val) for key, val in math.__dict__.items()
if not key.startswith("_")],
[(key, val) for key, val in builtins.__dict__.items()
if key in {"str", "float", "int", "len",
"abs", "max", "min"}]))
featureChanged = Signal()
featureEdited = Signal()
modifiedChanged = Signal(bool)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
layout = QFormLayout(
fieldGrowthPolicy=QFormLayout.ExpandingFieldsGrow
)
layout.setContentsMargins(0, 0, 0, 0)
self.nameedit = QLineEdit(
placeholderText="Name...",
sizePolicy=QSizePolicy(QSizePolicy.Minimum,
QSizePolicy.Fixed)
)
self.expressionedit = QLineEdit(
placeholderText="Expression..."
)
self.attrs_model = itemmodels.VariableListModel(
["Select Feature"], parent=self)
self.attributescb = QComboBox(
minimumContentsLength=16,
sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLengthWithIcon,
sizePolicy=QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
)
self.attributescb.setModel(self.attrs_model)
sorted_funcs = sorted(self.FUNCTIONS)
self.funcs_model = itemmodels.PyListModelTooltip()
self.funcs_model.setParent(self)
self.funcs_model[:] = chain(["Select Function"], sorted_funcs)
self.funcs_model.tooltips[:] = chain(
[''],
[self.FUNCTIONS[func].__doc__ for func in sorted_funcs])
self.functionscb = QComboBox(
minimumContentsLength=16,
sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLengthWithIcon,
sizePolicy=QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum))
self.functionscb.setModel(self.funcs_model)
hbox = QHBoxLayout()
hbox.addWidget(self.attributescb)
hbox.addWidget(self.functionscb)
layout.addRow(self.nameedit, self.expressionedit)
layout.addRow(self.tr(""), hbox)
self.setLayout(layout)
self.nameedit.editingFinished.connect(self._invalidate)
self.expressionedit.textChanged.connect(self._invalidate)
self.attributescb.currentIndexChanged.connect(self.on_attrs_changed)
self.functionscb.currentIndexChanged.connect(self.on_funcs_changed)
self._modified = False
def setModified(self, modified):
if not type(modified) is bool:
raise TypeError
if self._modified != modified:
self._modified = modified
self.modifiedChanged.emit(modified)
def modified(self):
return self._modified
modified = Property(bool, modified, setModified,
notify=modifiedChanged)
def setEditorData(self, data, domain):
self.nameedit.setText(data.name)
self.expressionedit.setText(data.expression)
self.setModified(False)
self.featureChanged.emit()
self.attrs_model[:] = ["Select Feature"]
if domain is not None and (domain or domain.metas):
self.attrs_model[:] += chain(domain.attributes,
domain.class_vars,
domain.metas)
def editorData(self):
return FeatureDescriptor(name=self.nameedit.text(),
expression=self.nameedit.text())
def _invalidate(self):
self.setModified(True)
self.featureEdited.emit()
self.featureChanged.emit()
#.........这里部分代码省略.........
示例4: createEditor
# 需要导入模块: from AnyQt.QtWidgets import QComboBox [as 别名]
# 或者: from AnyQt.QtWidgets.QComboBox import setModel [as 别名]
def createEditor(self, parent, option, index):
cb = QComboBox(parent)
cb.setModel(self.sortingModel)
cb.showPopup()
return cb
示例5: OWSql
# 需要导入模块: from AnyQt.QtWidgets import QComboBox [as 别名]
# 或者: from AnyQt.QtWidgets.QComboBox import setModel [as 别名]
class OWSql(OWWidget):
name = "SQL Table"
id = "orange.widgets.data.sql"
description = "Load data set from SQL."
icon = "icons/SQLTable.svg"
priority = 30
category = "Data"
keywords = ["data", "file", "load", "read", "SQL"]
class Outputs:
data = Output("Data", Table, doc="Attribute-valued data set read from the input file.")
settings_version = 2
want_main_area = False
resizing_enabled = False
host = Setting(None)
port = Setting(None)
database = Setting(None)
schema = Setting(None)
username = ""
password = ""
table = Setting(None)
sql = Setting("")
guess_values = Setting(True)
download = Setting(False)
materialize = Setting(False)
materialize_table_name = Setting("")
class Information(OWWidget.Information):
data_sampled = Msg("Data description was generated from a sample.")
class Error(OWWidget.Error):
connection = Msg("{}")
no_backends = Msg("Please install a backend to use this widget")
missing_extension = Msg("Database is missing extension{}: {}")
def __init__(self):
super().__init__()
self.backend = None
self.data_desc_table = None
self.database_desc = None
vbox = gui.vBox(self.controlArea, "Server", addSpace=True)
box = gui.vBox(vbox)
self.backends = BackendModel(Backend.available_backends())
self.backendcombo = QComboBox(box)
if len(self.backends):
self.backendcombo.setModel(self.backends)
else:
self.Error.no_backends()
box.setEnabled(False)
box.layout().addWidget(self.backendcombo)
self.servertext = QLineEdit(box)
self.servertext.setPlaceholderText('Server')
self.servertext.setToolTip('Server')
self.servertext.editingFinished.connect(self._load_credentials)
if self.host:
self.servertext.setText(self.host if not self.port else
'{}:{}'.format(self.host, self.port))
box.layout().addWidget(self.servertext)
self.databasetext = QLineEdit(box)
self.databasetext.setPlaceholderText('Database[/Schema]')
self.databasetext.setToolTip('Database or optionally Database/Schema')
if self.database:
self.databasetext.setText(
self.database if not self.schema else
'{}/{}'.format(self.database, self.schema))
box.layout().addWidget(self.databasetext)
self.usernametext = QLineEdit(box)
self.usernametext.setPlaceholderText('Username')
self.usernametext.setToolTip('Username')
box.layout().addWidget(self.usernametext)
self.passwordtext = QLineEdit(box)
self.passwordtext.setPlaceholderText('Password')
self.passwordtext.setToolTip('Password')
self.passwordtext.setEchoMode(QLineEdit.Password)
box.layout().addWidget(self.passwordtext)
self._load_credentials()
self.tables = TableModel()
tables = gui.hBox(box)
self.tablecombo = QComboBox(
minimumContentsLength=35,
sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLength
)
self.tablecombo.setModel(self.tables)
self.tablecombo.setToolTip('table')
tables.layout().addWidget(self.tablecombo)
self.connect()
#.........这里部分代码省略.........
示例6: createEditor
# 需要导入模块: from AnyQt.QtWidgets import QComboBox [as 别名]
# 或者: from AnyQt.QtWidgets.QComboBox import setModel [as 别名]
def createEditor(self, parent, _QStyleOptionViewItem, index):
combo = QComboBox(parent)
combo.setModel(self._combo_model)
return combo