[Bf-python] invoke_confirm with custom confirm message?

Dalai Felinto dfelinto at gmail.com
Mon Oct 21 14:05:14 CEST 2013


For the records, I found a workaround/solution.

Basically my operator bl_label is the message I want to ask, and in the ui
I change the displayed text.

bl_label = "Are you sure you want to remove all objects?"
layout.operator("object.delete_all_my", text="Delete All")

I even tried to change the bl_label, but that asserts Blender:

def invoke(self, context, event):
    self.bl_label = "Object: {0}".format(context.active_object.name)
    return context.window_manager.invoke_confirm(self, event)

Assertion failed: (!"setting the bl_label on a non-builtin operator"),
function rna_Operator_bl_label_set, file
/Users/dfelinto/blender/blender-svn/blender/source/blender/makesrna/intern/rna_wm.c,
line 1329.


Anyways, I'm happy with the solution I have now. But I will certainly look
at custom python popup later. Thanks.

Dalai

--
blendernetwork.org/dalai-felinto
www.dalaifelinto.com


2013/10/15 Campbell Barton <ideasman42 at gmail.com>

> Have you looked into using a custom python popup?
>
>
> http://www.blender.org/documentation/blender_python_api_2_69_1/bpy.types.WindowManager.html#bpy.types.WindowManager.popup_menu
>
> On Mon, Oct 14, 2013 at 2:25 PM, Dalai Felinto <dfelinto at gmail.com> wrote:
> > Hi,
> >
> > First a question, is it possible to have a custom message when I use
> > invoke_confirm?
> >
> > Apparently there is not, and the not-so-nice alternative is to use
> > invoke_props_dialog and have my own draw() function.
> >
> > Assuming that it's not possible, would that be a nice addition?
> > I think I can do that myself, but I would like to get 'design approval'
> > first.
> >
> > My proposal is to do:
> > context.window_manager.invoke_confirm(self, event, text="Are you sure you
> > want to do whatever with object \"{0}\"".format(context.object))
> >
> > I may do it anyways for a project I'm working on. But it would be nicer
> if
> > it can be incorporated back in Blender.
> >
> > (also I may not do it any soon, so if anyone wants to do first, be my
> guest)
> >
> > Cheers,
> > Dalai
> > --
> > blendernetwork.org/dalai-felinto
> > www.dalaifelinto.com
> >
> > _______________________________________________
> > Bf-python mailing list
> > Bf-python at blender.org
> > http://lists.blender.org/mailman/listinfo/bf-python
> >
>
>
>
> --
> - Campbell
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20131021/1d5d1c23/attachment.html>


More information about the Bf-python mailing list