question about python-fu and GTK+ 3.0

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

question about python-fu and GTK+ 3.0

Developers mailing list
Good evening,

I have been writing some python plug-ins for gimp over the past months with
great success. I really appreciate the effort that has gone into creation
of the plugin system.

I have one question specifically, which is a little more advanced. I am
trying to create a small interface for the plugin using GTK. I have in the
past used python-gtk (`import gtk`), which worked when launched from a gimp
plugin without a hitch. I have seen in many places that this library is
deprecated and that I should switch to GTK+ 3.0 if possible. Following
standard introductions, I arrive at a plugin file with the following
content:

#!/usr/bin/env python

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk


from gimpfu import *



class BaseUI2(object):

    def __init__(self):
        win = Gtk.Window()
        win.connect("destroy", Gtk.main_quit)
        win.show_all()

    def main(self):
        Gtk.main()

def g_test(img, drawable):

    w = BaseUI2()
    w.main()


register("g-test", "", "", "", "", "",
  "<Image>/Image/G  - Test", "RGB, RGB*",
  [

  ],
  [],
  g_test
  )

main()

-------------------

While the UI code runs fine when interpreted with standard python2.7 (or
3), trying to launch from a plugin gives: "ImportError: When using
gi.repository you must not import static modules like "gobject". Please
change all occurrences of "import gobject" to "from gi.repository import
GObject". See: https://bugzilla.gnome.org/show_bug.cgi?id=709183" , which I
have read is a symptom from trying to use "gtk" and "gi" together. I assume
that the "gtk" import is happening somewhere in the lower level code and is
causing this issue, but I am not sure.

Is there any way to use the python GTK+ 3.0 bindings in a GIMP plugin
currently?

Thank you for reading,
-Paul
_______________________________________________
gimp-developer-list mailing list
List address:    [hidden email]
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list