0
我想在两个图的底部添加一个按钮,它将显示要从文件读入的数据。在这两个地块下面将是一个控制行动的按钮。我试图从pyqt库中添加一个小部件,布局,graphicsItem。 我可以轻松地添加标签的布局,但增加一个按钮,我收到以下错误添加按钮到PyQtGraph布局
addItem(self, QGraphicsLayoutItem, int, int, alignment: Union[Qt.Alignment, Qt.AlignmentFlag] = Qt.Alignment()): argument 1 has unexpected type 'QPushButton'
的代码进行测试时:
import pyqtgraph as pg
win = pg.GraphicsWindow()
win.setWindowTitle('Test App')
label = pg.LabelItem(justify='right')
win.addItem(label)
button = QtGui.QPushButton()
p1 = win.addPlot(row=0, col=0)
p2 = win.addPlot(row=1, col=0)
p3 = win.addLayout(row=2, col=0)
p3.addItem(button,row=1,col=1)