如何在blender中创建一个对话框(三个选项,如quit/OK/Cancel),并处理通过python或C输入的文本。我找不到任何关于这方面的好教程。有什么帮助吗...?
发布于 2015-03-25 17:30:00
一个简单快捷的方法是使用zenity命令(默认情况下应该包含在任何python发行版中)。尝试这个简短的示例脚本,它可以在Ubuntu 14.04上的my Blender 2.69中运行。
import bpy # bpy or bge does not matter
import subprocess as SP
# call an OS subprocess $ zenity --entry --text "some text"
# (this will ask OS to open a window with the dialog)
res=SP.Popen(['zenity','--entry','--text',
'please write some text'], stdout=SP.PIPE)
# get the user input string back
usertext=str(res.communicate()[0][:-1])
# adjust user input string
text=usertext[2:-1]
print("I got this text from the user: %s"%text)有关更复杂的对话框,请参阅zenity --帮助
发布于 2013-10-24 15:31:36
blender不提供像对话框这样的东西。
回答有关外部模块的This previous question可能会有所帮助。
发布于 2013-10-25 13:04:43
class DialogOperator(bpy.types.Operator)
bl_idname = "object.dialog_operator"
bl_label = "Save Before You QUIT!"
def execute(self, context):
message = " You didn't saved yet "
self.report({'INFO'}, message)
print(message)
return {'FINISHED'}
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self)
class DialogPanel(bpy.types.Panel)
bl_label = "Dialog"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
def draw(self, context):
self.layout.operator("object.dialog_operator")但这仅用于创建对话框窗口。在此之后,必须在此code.If中插入按钮,任何认识此内容的人都可以尝试发布答案。同时,我也在尝试解决这个问题。
https://stackoverflow.com/questions/19510381
复制相似问题