How to fix Pycharm's indexing of PyGTK

R

ryanvade

Guest
For those of you who use Pycharm to write PyGTK applications this is how to fix the indexing issues. The problem is that Pycharm does not, by default, index large binary python modules. To fix this we have to do two things:
  • Change the max size of binary files Pycharm's Intellisense can index
  • Force Pycharm to index the binary modules for PyGTK
From Commandline:
1. modify /opt/pycharm-{community/professional}/bin/idea.properties by commenting out the line with
Code:
idea.max.intellisense.filesize=2500
*Note: Make sure to use the correct file location. Administrative permissions will be needed to edit the file.

From Pycharm:
1. Create a project and a python file.
2. Write a basic PyGTK application such as:
Code:
from gi.repository import Gtk
win = Gtk.Window()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
3. If importing Gtk is Unrecognized with an error such as:
Code:
Unresolved reference 'GTK' less... (Ctrl+F1)
This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.
Go to Code -> Inspect Code then either select Whole project or Selected files and click OK.
4. After the code cleanup is completed, find the Unresolved Reference issue in the analysis results. (Under Inspection results -> Project Name -> Python -> Unresolved references)
5. In the Error explanation box click on Generate stubs for binary module

*Note: There is supposed to be a quicker way to fix the indexing problem by hitting Alt + Enter while typing the import of PyGTK but I have not been able to use this solution.
 

Members online


Top