[Bf-committers] Add drag&drop box for python operator
ideasman42 at gmail.com
Wed May 30 12:43:34 CEST 2012
Currently this isnt possible.
AFAIK this isnt trivial to add - though to be sure of this I would
need to attempt to add it and see what problems come up.
When a region is initialized drop-boxes are defines but this happens
in C so we would need to add a way for the C code to call out to
python functions that define their own drop areas (which may change -
added on not each time).
Another way could be to have these drop boxes defines as persistant
data that python can go in and manipulate - but this isnt in keeping
with our existing design... so will ignore this for now.
Callbacks to define a drop area could be done like region draw
callbacks in source/blender/python/intern/bpy_rna_callback.c
So you could do something like...
def box(self, space): return x, y, w, h
handle = bpy.types.SpaceView3D.callback_add(drop_callback, (self,
This would be different to existing use of callback_add since it
applies to a space type - not the instance of a space type.
Existing use of callback_add looks like this...
handle = context.region.callback_add(draw_callback_px, (self,
2 Other ways to do this *(which I think are bad options...)
* using bpy.app.handlers style callbacks --- this fits poorly with the
design of this api which is meant for python to handle events in the
application (render, load, save, quit etc)
* being able to register a subclass of a space type that defines a
calls to define drop areas --- overkill.
On Wed, May 30, 2012 at 9:39 AM, Julien Duroure
<julien.duroure at gmail.com> wrote:
> Nobody to help me resolving my problem ?
> Will take my chance on IRC if not ;-)
> On Mon, May 28, 2012 at 10:07 AM, Julien Duroure
> <julien.duroure at gmail.com>wrote:
>> Hi all,
>> I am currently trying to add a new dropbox for drag&drop action.
>> I have define a new python operator, but at blender launching, executing
>> WM_dropbox_add, I have the following error :
>> search for unknown operator 'VIEW3D_OT_add_image_texture_brush',
>>> Error: dropbox with unknown operator: view3d.add_image_texture_brush
>> It seems that python operators are not yet registered when executing
>> dropboxes initializations.
>> After that, using Python Console autocompletion, my operator is found, are
>> correctly executed, so I know that there is no syntax error on my operator.
>> All examples, I found in source code, are using C operator. I tried to
>> create a dummy C operator, and all works fine in this case.
>> Is there a way to resolve my problem, or is it not possible to execute
>> python operator when drag&drop ?
> Bf-committers mailing list
> Bf-committers at blender.org
More information about the Bf-committers