GTK3+ Development using PyCharm

I recently encountered an issue when using silverblue and trying to develop a simple GTK3+ application using python as primarily language for the application.

The issue was that the PyGObject bindings were not recognized by PyCharm when trying to launch the application. Simpy put the following imports failed:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

It seemed as if it was not installed.

However it was installed in a toolbox.

I could enter the toolbox and simply run the python script from command line and it worked as expected.
I came to the realization that the Flatpak variant of PyCharm is not capable of using PyGObject since PyCharm is sandboxed.

The solution for me was installing PyCharm by downloading the package from the developer Jetbrains, and installing it inside my toolbox.

After installation I could launch PyCharm open the GTK+/Python Project and run it without any problems.

Now for a lot of people it is not exactly preferred to manually launch PyCharm from the command line to work on their project.

A solution for that is using this toolbox run --container {CONTAINER_NAME} {PATH_TO_COMMAND} as a command in a .desktop file to add it your menu. I’d recommend using AppEditor its available as Flatpak and did the trick for me.