Getting started with GTK app development

Sorry, I haven’t used PyCharm for a long time. You’ll probably have to ask for help in Jetbrains’ support forums. Have you configured your project to use /usr/bin/python3 and installed python-gobject/PyGObject?

I vaguely remember using “generate stubs”, so if it’s gone I hope that doesn’t mean PyCharm no longer supports GI. If that is the case, try fakegir instead; VS Code is arguably the best alternative to PyCharm. It could also be worth checking whether gnome-builder has an equivalent feature.

Thanks for you reply! :slightly_smiling_face:

Yes, I use the default interpreter. python-gobject is installed as well. I can execute Python GTK programs just fine.

I also tried VS Code, there I couldn’t get auto-completion for GTK objects working as well :frowning:
Do you use VS Code at the moment, or what is your preferred IDE? Maybe you can give some tips how to get it working with VS Code?

Builder was what I tried first, which also doesn’t has reliable auto-completion for GTK objects: No auto-completion for python project in Gnome Builder

I mostly use VS Code or vim now, but I haven’t been writing anything using PyGObject lately. Did you install fakegir and follow its instructions to enable it in VS Code?

Yes, unfortunately it also didn’t worked.

$ ls .cache/fakegir/gi/repository/
cairo.py     DBus.py        freetype2.py  GCi.py  GIRepository.py  GL.py       GObject.py   libxml2.py  win32.py   xft.py   xrandr.py
DBusGLib.py  fontconfig.py  GCalc.py      Gio.py  GLib.py          GModule.py  __init__.py  Vulkan.py   xfixes.py  xlib.py

settings.json:

"python.autoComplete.extraPaths": [
    "/home/schiesbn/.cache/fakegir/"
],

Surprisingly, when I start the interactive python interpreter directly in the terminal I can auto-complete GTK objects and their methods. So it seems like technically everything needed is installed on the system. Also the python3-gi package is installed. But for whatever reasons neither VS Code nor Pycharm uses it.

I forgot something else, are you using type hints? They might be necessary for the auto-completion to work, otherwise there aren’t enough clues for Jedi or whatever to work out the type of the object you’re editing.

I think that is sharp but how do i use c++, or is it that there is no support for it?