【发布时间】:2022-06-10 17:39:37
【问题描述】:
我想在 pyQT GUI 中绘制图表。我已经阅读了很多教程,但是那些在单独的窗口中绘制图表。我需要将其绘制在与其他按钮和字段相同的窗口中。
在我的 main.py 文件中,我导入了使用 QT 设计器生成的 Ui_MainWindow 类。但我不知道如何在 MainWindow 中绘制它
Matplotlib 画布类创建图形
class MplCanvas(FigureCanvas):
def __init__(self):
self.fig = Figure()
self.ax = self.fig.add_subplot(111)
FigureCanvas.__init__(self, self.fig)
FigureCanvas.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
def atualizar(self):
global tempoInicio
tempoInicio = self.campoTempoInicio.dateTime()
print(tempoInicio.toPyDateTime())
x=range(0, 10)
y=range(0, 20, 2)
self.FigureCanvas.canvas.ax.plot(x, y)
self.FigureCanvas.canvas.draw()
我试过这样,但效果不佳(按照教程)
提前感谢您阅读本文。
【问题讨论】:
标签: python qt user-interface charts pyqt