Ahoj, potřeboval bych radu, jak dostat graf matplolib (např. FFT) do okna pod buttons, kterými budu graf aktualizovat. Také bych potřeboval, aby se graf přizpůsobil velikosti okna. Na přiloženém obrázku je moje představa.
Pomůže mi někdo?
Díky moc
import sys
from PyQt6.QtCore import QSize, Qt
from PyQt6.QtWidgets import QApplication, QMainWindow, QPushButton, QVBoxLayout, QCheckBox, QWidget, QLabel
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
import matplotlib.pyplot as plt
import random
class AnotherWindow(QWidget):
def __init__(self):
super().__init__()
layout = QVBoxLayout()
self.setWindowTitle("MFR - Options")
self.setMinimumSize(QSize(1024, 600))
self.setLayout(layout)
class MainWindow(QMainWindow):
def button_TS_clicked(self):
print("Time signal button clicked!")
def button_FFT1500_clicked(self):
print("FFT1500 button clicked!")
def button_FFT7500_clicked(self):
print("FFT7500 button clicked!")
def button_hilbert_clicked(self):
print("Hilbert button clicked!")
def button_save_clicked(self):
print("Save button clicked!")
def button_options_clicked(self):
self.dialog.exec_()
def cb_update(self, state):
if state == Qt.CheckState.Checked.value:
print("AutoUpdate ON")
else:
print("AutoUpdate OFF")
def options_window(self, checked):
if self.window1.isVisible():
self.window1.hide()
else:
self.window1.show()
def __init__(self):
super().__init__()
QMainWindow.__init__(self)
self.window1 = AnotherWindow()
self.setWindowTitle("MFR")
self.setMinimumSize(QSize(1024, 600))
button_TS = QPushButton("Time signal", self)
button_TS.move(30,30)
button_TS.clicked.connect(self.button_TS_clicked)
button_FFT1500 = QPushButton("FFT 10-1500Hz", self)
button_FFT1500.move(150,30)
button_FFT1500.clicked.connect(self.button_FFT1500_clicked)
button_FFT7500 = QPushButton("FFT 500-7500Hz", self)
button_FFT7500.move(270,30)
button_FFT7500.clicked.connect(self.button_FFT7500_clicked)
button_hilbert = QPushButton("Hilbert", self)
button_hilbert.move(390,30)
button_hilbert.clicked.connect(self.button_hilbert_clicked)
button_save = QPushButton("Save wav", self)
button_save.move(510,30)
button_save.clicked.connect(self.button_save_clicked)
button_options = QPushButton("Options", self)
button_options.move(630,30)
button_options.clicked.connect(self.options_window)
cb = QCheckBox("Auto Update", self)
cb.move(750,30)
cb.stateChanged.connect(self.cb_update)
cb.toggle()
cb.setChecked(False)
self.label_1 = QLabel(self)
self.label_1.move(30, 70)
self.label_1.setText("SOME TEXTS.........................")
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()