首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Blender中使用C或Python创建对话框

在Blender中使用C或Python创建对话框
EN

Stack Overflow用户
提问于 2013-10-22 14:19:55
回答 3查看 2.3K关注 0票数 0

如何在blender中创建一个对话框(三个选项,如quit/OK/Cancel),并处理通过python或C输入的文本。我找不到任何关于这方面的好教程。有什么帮助吗...?

EN

回答 3

Stack Overflow用户

发布于 2015-03-25 17:30:00

一个简单快捷的方法是使用zenity命令(默认情况下应该包含在任何python发行版中)。尝试这个简短的示例脚本,它可以在Ubuntu 14.04上的my Blender 2.69中运行。

代码语言:javascript
复制
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 --帮助

票数 1
EN

Stack Overflow用户

发布于 2013-10-24 15:31:36

blender不提供像对话框这样的东西。

回答有关外部模块的This previous question可能会有所帮助。

票数 0
EN

Stack Overflow用户

发布于 2013-10-25 13:04:43

代码语言:javascript
复制
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中插入按钮,任何认识此内容的人都可以尝试发布答案。同时,我也在尝试解决这个问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19510381

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档