Python 3.5
PyQt5(Qt Designer + PyUic)
Накидал в дизайнере форму.(рис 1.)
Есть скрипт который выводит на экран анимированный график matplotlib.
import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation import matplotlib # import pylab import numpy as np R = 5 T = 19 def x_rez(t): return R * (t - np.sin(t)) def y_rez(t): return R * (1 - np.cos(t)) def f_res(): list1 = [] X = [] Y = [] t = 0 while t < T: X.append(x_rez(t)) Y.append(y_rez(t)) t += 0.01 list1.append(X) list1.append(Y) return list1 def init(): ax.set_xlim(-10, 2 * np.pi * R * 3 + 1) ax.set_ylim(-2, R * 5 + 20) return ln, def update(frame): x_frame = x_rez(frame) y_frame = y_rez(frame) xdata.append(x_frame) ydata.append(y_frame) x, y = patch.center x = x_frame patch.center = (x, y) ln.set_data(xdata, ydata) patchC.center = (x_frame, y_frame) #patchLine.set_data([x_frame, x], [y_frame, y]) #print(x_frame, y_frame) #ax.add_line(patchLine) ax.add_patch(patch) ax.add_patch(patchC) return ln, patch, patchC, if __name__ == "__main__": # res1 = f_res() # print('res1', type(res1), res1) # plt.plot(res1[0], res1[1]) # plt.ylim(-2, R*5) # plt.xlim(-10, 2*math.pi*R*3+1) fig, ax = plt.subplots() xdata, ydata = [], [] ln, = plt.plot([], [], animated=True) fig.set_size_inches(10, 5) ax.set_ylim(-2, (x_rez(19) + 5)/2) ax.set_xlim(-10, x_rez(19) + 5) # axes = pylab.gca() # axes.set_aspect("equal") patch = plt.Circle((0, R), R, fill=False, color='r') patchC = plt.Circle((0, 0), 0.5, fc='y') patchLine = plt.Line2D([0, 0], [R, 0], color="k") ani = FuncAnimation(fig, update, frames=np.linspace(0, 19, 128), blit=True, interval=100, init_func=init, repeat=False) plt.show()
# -*- coding: utf-8 -*- from PyQt5 import QtWidgets, QtCore import aza_rc from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas import matplotlib.pyplot as plt class MyWindow(QtWidgets.QWidget, aza_rc.Ui_Form): def __init__(self, parent=None): super().__init__(parent, QtCore.Qt.Window) self.setupUi(self) self.fig, self.ax = plt.subplots() self.fig.set_size_inches(10, 5) self.canvas = FigureCanvas(self.fig) self.verticalLayout_2.addWidget(self.canvas) self.pushButton.clicked.connect(self.plot) def plot(self): ''' plot some random stuff ''' self.canvas.draw()