本文整理汇总了Python中AnyQt.QtGui.QFont.setPixelSize方法的典型用法代码示例。如果您正苦于以下问题:Python QFont.setPixelSize方法的具体用法?Python QFont.setPixelSize怎么用?Python QFont.setPixelSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtGui.QFont
的用法示例。
在下文中一共展示了QFont.setPixelSize方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: splash_screen
# 需要导入模块: from AnyQt.QtGui import QFont [as 别名]
# 或者: from AnyQt.QtGui.QFont import setPixelSize [as 别名]
def splash_screen():
"""
"""
pm = QPixmap(
pkg_resources.resource_filename(
__name__, "icons/orange-splash-screen.png")
)
version = QCoreApplication.applicationVersion()
size = 21 if len(version) < 5 else 16
font = QFont("Helvetica")
font.setPixelSize(size)
font.setBold(True)
font.setItalic(True)
font.setLetterSpacing(QFont.AbsoluteSpacing, 2)
metrics = QFontMetrics(font)
br = metrics.boundingRect(version).adjusted(-5, 0, 5, 0)
br.moveCenter(QPoint(436, 224))
p = QPainter(pm)
p.setRenderHint(QPainter.Antialiasing)
p.setRenderHint(QPainter.TextAntialiasing)
p.setFont(font)
p.setPen(QColor("#231F20"))
p.drawText(br, Qt.AlignCenter, version)
p.end()
return pm, QRect(88, 193, 200, 20)
示例2: __init__
# 需要导入模块: from AnyQt.QtGui import QFont [as 别名]
# 或者: from AnyQt.QtGui.QFont import setPixelSize [as 别名]
def __init__(self):
super().__init__()
self.results = None
self.classifier_names = []
self.colors = []
self._curve_data = {}
box = gui.vBox(self.controlArea, "Plot")
tbox = gui.vBox(box, "Target Class")
tbox.setFlat(True)
self.target_cb = gui.comboBox(
tbox, self, "target_index", callback=self._on_target_changed,
contentsLength=8)
cbox = gui.vBox(box, "Classifiers")
cbox.setFlat(True)
self.classifiers_list_box = gui.listBox(
cbox, self, "selected_classifiers", "classifier_names",
selectionMode=QtWidgets.QListView.MultiSelection,
callback=self._on_classifiers_changed)
gui.checkBox(box, self, "display_convex_hull",
"Show lift convex hull", callback=self._replot)
self.plotview = pg.GraphicsView(background="w")
self.plotview.setFrameStyle(QtWidgets.QFrame.StyledPanel)
self.plot = pg.PlotItem(enableMenu=False)
self.plot.setMouseEnabled(False, False)
self.plot.hideButtons()
pen = QPen(self.palette().color(QPalette.Text))
tickfont = QFont(self.font())
tickfont.setPixelSize(max(int(tickfont.pixelSize() * 2 // 3), 11))
axis = self.plot.getAxis("bottom")
axis.setTickFont(tickfont)
axis.setPen(pen)
axis.setLabel("P Rate")
axis = self.plot.getAxis("left")
axis.setTickFont(tickfont)
axis.setPen(pen)
axis.setLabel("TP Rate")
self.plot.showGrid(True, True, alpha=0.1)
self.plot.setRange(xRange=(0.0, 1.0), yRange=(0.0, 1.0), padding=0.05)
self.plotview.setCentralItem(self.plot)
self.mainArea.layout().addWidget(self.plotview)
示例3: font_from_dict
# 需要导入模块: from AnyQt.QtGui import QFont [as 别名]
# 或者: from AnyQt.QtGui.QFont import setPixelSize [as 别名]
def font_from_dict(font_dict, font=None):
if font is None:
font = QFont()
else:
font = QFont(font)
if "family" in font_dict:
font.setFamily(font_dict["family"])
if "size" in font_dict:
font.setPixelSize(font_dict["size"])
return font
示例4: splash_screen
# 需要导入模块: from AnyQt.QtGui import QFont [as 别名]
# 或者: from AnyQt.QtGui.QFont import setPixelSize [as 别名]
def splash_screen():
# type: () -> Tuple[QPixmap, QRect]
"""
Return a splash screen pixmap and an text area within it.
The text area is used for displaying text messages during application
startup.
The default implementation returns a bland rectangle splash screen.
Returns
-------
t : Tuple[QPixmap, QRect]
A QPixmap and a rect area within it.
"""
path = pkg_resources.resource_filename(
__name__, "icons/orange-canvas-core-splash.svg")
pm = QPixmap(path)
version = QCoreApplication.applicationVersion()
if version:
version_parsed = LooseVersion(version)
version_comp = version_parsed.version
version = ".".join(map(str, version_comp[:2]))
size = 21 if len(version) < 5 else 16
font = QFont()
font.setPixelSize(size)
font.setBold(True)
font.setItalic(True)
font.setLetterSpacing(QFont.AbsoluteSpacing, 2)
metrics = QFontMetrics(font)
br = metrics.boundingRect(version).adjusted(-5, 0, 5, 0)
br.moveBottomRight(QPoint(pm.width() - 15, pm.height() - 15))
p = QPainter(pm)
p.setRenderHint(QPainter.Antialiasing)
p.setRenderHint(QPainter.TextAntialiasing)
p.setFont(font)
p.setPen(QColor("#231F20"))
p.drawText(br, Qt.AlignCenter, version)
p.end()
textarea = QRect(15, 15, 170, 20)
return pm, textarea
示例5: update_font
# 需要导入模块: from AnyQt.QtGui import QFont [as 别名]
# 或者: from AnyQt.QtGui.QFont import setPixelSize [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
示例6: __init__
# 需要导入模块: from AnyQt.QtGui import QFont [as 别名]
# 或者: from AnyQt.QtGui.QFont import setPixelSize [as 别名]
def __init__(self):
super().__init__()
self.results = None
self.classifier_names = []
self.perf_line = None
self.colors = []
self._curve_data = {}
self._plot_curves = {}
self._rocch = None
self._perf_line = None
box = gui.vBox(self.controlArea, "Plot")
tbox = gui.vBox(box, "Target Class")
tbox.setFlat(True)
self.target_cb = gui.comboBox(
tbox, self, "target_index", callback=self._on_target_changed,
contentsLength=8)
cbox = gui.vBox(box, "Classifiers")
cbox.setFlat(True)
self.classifiers_list_box = gui.listBox(
cbox, self, "selected_classifiers", "classifier_names",
selectionMode=QListView.MultiSelection,
callback=self._on_classifiers_changed)
abox = gui.vBox(box, "Combine ROC Curves From Folds")
abox.setFlat(True)
gui.comboBox(abox, self, "roc_averaging",
items=["Merge Predictions from Folds", "Mean TP Rate",
"Mean TP and FP at Threshold", "Show Individual Curves"],
callback=self._replot)
hbox = gui.vBox(box, "ROC Convex Hull")
hbox.setFlat(True)
gui.checkBox(hbox, self, "display_convex_curve",
"Show convex ROC curves", callback=self._replot)
gui.checkBox(hbox, self, "display_convex_hull",
"Show ROC convex hull", callback=self._replot)
box = gui.vBox(self.controlArea, "Analysis")
gui.checkBox(box, self, "display_def_threshold",
"Default threshold (0.5) point",
callback=self._on_display_def_threshold_changed)
gui.checkBox(box, self, "display_perf_line", "Show performance line",
callback=self._on_display_perf_line_changed)
grid = QGridLayout()
ibox = gui.indentedBox(box, orientation=grid)
sp = gui.spin(box, self, "fp_cost", 1, 1000, 10,
callback=self._on_display_perf_line_changed)
grid.addWidget(QLabel("FP Cost:"), 0, 0)
grid.addWidget(sp, 0, 1)
sp = gui.spin(box, self, "fn_cost", 1, 1000, 10,
callback=self._on_display_perf_line_changed)
grid.addWidget(QLabel("FN Cost:"))
grid.addWidget(sp, 1, 1)
sp = gui.spin(box, self, "target_prior", 1, 99,
callback=self._on_display_perf_line_changed)
sp.setSuffix("%")
sp.addAction(QAction("Auto", sp))
grid.addWidget(QLabel("Prior target class probability:"))
grid.addWidget(sp, 2, 1)
self.plotview = pg.GraphicsView(background="w")
self.plotview.setFrameStyle(QFrame.StyledPanel)
self.plot = pg.PlotItem(enableMenu=False)
self.plot.setMouseEnabled(False, False)
self.plot.hideButtons()
pen = QPen(self.palette().color(QPalette.Text))
tickfont = QFont(self.font())
tickfont.setPixelSize(max(int(tickfont.pixelSize() * 2 // 3), 11))
axis = self.plot.getAxis("bottom")
axis.setTickFont(tickfont)
axis.setPen(pen)
axis.setLabel("FP Rate (1-Specificity)")
axis = self.plot.getAxis("left")
axis.setTickFont(tickfont)
axis.setPen(pen)
axis.setLabel("TP Rate (Sensitivity)")
self.plot.showGrid(True, True, alpha=0.1)
self.plot.setRange(xRange=(0.0, 1.0), yRange=(0.0, 1.0), padding=0.05)
self.plotview.setCentralItem(self.plot)
self.mainArea.layout().addWidget(self.plotview)
示例7: _init_ui
# 需要导入模块: from AnyQt.QtGui import QFont [as 别名]
# 或者: from AnyQt.QtGui.QFont import setPixelSize [as 别名]
#.........这里部分代码省略.........
self.toolActions = QActionGroup(self)
self.toolActions.setExclusive(True)
self.toolButtons = []
for i, (name, tooltip, tool, icon) in enumerate(self.TOOLS):
action = QAction(
name, self,
toolTip=tooltip,
checkable=tool.checkable,
icon=QIcon(icon),
)
action.triggered.connect(partial(self.set_current_tool, tool))
button = QToolButton(
iconSize=QSize(24, 24),
toolButtonStyle=Qt.ToolButtonTextUnderIcon,
sizePolicy=QSizePolicy(QSizePolicy.MinimumExpanding,
QSizePolicy.Fixed)
)
button.setDefaultAction(action)
self.toolButtons.append((button, tool))
toolsBox.layout().addWidget(button, i / 3, i % 3)
self.toolActions.addAction(action)
for column in range(3):
toolsBox.layout().setColumnMinimumWidth(column, 10)
toolsBox.layout().setColumnStretch(column, 1)
undo = self.undo_stack.createUndoAction(self)
redo = self.undo_stack.createRedoAction(self)
undo.setShortcut(QKeySequence.Undo)
redo.setShortcut(QKeySequence.Redo)
self.addActions([undo, redo])
self.undo_stack.indexChanged.connect(lambda _: self.invalidate())
gui.separator(tBox)
indBox = gui.indentedBox(tBox, sep=8)
form = QFormLayout(
formAlignment=Qt.AlignLeft,
labelAlignment=Qt.AlignLeft,
fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow
)
indBox.layout().addLayout(form)
slider = gui.hSlider(
indBox, self, "brushRadius", minValue=1, maxValue=100,
createLabel=False
)
form.addRow("Radius:", slider)
slider = gui.hSlider(
indBox, self, "density", None, minValue=1, maxValue=100,
createLabel=False
)
form.addRow("Intensity:", slider)
self.btResetToInput = gui.button(
tBox, self, "Reset to Input Data", self.reset_to_input)
self.btResetToInput.setDisabled(True)
gui.rubber(self.controlArea)
gui.auto_commit(self.left_side, self, "autocommit",
"Send")
# main area GUI
viewbox = PaintViewBox(enableMouse=False)
self.plotview = pg.PlotWidget(background="w", viewBox=viewbox)
self.plotview.sizeHint = lambda: QSize(200, 100) # Minimum size for 1-d painting
self.plot = self.plotview.getPlotItem()
axis_color = self.palette().color(QPalette.Text)
axis_pen = QPen(axis_color)
tickfont = QFont(self.font())
tickfont.setPixelSize(max(int(tickfont.pixelSize() * 2 // 3), 11))
axis = self.plot.getAxis("bottom")
axis.setLabel(self.attr1)
axis.setPen(axis_pen)
axis.setTickFont(tickfont)
axis = self.plot.getAxis("left")
axis.setLabel(self.attr2)
axis.setPen(axis_pen)
axis.setTickFont(tickfont)
if not self.hasAttr2:
self.plot.hideAxis('left')
self.plot.hideButtons()
self.plot.setXRange(0, 1, padding=0.01)
self.mainArea.layout().addWidget(self.plotview)
# enable brush tool
self.toolActions.actions()[0].setChecked(True)
self.set_current_tool(self.TOOLS[0][2])
self.set_dimensions()
示例8: add_main_layout
# 需要导入模块: from AnyQt.QtGui import QFont [as 别名]
# 或者: from AnyQt.QtGui.QFont import setPixelSize [as 别名]
def add_main_layout(self):
self.data = None
self.preprocessors = None
self.learner = None
self.scatterplot_item = None
self.plot_item = None
self.x_label = 'x'
self.y_label = 'y'
box = gui.vBox(self.controlArea, "Variables")
self.x_var_model = itemmodels.VariableListModel()
self.comboBoxAttributesX = gui.comboBox(
box, self, value='x_var_index', label="Input: ",
orientation=Qt.Horizontal, callback=self.apply, contentsLength=12)
self.comboBoxAttributesX.setSizePolicy(
QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)
self.comboBoxAttributesX.setModel(self.x_var_model)
gui.doubleSpin(
gui.indentedBox(box),
self, "polynomialexpansion", 0, 10,
label="Polynomial expansion:", callback=self.apply)
gui.separator(box, height=8)
self.y_var_model = itemmodels.VariableListModel()
self.comboBoxAttributesY = gui.comboBox(
box, self, value="y_var_index", label="Target: ",
orientation=Qt.Horizontal, callback=self.apply, contentsLength=12)
self.comboBoxAttributesY.setSizePolicy(
QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)
self.comboBoxAttributesY.setModel(self.y_var_model)
gui.rubber(self.controlArea)
# main area GUI
self.plotview = pg.PlotWidget(background="w")
self.plot = self.plotview.getPlotItem()
axis_color = self.palette().color(QPalette.Text)
axis_pen = QPen(axis_color)
tickfont = QFont(self.font())
tickfont.setPixelSize(max(int(tickfont.pixelSize() * 2 // 3), 11))
axis = self.plot.getAxis("bottom")
axis.setLabel(self.x_label)
axis.setPen(axis_pen)
axis.setTickFont(tickfont)
axis = self.plot.getAxis("left")
axis.setLabel(self.y_label)
axis.setPen(axis_pen)
axis.setTickFont(tickfont)
self.plot.setRange(xRange=(0.0, 1.0), yRange=(0.0, 1.0),
disableAutoRange=True)
self.mainArea.layout().addWidget(self.plotview)
示例9: add_main_layout
# 需要导入模块: from AnyQt.QtGui import QFont [as 别名]
# 或者: from AnyQt.QtGui.QFont import setPixelSize [as 别名]
def add_main_layout(self):
self.data = None
self.learner = None
self.scatterplot_item = None
self.plot_item = None
self.x_label = 'x'
self.y_label = 'y'
self.rmse = ""
self.mae = ""
self.regressor_name = self.default_learner_name
# info box
info_box = gui.vBox(self.controlArea, "Info")
self.regressor_label = gui.label(
widget=info_box, master=self,
label="Regressor: %(regressor_name).30s")
gui.label(widget=info_box, master=self,
label="Mean absolute error: %(mae).6s")
gui.label(widget=info_box, master=self,
label="Root mean square error: %(rmse).6s")
box = gui.vBox(self.controlArea, "Variables")
self.x_var_model = itemmodels.VariableListModel()
self.comboBoxAttributesX = gui.comboBox(
box, self, value='x_var_index', label="Input: ",
orientation=Qt.Horizontal, callback=self.apply,
maximumContentsLength=15)
self.comboBoxAttributesX.setModel(self.x_var_model)
self.expansion_spin = gui.doubleSpin(
gui.indentedBox(box),
self, "polynomialexpansion", 0, 10,
label="Polynomial expansion:", callback=self.apply)
gui.separator(box, height=8)
self.y_var_model = itemmodels.VariableListModel()
self.comboBoxAttributesY = gui.comboBox(
box, self, value="y_var_index", label="Target: ",
orientation=Qt.Horizontal, callback=self.apply,
maximumContentsLength=15)
self.comboBoxAttributesY.setModel(self.y_var_model)
properties_box = gui.vBox(self.controlArea, "Properties")
self.error_bars_checkbox = gui.checkBox(
widget=properties_box, master=self, value='error_bars_enabled',
label="Show error bars", callback=self.apply)
gui.rubber(self.controlArea)
# main area GUI
self.plotview = pg.PlotWidget(background="w")
self.plot = self.plotview.getPlotItem()
axis_color = self.palette().color(QPalette.Text)
axis_pen = QPen(axis_color)
tickfont = QFont(self.font())
tickfont.setPixelSize(max(int(tickfont.pixelSize() * 2 // 3), 11))
axis = self.plot.getAxis("bottom")
axis.setLabel(self.x_label)
axis.setPen(axis_pen)
axis.setTickFont(tickfont)
axis = self.plot.getAxis("left")
axis.setLabel(self.y_label)
axis.setPen(axis_pen)
axis.setTickFont(tickfont)
self.plot.setRange(xRange=(0.0, 1.0), yRange=(0.0, 1.0),
disableAutoRange=True)
self.mainArea.layout().addWidget(self.plotview)