Re: Python plugin dev: getting picked color from gimpui.PickButton.color-picked event callback?

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

 



You are really trying something very different than what the current
GIMP-Python integration is thought of to do:
You are using gobject introspection to call functions that up to now
have only been called from native-code
plug-ins (normally in C), and have no provision to be called from
Python or other language supported
by gobject introspection but for the automatic generation of the bindings.

I am in fact surprised you could get this far.

GIMP-Python plug-ins, AKA python-fu, are designed to around a python-module
that is delivered with GIMP, and comunicates with GIMP through the
"Procedural database" (PDB).
The module does have some higher level constructs, such as images,
layers, layer-groups,
but these are just rebuilt on the Python side from  values such as
numeric and string IDs fetched
from GIMP through pdb calls.

That said, you can see all your available API by going to help->PDB
browser on GIMP.
(Open any .py file that comes with GIMP to see how the plug-ins are
registered and created,
if yours go on a completely different way by trying to use the libgimp API)

Now, plug-ins in GIMP - neither the ones built using native code - are
not supposed
to be able to change the active tool while running - so, to get
exactly what you want is impossible.

You can make a Python plug-in that will display a custom gtk+ window,
change a layer's visibility,
and display instructions for the user to change to the color picker
tool (maybe your hack with gobject
can do that, but I would not trust it across GIMP versions/platforms),
and pick a color.
At this time, the plug-in can read the picked color with a call to
pdb.gimp_context_get_foreground .

  js
 -><-



On 5 February 2014 21:20, Viet Nguyen <vietjtnguyen@xxxxxxxxx> wrote:
> My goal is to write behavior where a click on my special pick button will
>
> 1. Modify layer visibility
> 2. Run the normal pick tool
> 3. Do something with the picked color
>
> I'm trying to do this as a Python plugin so I'm trying to implement this
> using `gimpui.PickButton` and adding event callbacks for `clicked` and
> `color-picked`. I'm using `pydoc gimpui` as a reference.
>
> Unfortunately the Python API apparently has obscured the color data
> structure that gets passed to the `color-picked` event callback. It passes
> it as a `gobject.gpointer` which is just an intractable pointer (see
> http://developer.gimp.org/api/2.0/libgimpwidgets/GimpPickButton.html#GimpPickButton-color-pickedand
> https://developer.gnome.org/glib/2.37/glib-Basic-Types.html#gpointer). I
> don't know of any way to pull out the triple double union in Python.
>
> A simpler solution would be to simply "activate" the standard color picker,
> but I can't figure out how to do that with the API available. I would
> appreciate any help and/or ideas on this.
>
> Thanks!
>
> Viet
> _______________________________________________
> gimp-developer-list mailing list
> List address:    gimp-developer-list@xxxxxxxxx
> List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
> List archives:   https://mail.gnome.org/archives/gimp-developer-list
_______________________________________________
gimp-developer-list mailing list
List address:    gimp-developer-list@xxxxxxxxx
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list




[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux