Tkinter GUI support on Verdin IMX8MM board

I have developed an application using Python Tkinter. The GUI of this application throws error while I tried to run it on the Verdin IMX8MM board. I found the Tkinter Graphics library(GTK) is not supported on the board. I have been advised to use PySIde or PyQt instead. I want to know if there is any other SOM board that supports GTK library of python? Secondly if I switch to PySide for GUI development is there any license cost involved?

Thanks
Pramod

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello Pramod,

For your application developed with Python Tkinter, encountering issues on the Verdin iMX8MM board is likely due to the absence of the necessary graphical libraries or configurations required by Tkinter. While Tkinter itself is a standard GUI toolkit for Python, it relies on the underlying system’s graphical capabilities, which might not be directly supported or enabled in the default configuration on Toradex modules.

Regarding your question about other System on Modules (SOMs) that support the GTK library of Python, all Toradex modules, including those in the Colibri, Apalis, and Verdin families, can support GTK given the correct software setup. However, this might require customizing the Linux image to include GTK and its dependencies, which is feasible through the Yocto Project or by installing the necessary packages in TorizonCore with Debian containers.

Switching to PySide (Qt for Python) for GUI development is a viable alternative. PySide is officially supported by Qt and provides bindings to the Qt libraries for Python applications. Regarding the licensing cost, PySide (Qt for Python) is available under the LGPL (Lesser General Public License), which allows for its use in both open-source and proprietary software under certain conditions. If your application is proprietary, you can still use PySide under the LGPL, but you must ensure that you comply with the terms of the LGPL, such as allowing users to re-link your application against different versions of the Qt libraries. If you require a license that does not have these requirements, commercial licenses for Qt are available, which might incur costs.

In summary, while you can enable GTK support on Toradex modules with some effort, switching to PySide for your GUI development might be a more straightforward path, especially considering the licensing flexibility and the support for hardware acceleration on Toradex’s Torizon platform.

Best regards,
Toradex AI Assistant

Please, also check if these links can help you solve your problem:

Qt on Torizon OS | Toradex Developer Center.

Greetings @samalpamod,

What do you mean by:

I found the Tkinter Graphics library(GTK) is not supported on the board.

Where did you get this information from? I believe GTK should generally work. Maybe some functionality may be not ideal but should at least be able to display something basic. If you see this other thread here: Tkinter GUI app in Torizon OS

One of our developers offered a simple Python based Tkinter example. The only thing to note is that we are not Tkinter experts so the support we can provide for related issues is limited.

Secondly if I switch to PySide for GUI development is there any license cost involved?

You should be able to use Pyside for no additional licensing costs as documented here: https://www.pythonguis.com/faq/pyqt-vs-pyside/

Best Regards,
Jeremias

Hi @jeremias.tx
I tested a sample Tkinter GUI application on default torizon os and it did not work. It throws some “: _tkinter.TclError: couldn’t connect to display “:0” or couldn’t open”. Checked the forum and found that it is NXP that does not support X11 any more on IMX8. Bottom line is I still could not run the sample Tkinter application on the Verdin IMX8MM board. Secondly, I developed a sample application using PySide6 which works fine on local machine but does not work on Toradex verdin IMX8MM. Checked forum and found that PySide6 is not supported on IMX8. I checked with toradex support team in India and they said Xserver is not supported on the board hence Tkinter will not work. I think only option I have left is switch to PySide2. But the problem here is Python 3.11 does not support PySide2 as someone mentioned in the forum. I need to choose a lower Python version for the development. Please correct me if the above finding is incorrect.

Thanks
Pramod

It throws some “: _tkinter.TclError: couldn’t connect to display “:0” or couldn’t open”.

This was the same error in the other community thread I linked. Did you take a look at that? The example provided there uses PySimpleGui which is a wrapper for Tkinter. So I would assume basic Tkinter could work.

Checked the forum and found that it is NXP that does not support X11 any more on IMX8.

This is correct. However, Wayland is supported and comes with XWayland as an alternative X server X11 applications. Most X11 applications can use XWayland as an alternative. Unless Tkinter for some reason strictly needs X11 and not XWayland.

Checked forum and found that PySide6 is not supported on IMX8

This I have no knowledge of. Did you find this from the NXP Forums?

But the problem here is Python 3.11 does not support PySide2 as someone mentioned in the forum

Have you tried our VSCode extension that has a template for Pyside2?: GitHub - toradex/vscode-torizon-templates: VS Code Torizon Integrated Development Environment Templates

Best Regards,
Jeremias

Hi jeremias.tx,
Thanks for your reply. Regarding PySide6 support I have not checked NXP site. But I came to know about it on toradex forum. Here is the link where I got the information.

Regarding your VS code template on PySide2, yes that works fine on both the local machine and the device. I have not checked my own code yet on the device.
Regarding using PySimpleGui I have to check how much it supports as my application have rich UI having option to play videos and display dynamic text and images. I need to explore before jumping to new package and restart the development again on the new package
Anyway thanks for your time and kind response
Regards
Pramod

Glad I was able to help. If you experience any issues with our Pyside2 template or any other of our provided templates please do let us know.

Best Regards,
Jeremias

Hi jeremias.tx,
The PySide application was working but not the python Tkinter. I always gets the following error
“pythontkinter-1 | _tkinter.TclError: no display name and no $DISPLAY environment variable”
As mentioned in one of the threads you shared I tried to run

I still get the same error as mentioned below.
"Traceback (most recent call last):
File “/home/torizon/app/src/main.py”, line 6, in
root = tk.Tk()
^^^^^^^
File “/usr/lib/python3.11/tkinter/init.py”, line 2326, in init
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: couldn’t connect to display "
Seems PySide2 is the best option available now. Let me check my sample code on the board.
Thanks for all the supprt.
Regards
Pramod

As mentioned in one of the threads you shared I tried to run

That’s a different thread then the one I linked earlier: Tkinter GUI app in Torizon OS

Also it looks like you’re quoting the response from our ToradexAI bot, which isn’t always the most accurate. Please take a look at my colleague Leon’s response in this thread I just linked.

Best Regards,
Jeremias

Hi jeremias.tx,
That thread uses pysimplegui. I have not checked yet as I need to download pysimplegui package and work again. Anyway thanks for all the support. PySide2 working fine on my board so far.

Thanks
Pramod

In the end just use whatever you feel most comfortable using. The final decision is yours of course. Glad I was able to help clarify some things.

Best Regards,
Jeremias