在搅拌机用C或Python创建对话框

问题描述 投票:0回答:3

如何使一个对话框(三个选项像戒烟/确定/取消)在搅拌器和处理文本通过蟒蛇进入或C.我无法找到任何这很好的教程。任何帮助....?

blender blender-2.61 blender-2.50 blender-2.49 blender-2.67
3个回答
1
投票

一个快速和肮脏的方法是使用zenity命令(默认情况下应在任何蟒蛇分布包括在内)。试试这个简单的例子脚本,它工作在我的Blender 2.69在Ubuntu 14.04。

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 --help


0
投票

搅拌器不提供之类的东西对话。

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


0
投票
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任何人。同时我也想弄清楚这一点。

© www.soinside.com 2019 - 2024. All rights reserved.