python - Blender Python:取消运算符而不关闭 props_dialog
问题描述
我正在开发一个 Blender Add-on,而 Blender Operators 的默认“Invoke -> Execute -> Close”流程对我来说并不是最友好的。我很确定我错过了一些东西。
我有一个layout_props_dialog
:
当用户单击“确定”时,我需要在允许操作员运行之前验证一些字段。但是,CANCELLED
从该execute
方法返回会关闭对话框,这是一种糟糕的 UX 模式。
我知道模态,但这似乎不是它的常见情况,因为在正确填写表格后,动作(添加固定装置)只发生一次。
# DMX_Fixture_AddEdit contains prop declarations and the draw method.
class DMX_OT_Fixture_Add(DMX_Fixture_AddEdit, Operator):
bl_label = "DMX: Add Fixture"
bl_idname = "dmx.add_fixture"
bl_options = {'REGISTER','UNDO'}
def execute(self, context):
scene = context.scene
dmx = scene.dmx
if (self.name in bpy.data.collections):
return {'CANCELLED'}
if (not len(self.profile)):
self.report({'ERROR'}, "No GDTF Profile selected.")
return {'CANCELLED'}
if (not len(self.mode)):
self.report({'ERROR'}, "No DMX Mode selected.")
return {'CANCELLED'}
for i in range(self.units):
dmx.addFixture(self.name+" "+str(i+1), self.profile, self.universe, self.address, self.mode, list(self.gel_color))
return {'FINISHED'}
def invoke(self, context, event):
self.name = "Fixture "+str(len(context.scene.dmx.fixtures)+1)
self.units = 1
DMX_Fixture_AddEdit.profile_list_items = []
wm = context.window_manager
return wm.invoke_props_dialog(self)
所以,简而言之,我需要取消执行方法而不关闭layout_prop_dialog
. 我也尝试过RUNNING_MODAL
,PASS_THROUGH
和INTERFACE
. 所有人都表现出相同的行为。
有任何想法吗?
解决方案
推荐阅读
- jquery - 同位素插件:仅当显示 DIV 时才在 DIV 上执行 ajax
- python - 如何使用列表列表和元组列表创建字典字典
- django - 如何确定我的 Django 应用程序需要什么 AWS RDS 实例?
- discord.py - 有多少用户具有特定角色
- python - 脚本需要旧的 tensorflow,许多 GPU。跑到哪里去?
- excel - VBA - 循环多个工作簿并保存到主工作簿时覆盖的单元格
- c# - 我为基于 Selenium SpecFlow 的 Visual Studio 解决方案使用什么项目类型
- swift - 无法预览此文件,应用程序可能已崩溃 -- 输入特定代码行时发生
- javascript - 在 ag-grid 浮动过滤器中键入多个值
- python - (Tkinter)相同的代码 - 没有变化 - 当我运行它时会起作用然后不再起作用吗?绑定回车键功能