Re: [gedit-list] Scheduling timers from plugins


first, it's best to cc the entire list when you reply, since others may be able to help too (or at least may be interested in what's discussed).

I'd look at the source to the Snippets plugin which comes with gedit - it's written in Python and includes calls to timeout_add.  On a 64-bit Ubuntu system, you could find this at


Alternatively, you could download a gedit tarball at or get the sources using git (see

Note that gedit 3.6 (and earlier) uses Python 2.x, but gedit 3.8 (and later) uses Python 3.x.  So if you write your plugin using Python 2.x now, you'll have to port to Python 3.x when you upgrade to Ubuntu 13.10, which includes gedit 3.8.3.

Also note that the way to call timeout_add is apparently different in these two versions of Python.  Specifically, gedit-3.6.2/plugins/snippets/snippets/ has 'GObject.timeout_add(...)' for Python 2.x, but in gedit 3.8.3 this code reads 'GLib.timeout_add(...)' for Python 3.x.  I'd also look at the import statements at the top of this file for whichever version of Python you want to use.  If all this works in the Snippets plugin, it should work in yours too.  :)


On Sat, Oct 26, 2013 at 6:48 PM, Dustin Oprea <myselfasunder gmail com> wrote:
Since everything breaks when I import gobject, I thought that it might belong to a previous GTK/PyGTK version. Since I found some examples using glib.timeout_add() and glib.timeout_add_seconds() (using "glib" rather than "gobject"), I tried doing this as well. I don't get any import related errors (the error in the previous method occurs on import), but I do get another seg-fault. I was guessing that this happens simply because there is some violation in a late-type binding (like those methods can't actually be found on "glib", at the time of invocation).

Python: 2.7.4
Gedit: 3.6.2
Distro: Ubuntu/13.04
Glib package: libglib2.0-0

Dustin Oprea

On Sat, Oct 26, 2013 at 6:24 PM, Adam Dingle <adam medovina org> wrote:

I'd like to think you should be able to use gobject.timeout_add() and gobject.timeout_add_seconds().  I don't think they will interfere with GTK's loop.  Regarding the error when you import gobject:

- which version of Python are you using?
- which version of gedit?
- do you know which version of GLib is installed on your system?
- which version of which operating system (e.g. Debian, Fedora, Ubuntu) are you running?


On Sat, Oct 26, 2013 at 6:17 PM, Dustin Oprea <myselfasunder gmail com> wrote:
What's an acceptable strategy to regularly invoke functionality in a Python plugin (via some kind of timer)?

The only examples I can find for timers with PyGTK, in general, are gobject.timeout_add() and gobject.timeout_add_seconds(), but I think they're deprecated as the plugin completely ceases to work when I import gobject (I get a "type object 'gobject.GObject' has no attribute 'ref" error).

I'm also assuming that normal Python timers might interfere with GTK's loop, so I shouldn't be using them.

Dustin Oprea

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]