tkinter and mne: how embed mne.viz.plot_alignment() in a tkinter frame

Dear Sr.

I’m following this tutorial:

but can’t figure out how to plot the dinamic image in a tkinter frame python 3.8

Besides when plotting outside tkinter it changes the resolution and size of fullscreen tkinter window to a smaller size.

I want to plot in a tkinter frame—>

mne.viz.plot_alignment(, src=src, eeg=[‘original’, ‘projected’], trans=trans,
show_axes=True, mri_fiducials=True, dig=‘fiducials’)

Any suggestions are welcome.

Hello @PauloKanda, this doesn’t answer your question (sorry), but: the PyQt5 Matplotlib backend seems to work best for our interactive figures, and we recommend using it if possible.

Dear Mr Höchenberger

Thank you for the suggestion. Unfortunately I´ve already written 6622 lines of code in tkinter (to this specific app). Consequently, I will be waiting for the light of a lighthouse to guide me.
best regards

Paulo Kanda

Hello, it’s only now that I’m realizing you asked about plot_alignment and not (as I read) plot_sensors :man_facepalming: I don’t think there’s a way to do what you’re trying to achieve, then, and I don’t think there will be in the foreseeable future. @GuillaumeFavelier, WDYT?

Dear Mr. Höchenberger

This is just a small issue, no problem at all. I’m learning a lot with mne. Thanks for your kindness and for sharing your amazing tool.
Paulo Kanda

MNE-Python currently works with two 3D backends: mayavi and pyvista. pyvista uses Qt for its GUI / window management. Mayavi uses vtk, though it has a guide for integrating it into other interactive apps (see here). If you really need this, your best bet is probably to tell MNE-Python to use the mayavi backend (mne.viz.set_3d_backend('mayavi')), and then work through Mayavi’s integration guide linked above. I don’t know if it will work with tkinter; they only give examples for wxpython and Qt.

1 Like

Dear MrMcCloy

thank you again.