Code completion with introspective bindings

Is there any way to get code completion with PyGObject? I've really tried EVERYTHING you can think of.
I have pycharm build 138.2401 where this bug : is supposed to be fixed but I can't get any code suggestions.
This simple code would raise a warning (Gtk is not found):

  1. #!/usr/bin/python3
  2. from gi.repository import Gtk

I really need help. I've been trying for hours and can't get this sorted out.

Thanks in advance.

Iván Lago.
Comment actions Permalink
you need to import Gtk ( download it first) and have the right path
Comment actions Permalink

Make sure you have PyGObject installed.

File>Settings>Project:Your_Project_Name>Project Interperter

Click on the green plus "+" and type "PyGObject"

Click on PyGObject and Install Package

Mine failed the first time and on my Ubuntu system.

So, I also had to install these extra packages to even get the PyGObject to install:

sudo apt install python-distutils-extra
sudo apt install pkg-config
sudo apt install libcairo2-dev
sudo apt install python3-dev
sudo apt install libgirepository1.0-dev

Now that we have PyGObject installed, you will have to edit the pycharm's file.
To find the location of the file I ran:
sudo find / -iname

MY OUTPUT WAS: /snap/pycharm-community/64/bin/
Since my pycharm is installed in a snap i can not edit the file, but open the
file and comment out:
This will allow pycharm to index Gtk and save file

Run this code to make sure it works:
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk

window = Gtk.Window()
window.connect("delete-event", Gtk.main_quit)

Please sign in to leave a comment.