Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm - autocomplete for Gtk3 magically stops working

I have this weird problem - I'm learning Gtk3 on Windows 7 with PyCharm Community 3.4.1. When I try to import Gtk:

from gi.repository import Gtk

it underlines Gtk as unresolved reference, becouse it's a binary module. Then I press Alt+Enter and choose "Generate methon stubs for binary module..." and wait until it it finishes indexing. Then I happily write this simple empty window with autocomplete working correctly:

class Okienko(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self, title='Okienko')

app = Okienko()
app.connect('delete-event', Gtk.main_quit)
app.show_all()
Gtk.main()

I run it, it shows me a nice empty Gtk window. So far so good.

BUT.

Bad things happen - autocomplete for Gtk module simply vanishes! from gi.repository import Gtk gets underlined red and autocomplete gives me just names which I've previously used (Window and main in this case). The only thing I can do is to Invalidate cache and restart Pycharm and go over this procedure again... I also tried .NET classes in IronPython - it's even worse, indexing takes several minutes and doesn't even finish.

like image 543
DiPi Avatar asked Jun 17 '14 00:06

DiPi


People also ask

Why is PyCharm autocomplete not working?

You need to go into the project settings and configure the interpreter to point at the virtualenv. PyCharm will then index the interpreter and allow you to autocomplete. The virtualenv may be auto-detected in the dropdown menu on the left.

How do I enable autocomplete in PyCharm?

Invoke basic completionPress Ctrl+Space or choose Code | Code Completion | Basic from the main menu. If necessary, press Ctrl+Space for the second time (or press Ctrl+Alt+Space ).

How do I turn off auto complete in PyCharm?

Go to File > Settings (or Ctrl + Alt + S ) > [IDE Settings] > Editor > Code Completion. The "Autopopup code completion" setting will determine if the popup opens automatically. Below it, the "Insert selected variant by typing dot, space, etc." is likely the setting you want to turn off. Save this answer.


2 Answers

In PyCharm community edition 3.4.1 (mint 17), to make Gtk3 autocompletion works:

  1. In file: "pycharm.community-3.4.1/bin/idea.properties" comment the line: "idea.max.intellisense.filesize=2500"
  2. Restart the IDE
  3. In your code: from gi.repository import Gtk strike Alt-Enter and select "Generate stubs for binary module"
like image 154
Victor Forero Avatar answered Dec 18 '22 15:12

Victor Forero


I had the same issue and found out that the Gtk.py file is too big for IDE file size limit allowed by PyCharm. I changed the config value "idea.max.intellisense.filesize" in idea.properties from 2500 to 10000. The stub generation takes some time but finishes now.

Hope that helps even Windows users. Feedback appreciated.

like image 25
Devmind Avatar answered Dec 18 '22 13:12

Devmind