Thanks Jo. It doesn't help directly, but it did get me thinking about
creative ways to assign the callbacks.

The main issue is that this list of Commands and the callback functions
they are bound to is generated on the fly by an external Python Object. But
Softimage wants each explicit function defined in the local scope of the
Self Installed Plugin script. In my case, I can't define the equivalent of
do_something and do_something else.

What ended up solving the issue for me was a huge hack. I'm basically
passing the globals() dictionary into the Python Object when it's called
from inside my Menu_Init() handler. Inside the Python Object it does the
following:


callback_name = getattr(self.callback, "__name__")

#self.global_dict points to globals() from the Object Caller
self.global_dict[callback_name] = lambda x: self.callback()
menu.AddCallbackItem2(self.name, callback_name)



On Thu, Oct 4, 2012 at 10:28 PM, jo benayoun <[email protected]> wrote:

> Hey Bradley,
> is this helping you?
>
> do_something = lambda x: x
> do_something_else = lambda x: x
> menu = ctxt.Source
> commands = {"Do something": do_something, "Do something Else":
> do_something_else, ...}
> [menu.AddCallbackItem(x, getattr(y, "__name__")) for x, y in
> commands.iteritems()]
>
> --jo
>
>
>
>
> 2012/10/4 Bradley Gabe <[email protected]>
>
>> AddCallbackItem
>
>
>

Reply via email to