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)