# tkinter and mne: how embed mne.viz.plot\_alignment() in a tkinter frame

**URL:** <https://mne.discourse.group/t/tkinter-and-mne-how-embed-mne-viz-plot-alignment-in-a-tkinter-frame/3551>\
**Category:** Support & Discussions\
**Tags:** eeg, visualization\
**Created:** [August 15, 2021, 10:51pm UTC](https://mne.discourse.group/t/tkinter-and-mne-how-embed-mne-viz-plot-alignment-in-a-tkinter-frame/3551 "2021-08-15T22:51:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![PauloKanda](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/paulokanda/32/642_2.png) [@PauloKanda](https://mne.discourse.group/u/PauloKanda)\
**Post date:** [August 15, 2021, 10:51pm UTC](https://mne.discourse.group/t/tkinter-and-mne-how-embed-mne-viz-plot-alignment-in-a-tkinter-frame/3551/1 "2021-08-15T22:51:23Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [August 17, 2021, 9:18pm UTC](https://mne.discourse.group/t/tkinter-and-mne-how-embed-mne-viz-plot-alignment-in-a-tkinter-frame/3551/2 "2021-08-17T21:18:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![PauloKanda](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/paulokanda/32/642_2.png) [@PauloKanda](https://mne.discourse.group/u/PauloKanda)\
**Post date:** [August 18, 2021, 1:15am UTC](https://mne.discourse.group/t/tkinter-and-mne-how-embed-mne-viz-plot-alignment-in-a-tkinter-frame/3551/3 "2021-08-18T01:15:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [August 18, 2021, 8:46am UTC](https://mne.discourse.group/t/tkinter-and-mne-how-embed-mne-viz-plot-alignment-in-a-tkinter-frame/3551/4 "2021-08-18T08:46:45Z")

</div>

Hello, it’s only now that I’m realizing you asked about `plot_alignment` and not (as I read) `plot_sensors` 🤦‍♂️ 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?

---

<div class="post-metadata">

**Author:** ![PauloKanda](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/paulokanda/32/642_2.png) [@PauloKanda](https://mne.discourse.group/u/PauloKanda)\
**Post date:** [August 18, 2021, 12:13pm UTC](https://mne.discourse.group/t/tkinter-and-mne-how-embed-mne-viz-plot-alignment-in-a-tkinter-frame/3551/5 "2021-08-18T12:13:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [August 18, 2021, 3:19pm UTC](https://mne.discourse.group/t/tkinter-and-mne-how-embed-mne-viz-plot-alignment-in-a-tkinter-frame/3551/6 "2021-08-18T15:19:54Z")

</div>

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](http://docs.enthought.com/mayavi/mayavi/building_applications.html?highlight=building%20applications)). 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.

---

<div class="post-metadata">

**Author:** ![PauloKanda](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/paulokanda/32/642_2.png) [@PauloKanda](https://mne.discourse.group/u/PauloKanda)\
**Post date:** [August 18, 2021, 11:33pm UTC](https://mne.discourse.group/t/tkinter-and-mne-how-embed-mne-viz-plot-alignment-in-a-tkinter-frame/3551/7 "2021-08-18T23:33:42Z")

</div>

Dear MrMcCloy

thank you again.
