本文整理汇总了Python中AnyQt.QtGui.QFont.setWeight方法的典型用法代码示例。如果您正苦于以下问题:Python QFont.setWeight方法的具体用法?Python QFont.setWeight怎么用?Python QFont.setWeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtGui.QFont
的用法示例。
在下文中一共展示了QFont.setWeight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_layout
# 需要导入模块: from AnyQt.QtGui import QFont [as 别名]
# 或者: from AnyQt.QtGui.QFont import setWeight [as 别名]
def _create_layout(self):
box = gui.widgetBox(self.mainArea, 'RMSE')
BOLD_FONT = QFont()
BOLD_FONT.setWeight(QFont.DemiBold)
widget = self
class HereTableWidget(QTableWidget):
def __init__(self, parent):
super().__init__(parent)
parent.layout().addWidget(self)
self.setHorizontalScrollMode(self.ScrollPerPixel)
self.setVerticalScrollMode(self.ScrollPerPixel)
def update_table(self, fusers, relations):
self.clear()
self.setRowCount(0)
self.setColumnCount(len(fusers))
self.setHorizontalHeaderLabels([fuser[0].name for fuser in fusers.values()])
for id, relation in relations.items():
row = self.rowCount()
self.insertRow(row)
if not np.ma.is_masked(relation.data):
widget.warning(id, 'Relation "{}" has no missing values '
'(mask)'.format(relation_str(relation)))
rmses = []
for fuser in fusers.values():
rep_rmse = []
for fuserfit in fuser:
if not fuserfit.can_complete(relation):
break
completion = fuserfit.complete(relation)
rep_rmse.append(RMSE(relation.data, completion))
rmses.append(np.mean(rep_rmse) if rep_rmse else None)
try: min_rmse = min(e for e in rmses if e is not None)
except ValueError: continue # No fuser could complete this relation
for col, rmse in enumerate(rmses):
if rmse is None: continue
item = QTableWidgetItem('{:.05f}'.format(rmse))
item.setFlags(Qt.ItemIsEnabled)
if rmse == min_rmse and len(rmses) > 1:
item.setFont(BOLD_FONT)
self.setItem(row, col, item)
self.setVerticalHeaderLabels([relation_str(i) for i in relations.values()])
self.resizeColumnsToContents()
self.resizeRowsToContents()
self.table = HereTableWidget(box)
示例2: update_font
# 需要导入模块: from AnyQt.QtGui import QFont [as 别名]
# 或者: from AnyQt.QtGui.QFont import setWeight [as 别名]
def update_font(basefont, weight=None, italic=None, underline=None,
pixelSize=None, pointSize=None):
"""
Return a copy of `basefont` :class:`QFont` with updated properties.
"""
font = QFont(basefont)
if weight is not None:
font.setWeight(weight)
if italic is not None:
font.setItalic(italic)
if underline is not None:
font.setUnderline(underline)
if pixelSize is not None:
font.setPixelSize(pixelSize)
if pointSize is not None:
font.setPointSize(pointSize)
return font