I'm a beginner to Pyside6 and mne-python. I want the raw.plot to block so I can interact with the figure. However, the program continue to run and print 'after window close' after the figure opened. According to mne documentation, https://mne.tools/stable/generated/mne.viz.plot_raw.html?highlight=plot_raw#mne.viz.plot_raw I have set the parameter block to True, but it doesn't work.
import matplotlib
import mne, sys
from PySide6.QtWidgets import QMainWindow, QPushButton, QApplication
matplotlib.rcParams['font.sans-serif'] = ['Arial Unicode MS']
matplotlib.rcParams['axes.unicode_minus'] = False
matplotlib.use('qtAgg')
class Test(QMainWindow):
def __init__(self):
super(Test, self).__init__()
self.button = QPushButton('Plot raw')
self.button.clicked.connect(self.Show)
self.setCentralWidget(self.button)
def Show(self):
sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = (sample_data_folder / 'MEG' / 'sample' /
'sample_audvis_filt-0-40_raw.fif')
raw = mne.io.read_raw_fif(sample_data_raw_file)
raw.plot(block=True)
print('after window close')
app = QApplication(sys.argv)
main = Test()
main.show()
app.exec()
sys.exit()
When the program is running, it shows some information like this: CoreApplication::exec: The event loop is already running. I search for it, but don't find a solution to my problem. Is this an waring or error and can anyone give me a solution?