Bonjour à toutes et à tous!
J'ai un petit soucis sur un de mes bouts de codes.
J'ai une fenêtre avec un layout où doit aller un graphique matplotlib.
J'ai fais le code du graphique et cela fonctionne.
Maintenant mon problème est lors de l'intégration au layout Qt, il manque un argument dans la classe où j'ai créer mon graphique mais je n'arrive pas à trouver ce qu'il faut mettre.
Fichier principal du programme:
Fichier où se trouve le graphique:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 #Intégration du graphique dans le layout self.Graph = Temperatures.TempGraph() self.ui.verticalLayout_TempraturesGraphic.addWidget(self.Graph)
Erreur dans le terminal:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 #Modules de Pythonimport matplotlib.pyplot as plt import matplotlib.animation as animation from matplotlib import style class TempGraph(): def animate(self, i): graph_data = open("temp.txt", "r").read() lines = graph_data.split("\n") xs = [] ys = [] for line in lines: if len(line) > 1: x, y = line.split(",") xs.append(x) ys.append(y) self.ax1.clear() self.ax1.plot(xs, ys) def __init__(self): style.use = ('fivethirtyeight') fig = plt.figure() self.ax1 = fig.add_subplot(1, 1, 1) ani = animation.FuncAnimation(fig, self.animate, interval = 1000) plt.show()
Merci d'avance!
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 Traceback (most recent call last): File "CNControl.py", line 69, in <module> window = MainWindow() File "CNControl.py", line 41, in __init__ self.ui.verticalLayout_TempraturesGraphic.addWidget(self.Graph) TypeError: addWidget(self, QWidget, stretch: int = 0, alignment: Union[Qt.Alignment, Qt.AlignmentFlag] = Qt.Alignment()): argument 1 has unexpected type 'TempGraph'
Partager