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

Dear Sr.

Iā€™m following this tutorial:
https://mne.tools/dev/auto_tutorials/forward/35_eeg_no_mri.html#sphx-glr-auto-tutorials-forward-35-eeg-no-mri-py

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(raw.info, 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.
best
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.