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 :https://youtrack.jetbrains.com/issue/PY-6932 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.
2 comments
Comment actions Permalink
you need to import Gtk ( download it first) and have the right path
0
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 idea.properties file.
To find the location of the file I ran:
sudo find / -iname idea.properties

MY OUTPUT WAS: /snap/pycharm-community/64/bin/idea.properties
Since my pycharm is installed in a snap i can not edit the file, but open the idea.properties
file and comment out:
idea.max.intellisense.filesize=2500
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)
window.show_all()
Gtk.main()
0

Please sign in to leave a comment.