ActiveState Community

CIX starter for Python GTK

Posted by ToddW on 2007-08-13 12:34
OS: Linux

The Komodo team have been working on creating tools for the automatic generation of the codeintel description files for these types of python binary modules.

Attached is a CIX file that covers "gtk._gtk.so", which means you should be able to get completions from code like this:

import pygtk
pygtk.require('2.0')
import gtk   # this performs an import "from gtk._gtk import *"
gtk.<|>  # completions should also include the gtk binary module

Installation
Unzip (gunzip) the gtk._gtk.cix file from gtk._gtk.cix.gz. Inside Komodo, go to your preferences and select the "Code Intelligence" category, then in the API Catalogs section, click on the "Add an API Catalog...", navigate to the gtk._gtk.cix file and add this. You should now have the full gtk completions (if not, try a restart to ensure all the codeintel information is synced).

Now, there are a lot of other binary modules covered by gtk-2.0 packages (gnome, glade, pango, gdl, etc...), which I have not yet scanned. Once some people test this to ensure it's going to be usable, we will release the tools to let people generate these cix files themselves.

Cheers,
Todd

AttachmentSize
gtk._gtk.cix_.gz27.21 KB
gtk_v2.cix_.gz77.56 KB

Nat | Tue, 2007-08-14 18:17

First of all, I want to say I am really amazed by the ActiveState team, you come up with solutions quickly and your support is top notch. I'm very happy I chose Komodo.

I just tested on Windows and it seems to work fine, I will test it tommorow on my work machine (Linux).

Thank you very much.

Nat | Wed, 2007-08-15 14:44

Worked with it all day under linux, no major problems so far.
I'm not sure that gtk._gtk.so covers the gobject class which seems to be the parent of gtk.Object. Some common methods like connect are in that class so they don't work with autocomplete right now. Otherwise, the commonly used gtk.gdk object is not scanned either. (perhaps once the tools to scan are provided it'll be possible to scan those.

Nat

ToddW | Thu, 2007-08-16 11:47

I've updated the cix to include completions for the gobject class and "gtk.gdk" namespace. Due to the import hacks of the gtk module, I needed to do some minor manual hacking myself in order to achieve the same affect.

New cix file is "gtk_v2.cix".

Cheers,
Todd

Nat | Thu, 2007-08-16 22:33

On Windows, I added the gtk_v2.cix catalog (after removing the old version). I get completions for gtk.gdk, but not gtk anymore. I then tried removing the catalog but it raised an error. Adding it again (after a komodo restart) raised another error :

Traceback (most recent call last):
File "C:\Program Files\ActiveState Komodo IDE 4.2\lib\mozilla\components\koCatalogsTree.py", line 315, in run
mgr.db.get_catalogs_zone().update(selections=[dst_path])
File "C:\Program Files\ActiveState Komodo IDE 4.2\lib\mozilla\python\komodo\codeintel2\database\catalog.py", line 384, in update
self._remove_res(res)
File "C:\Program Files\ActiveState Komodo IDE 4.2\lib\mozilla\python\komodo\codeintel2\database\catalog.py", line 432, in _remove_res
dbfile, res_id = dbfile_and_res_id_from_blobname[blobname]
KeyError: 'gtk._gtk'

Nat | Thu, 2007-08-16 22:35

This is the error I get when I remove the catalog :

Traceback (most recent call last):
File "C:\Program Files\ActiveState Komodo IDE 4.2\lib\mozilla\components\koCatalogsTree.py", line 396, in run
mgr.db.get_catalogs_zone().update(selections=[cix_path])
File "C:\Program Files\ActiveState Komodo IDE 4.2\lib\mozilla\python\komodo\codeintel2\database\catalog.py", line 375, in update
self._remove_res(res)
File "C:\Program Files\ActiveState Komodo IDE 4.2\lib\mozilla\python\komodo\codeintel2\database\catalog.py", line 432, in _remove_res
dbfile, res_id = dbfile_and_res_id_from_blobname[blobname]
KeyError: 'gtk.keysyms'

ToddW | Fri, 2007-08-17 10:26

I could not reproduce this error, but I have seen something similar once before. You'll need to:

* Shutdown Komodo
* Remove all gtk*.cix api catalogs, these are installed in the "apicatalogs" directory under the Komodo profile area:
http://community.activestate.com/faq/komodo-file-locations#appdata_dir
* Start Komodo and then try to install the cix again.

Does that fix the errors? Do the completions work correctly after this?

Nat | Sat, 2007-08-18 11:21

The apicatalogs folder was already empty, adding it again gives the same error, the catalog is installed but I don't get completions for gtk, still only for gdk.

Nat | Tue, 2007-08-21 19:15

I tested under Linux and it works fine. I still get the errors on Windows however.

ToddW | Mon, 2007-08-27 12:30

On Windows, you might want to try to clean out the Komodo code intelligence database for python. To do this:

  • unselect all the Komodo Code Intelligence API catalogs
  • shutdown Komodo
  • delete the python codeintel db in the Komodo app data directory:
    http://community.activestate.com/faq/komodo-file-locations#appdata_dir
    del /S <app_data_dir>/host-<hostname>/codeintel/db/python
  • Start Komodo and then reselect the required CIX API catalogs.
  • Restart Komodo and then try gtk completions (it may take a while to re-populate the API data).

Does that fix things or do you still get this error?

Cheers,
Todd

Nat | Mon, 2007-08-27 18:15

Got the same error when trying to install the .cix catalog.

Nat

ToddW | Tue, 2007-08-28 12:57

Which gtk version do you have installed on Windows?

import gtk
print gtk.ver
import gtk
print gtk.ver

Thanks,
Todd

Nat | Tue, 2007-08-28 15:58

2.12.2

kkubasik | Thu, 2008-04-10 06:29

Seening as this seems to have worked pretty well, would you mind sharing more about the tool used to generate the file?

ToddW | Thu, 2008-04-10 14:41

Yes, this is both something the Komodo team have talked about doing and something we want to do. It's simply been a matter of time/priority that this has not already been done.

Thanks to corfy, we have a bug tracking this now:
http://bugs.activestate.com/show_bug.cgi?id=76270

Cheers,
Todd