I've been running into a problem for several days,
The program allows you to retrieve data, create one, and display it on a Figure.
I did it this way because we can display 2 curves or 3 curves no matter what we press the button and presto it is displayed.
My questions are therefore to know if in the current state it is possible to delete the graphs? If the programs are relatively well written? How else should I do? And my last question, I would like to create a function which would allow to retrieve the data directly from the Figure, is it possible?
self.fig = Figure(figsize=(6.25,4.16), dpi=96)
ax = self.fig.add_subplot(111)
def ref():
is_cal = messagebox.askquestion("Mesure Référence","Le calibrage à t'il était fait ?")
if is_cal == "yes":
print("Cal = TRUE")
FUNCTION GET DATA NO ISSUES WITH IT return X Y
#Check if data is OK, matching number, not empty array
if y.all():
if x.all():
ax.plot(x, y, label="Ref S21 Start {} Hz Pwr {}dBm Bw {} Stop {} Hz".format(self.startfreq, self.power ,self.rbw ,self.endfreq))
#ax.set_title("DUT ??? : ??/??/????")
ax.set_xscale("log")
ax.set_xlabel("Fréquence (Hz)")
ax.set_ylabel("Atténuation (dB)")
ax.legend()
ax.grid(True, which="both", ls="-")
graph = FigureCanvasTkAgg(self.fig, master=canvas_display)
graph.draw()
graph.get_tk_widget().place(x=1,y=1)
self.pdf = self.fig
else:
print("Erreur")
subsection_min['text'] = " Atténuation minimum : {} dB".format(round(self.Minimum(y),1))
subsection_max['text'] = " Atténuation maximum : {} dB".format(round(self.Maximum(y),1))
subsection_moy['text'] = " Atténuation moyenne : {} dB".format(round(self.Average(y),1))
self.averageref_value = self.Average(y)
if is_cal == "no":
print("CAL = FALSE")
messagebox.showerror("Mesure Référence", "Il est impossible de trouver la référence si le calibrage n'est pas correct / initialisé")
def dut():
print("Print new graph")
FUNCTION GET DATA NO ISSUES WITH IT return X Y
self.x = x
self.y = y
is_ref = messagebox.askquestion("Mesure DUT", "La mesure de référence à t-elle était faite ?")
if is_ref == "yes":
#Check if data is OK, matching number, not empty array
if y.all():
if x.all():
#Duplicate
self.nbdut = self.nbdut + 1
ax.plot(x, y, label="DUT {} S21 Start {} Hz Pwr {}dBm Bw {} Stop {} Hz".format(self.nbdut, self.startfreq, self.power ,self.rbw ,self.endfreq))
ax.set_title("PLOT 1 : 22/04/2021")
ax.set_xscale("log")
ax.set_xlabel("Fréquence (Hz)")
ax.set_ylabel("Atténuation (dB)")
ax.legend()
ax.grid(True, which="both", ls="-")
graph = FigureCanvasTkAgg(self.fig, master=canvas_display)
graph.draw()
graph.get_tk_widget().place(x=1,y=1)
self.pdf = self.fig
else:
print("Erreur")
subsection_min['text'] = " Atténuation minimum : {} dB".format(round(self.Minimum(y),1))
subsection_max['text'] = " Atténuation maximum : {} dB".format(round(self.Maximum(y),1))
subsection_moy['text'] = " Atténuation moyenne : {} dB".format(round(self.Average(y),1))
self.averagedut_value = self.Average(y)
if is_ref == "no":
messagebox.showerror("Mesure DUT", "Lancez d'abord la mesure de référence avant la mesure DUT")
def raz():
print("RAZ")
#self.fig = Figure(figsize=(6.25,4.16), dpi=96)
self.fig.ax().close()