本文整理汇总了Python中AnyQt.QtGui.QStandardItem.setTextAlignment方法的典型用法代码示例。如果您正苦于以下问题:Python QStandardItem.setTextAlignment方法的具体用法?Python QStandardItem.setTextAlignment怎么用?Python QStandardItem.setTextAlignment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtGui.QStandardItem
的用法示例。
在下文中一共展示了QStandardItem.setTextAlignment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _sum_item
# 需要导入模块: from AnyQt.QtGui import QStandardItem [as 别名]
# 或者: from AnyQt.QtGui.QStandardItem import setTextAlignment [as 别名]
def _sum_item(value, border=""):
item = QStandardItem()
item.setData(value, Qt.DisplayRole)
item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)
item.setFlags(Qt.ItemIsEnabled)
item.setFont(bold_font)
item.setData(border, BorderRole)
item.setData(QColor(192, 192, 192), BorderColorRole)
return item
示例2: show_results
# 需要导入模块: from AnyQt.QtGui import QStandardItem [as 别名]
# 或者: from AnyQt.QtGui.QStandardItem import setTextAlignment [as 别名]
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)