本文整理汇总了Python中AnyQt.QtGui.QStandardItemModel.setRowCount方法的典型用法代码示例。如果您正苦于以下问题:Python QStandardItemModel.setRowCount方法的具体用法?Python QStandardItemModel.setRowCount怎么用?Python QStandardItemModel.setRowCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtGui.QStandardItemModel
的用法示例。
在下文中一共展示了QStandardItemModel.setRowCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OWConfusionMatrix
# 需要导入模块: from AnyQt.QtGui import QStandardItemModel [as 别名]
# 或者: from AnyQt.QtGui.QStandardItemModel import setRowCount [as 别名]
#.........这里部分代码省略.........
item.setFlags(Qt.NoItemFlags)
self.tableview.setItemDelegateForColumn(0, gui.VerticalItemDelegate())
self._set_item(2, 0, item)
self.tableview.setSpan(0, 2, 1, nclasses)
self.tableview.setSpan(2, 0, nclasses, 1)
font = self.tablemodel.invisibleRootItem().font()
bold_font = QFont(font)
bold_font.setBold(True)
for i in (0, 1):
for j in (0, 1):
item = self._item(i, j)
item.setFlags(Qt.NoItemFlags)
self._set_item(i, j, item)
for p, label in enumerate(self.headers):
for i, j in ((1, p + 2), (p + 2, 1)):
item = self._item(i, j)
item.setData(label, Qt.DisplayRole)
item.setFont(bold_font)
item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)
item.setFlags(Qt.ItemIsEnabled)
if p < len(self.headers) - 1:
item.setData("br"[j == 1], BorderRole)
item.setData(QColor(192, 192, 192), BorderColorRole)
self._set_item(i, j, item)
hor_header = self.tableview.horizontalHeader()
if len(' '.join(self.headers)) < 120:
hor_header.setSectionResizeMode(QHeaderView.ResizeToContents)
else:
hor_header.setDefaultSectionSize(60)
self.tablemodel.setRowCount(nclasses + 3)
self.tablemodel.setColumnCount(nclasses + 3)
@Inputs.evaluation_results
def set_results(self, results):
"""Set the input results."""
prev_sel_learner = self.selected_learner.copy()
self.clear()
self.warning()
self.closeContext()
data = None
if results is not None and results.data is not None:
data = results.data[results.row_indices]
if data is not None and not data.domain.has_discrete_class:
self.Error.no_regression()
data = results = None
else:
self.Error.no_regression.clear()
nan_values = False
if results is not None:
assert isinstance(results, Orange.evaluation.Results)
if np.any(np.isnan(results.actual)) or \
np.any(np.isnan(results.predicted)):
# Error out here (could filter them out with a warning
# instead).
nan_values = True
results = data = None
if nan_values:
示例2: OWKMeans
# 需要导入模块: from AnyQt.QtGui import QStandardItemModel [as 别名]
# 或者: from AnyQt.QtGui.QStandardItemModel import setRowCount [as 别名]
#.........这里部分代码省略.........
init=['random', 'k-means++'][self.smart_init],
n_init=self.n_init,
max_iter=self.max_iterations)(self.data)
self.send_data()
def run(self):
self.clear_messages()
if not self.data:
return
if self.optimize_k:
self.run_optimization()
else:
self.cluster()
def commit(self):
self.run()
def show_results(self):
minimize = self.SCORING_METHODS[self.scoring][2]
k_scores = [(k, self.SCORING_METHODS[self.scoring][1](run)) for
k, run in self.optimization_runs]
scores = list(zip(*k_scores))[1]
if minimize:
best_score, worst_score = min(scores), max(scores)
else:
best_score, worst_score = max(scores), min(scores)
best_run = scores.index(best_score)
score_span = (best_score - worst_score) or 1
max_score = max(scores)
nplaces = min(5, np.floor(abs(math.log(max(max_score, 1e-10)))) + 2)
fmt = "{{:.{}f}}".format(int(nplaces))
model = self.table_model
model.setRowCount(len(k_scores))
for i, (k, score) in enumerate(k_scores):
item = model.item(i, 0)
if item is None:
item = QStandardItem()
item.setData(k, Qt.DisplayRole)
item.setTextAlignment(Qt.AlignCenter)
model.setItem(i, 0, item)
item = model.item(i, 1)
if item is None:
item = QStandardItem()
item.setData(fmt.format(score) if not np.isnan(score) else 'out-of-memory error',
Qt.DisplayRole)
bar_ratio = 0.95 * (score - worst_score) / score_span
item.setData(bar_ratio, gui.TableBarItem.BarRole)
model.setItem(i, 1, item)
self.table_view.resizeRowsToContents()
self.table_view.selectRow(best_run)
self.table_view.show()
if minimize:
self.table_box.setTitle("Scoring (smaller is better)")
else:
self.table_box.setTitle("Scoring (bigger is better)")
QTimer.singleShot(0, self.adjustSize)
def update(self):
self.hide_show_opt_results()
self.run()
def selected_row(self):
indices = self.table_view.selectedIndexes()
rows = {ind.row() for ind in indices}