【问题标题】:Change the title font type in pyqtgraph更改 pyqtgraph 中的标题字体类型
【发布时间】:2020-05-31 11:51:28
【问题描述】:

我有一个自定义字体已经上传为 Qfont,我想将它应用到 PlotWidget 的标题。我设法将它应用到刻度轴标签,但到目前为止我对标题本身没有运气。这就是我管理轴的方式:

import pyqtgraph as pq
from PyQt5 import QtGui
id = QtGui.QFontDatabase.addApplicationFont(cnst.ABS_FONT_PATH + 'Century18th.ttf')
_fontstr = QtGui.QFontDatabase.applicationFontFamilies(id)[0]
font= QtGui.QFont(_fontstr, 40)

....

widg = pq.PlotWidget(background=(0, 0, 0, 255), x=[0, 1, 2, 3], y=[0, 1, 2, 3],font= font,font_size= 30) 
item= widg.getPlotItem()
item.getAxis("bottom").tickFont = font
item.getAxis("left").tickFont = font

Title 有没有类似于 tickFont 的东西?在 PlotWidget 初始化时设置字体参数对我来说并没有改变......

非常感谢!!

【问题讨论】:

    标签: python pyqt pyqtgraph


    【解决方案1】:

    最后,我通过查看 pyqtgraph 和 pyqt API 详细信息找到了一种方法。

    ...
    widg = pq.PlotWidget(background=(0, 0, 0, 255), x=[0, 1, 2, 3], 
                                 y=[0, 1, 2, 3],font= font,font_size= 30) 
    item= widg.getPlotItem()
    item.titleLabel.item.setFont(font)
    

    PS:如果他们扩展 pyqtgraph API(当前解决方案适用于 0.10.0),将来可能会有更优雅的直接方式。如果您找到了更聪明的方法,请随时发表评论:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-07-22
      • 2022-12-03
      • 2011-10-29
      • 2011-05-02
      • 2015-04-04
      • 2012-05-25
      • 1970-01-01
      相关资源
      最近更新 更多