每当您右键单击 PyQtGraph 中的绘图时,我都会尝试更改菜单的字体大小。当我使用 更改整个应用程序的字体大小时setStyleSheet
,它也会更改菜单的字体大小。
前
后
我不想单独更改按钮的字体大小,因为我在 GUI 中有许多其他小部件,所以我更改了app
字体大小。但它也改变了绘图菜单的字体大小。如何使菜单的字体大小变小?要么将字体大小更改得更小,要么以某种方式使菜单变大,这样单词就不会被截断。
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
import sys
if __name__ == '__main__':
app = QtGui.QApplication([])
main_window = QtGui.QMainWindow()
widget = QtGui.QWidget()
main_layout = QtGui.QVBoxLayout()
widget.setLayout(main_layout)
main_window.setCentralWidget(widget)
button = QtGui.QPushButton('hello')
plot_widget = pg.PlotWidget()
plot = plot_widget.plot()
layout = QtGui.QHBoxLayout()
layout.addWidget(button)
layout.addWidget(plot_widget)
main_layout.addLayout(layout)
main_window.show()
app.setStyleSheet('QWidget {font-size: 30px}')
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()