本文整理汇总了Python中AnyQt.QtGui.QStandardItem.setText方法的典型用法代码示例。如果您正苦于以下问题:Python QStandardItem.setText方法的具体用法?Python QStandardItem.setText怎么用?Python QStandardItem.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtGui.QStandardItem
的用法示例。
在下文中一共展示了QStandardItem.setText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _cat_desc_to_std_item
# 需要导入模块: from AnyQt.QtGui import QStandardItem [as 别名]
# 或者: from AnyQt.QtGui.QStandardItem import setText [as 别名]
def _cat_desc_to_std_item(self, desc):
"""
Create a QStandardItem for the category description.
"""
item = QStandardItem()
item.setText(desc.name)
if desc.icon:
icon = desc.icon
else:
icon = "icons/default-category.svg"
icon = icon_loader.from_description(desc).get(icon)
item.setIcon(icon)
if desc.background:
background = desc.background
else:
background = DEFAULT_COLOR
background = NAMED_COLORS.get(background, background)
brush = QBrush(QColor(background))
item.setData(brush, self.BACKGROUND_ROLE)
tooltip = desc.description if desc.description else desc.name
item.setToolTip(tooltip)
item.setFlags(Qt.ItemIsEnabled)
item.setData(desc, self.CATEGORY_DESC_ROLE)
return item
示例2: _widget_desc_to_std_item
# 需要导入模块: from AnyQt.QtGui import QStandardItem [as 别名]
# 或者: from AnyQt.QtGui.QStandardItem import setText [as 别名]
def _widget_desc_to_std_item(self, desc, category):
"""
Create a QStandardItem for the widget description.
"""
item = QStandardItem(desc.name)
item.setText(desc.name)
if desc.icon:
icon = desc.icon
else:
icon = "icons/default-widget.svg"
icon = icon_loader.from_description(desc).get(icon)
item.setIcon(icon)
# This should be inherited from the category.
background = None
if desc.background:
background = desc.background
elif category.background:
background = category.background
else:
background = DEFAULT_COLOR
if background is not None:
background = NAMED_COLORS.get(background, background)
brush = QBrush(QColor(background))
item.setData(brush, self.BACKGROUND_ROLE)
tooltip = tooltip_helper(desc)
style = "ul { margin-top: 1px; margin-bottom: 1px; }"
tooltip = TOOLTIP_TEMPLATE.format(style=style, tooltip=tooltip)
item.setToolTip(tooltip)
item.setWhatsThis(whats_this_helper(desc))
item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
item.setData(desc, self.WIDGET_DESC_ROLE)
# Create the action for the widget_item
action = self.create_action_for_item(item)
item.setData(action, self.WIDGET_ACTION_ROLE)
return item
示例3: _update_stats_model
# 需要导入模块: from AnyQt.QtGui import QStandardItem [as 别名]
# 或者: from AnyQt.QtGui.QStandardItem import setText [as 别名]
def _update_stats_model(self):
# Update the results_model with up to date scores.
# Note: The target class specific scores (if requested) are
# computed as needed in this method.
model = self.view.model()
# clear the table model, but preserving the header labels
for r in reversed(range(model.rowCount())):
model.takeRow(r)
target_index = None
if self.data is not None:
class_var = self.data.domain.class_var
if self.data.domain.has_discrete_class and \
self.class_selection != self.TARGET_AVERAGE:
target_index = class_var.values.index(self.class_selection)
else:
class_var = None
errors = []
has_missing_scores = False
for key, slot in self.learners.items():
name = learner_name(slot.learner)
head = QStandardItem(name)
head.setData(key, Qt.UserRole)
if isinstance(slot.results, Try.Fail):
head.setToolTip(str(slot.results.exception))
head.setText("{} (error)".format(name))
head.setForeground(QtGui.QBrush(Qt.red))
errors.append("{name} failed with error:\n"
"{exc.__class__.__name__}: {exc!s}"
.format(name=name, exc=slot.results.exception))
row = [head]
if class_var is not None and class_var.is_discrete and \
target_index is not None:
if slot.results is not None and slot.results.success:
ovr_results = results_one_vs_rest(
slot.results.value, target_index)
# Cell variable is used immediatelly, it's not stored
# pylint: disable=cell-var-from-loop
stats = [Try(scorer_caller(scorer, ovr_results))
for scorer in self.scorers]
else:
stats = None
else:
stats = slot.stats
if stats is not None:
for stat in stats:
item = QStandardItem()
if stat.success:
item.setText("{:.3f}".format(stat.value[0]))
else:
item.setToolTip(str(stat.exception))
has_missing_scores = True
row.append(item)
model.appendRow(row)
self.error("\n".join(errors), shown=bool(errors))
self.Warning.scores_not_computed(shown=has_missing_scores)
示例4: __setupUi
# 需要导入模块: from AnyQt.QtGui import QStandardItem [as 别名]
# 或者: from AnyQt.QtGui.QStandardItem import setText [as 别名]
#.........这里部分代码省略.........
box = QWidget()
layout = QVBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
combo = QComboBox()
combo.addItems([self.tr("Critical"),
self.tr("Error"),
self.tr("Warn"),
self.tr("Info"),
self.tr("Debug")])
self.bind(combo, "currentIndex", "logging/level")
layout.addWidget(combo)
box.setLayout(layout)
form.addRow(self.tr("Logging"), box)
box = QWidget()
layout = QVBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
cb1 = QCheckBox(self.tr("Open in external browser"),
objectName="open-in-external-browser")
self.bind(cb1, "checked", "help/open-in-external-browser")
layout.addWidget(cb1)
box.setLayout(layout)
form.addRow(self.tr("Help window"), box)
tab.setLayout(form)
# Categories Tab
tab = QWidget()
layout = QVBoxLayout()
view = QListView(
editTriggers=QListView.NoEditTriggers
)
from .. import registry
reg = registry.global_registry()
model = QStandardItemModel()
settings = QSettings()
for cat in reg.categories():
item = QStandardItem()
item.setText(cat.name)
item.setCheckable(True)
visible, _ = category_state(cat, settings)
item.setCheckState(Qt.Checked if visible else Qt.Unchecked)
model.appendRow([item])
view.setModel(model)
layout.addWidget(view)
tab.setLayout(layout)
model.itemChanged.connect(
lambda item:
save_category_state(
reg.category(str(item.text())),
_State(item.checkState() == Qt.Checked, -1),
settings
)
)
self.addTab(tab, "Categories")
# Add-ons Tab
tab = QWidget()
self.addTab(tab, self.tr("Add-ons"),
toolTip="Settings related to add-on installation")
form = QFormLayout()
conda = QWidget(self, objectName="conda-group")
conda.setLayout(QVBoxLayout())
conda.layout().setContentsMargins(0, 0, 0, 0)
cb_conda_install = QCheckBox(self.tr("Install add-ons with conda"), self,
objectName="allow-conda-experimental")
self.bind(cb_conda_install, "checked", "add-ons/allow-conda-experimental")
conda.layout().addWidget(cb_conda_install)
form.addRow(self.tr("Conda"), conda)
form.addRow(self.tr("Pip"), QLabel("Pip install arguments:"))
line_edit_pip = QLineEdit()
self.bind(line_edit_pip, "text", "add-ons/pip-install-arguments")
form.addRow("", line_edit_pip)
tab.setLayout(form)
# Network Tab
tab = QWidget()
self.addTab(tab, self.tr("Network"),
toolTip="Settings related to networking")
form = QFormLayout()
line_edit_http_proxy = QLineEdit()
self.bind(line_edit_http_proxy, "text", "network/http-proxy")
form.addRow("HTTP proxy:", line_edit_http_proxy)
line_edit_https_proxy = QLineEdit()
self.bind(line_edit_https_proxy, "text", "network/https-proxy")
form.addRow("HTTPS proxy:", line_edit_https_proxy)
tab.setLayout(form)
if self.__macUnified:
# Need some sensible size otherwise mac unified toolbar 'takes'
# the space that should be used for layout of the contents
self.adjustSize()