如何创建 UI“输入字段”在面板中(3D Blender 2.55)?

发布于 2024-10-04 01:02:28 字数 1303 浏览 7 评论 0原文

我正在尝试创建自己的面板(在 Blender 2.55 中),这将帮助我修改/创建对象。

我尝试过以下示例:

import bpy

class OBJECT_PT_My_Panel(bpy.types.Panel):
    bl_label = "My Panel Test 1"
    bl_region_type = "WINDOW"
    bl_space_type = "PROPERTIES"
    bl_context = "object"

    height = bpy.props.IntProperty(attr="height")

    def draw(self, context):
        layout = self.layout

        row = layout.row()
        row.prop(self, "height")

但它失败了:(

控制台:

rna_uiItemR:找不到属性:OBJECT_PT_My_Panel.height

这也失败:

import bpy

class OBJECT_PT_My_Panel(bpy.types.Panel):
    bl_label = "My Panel Test 1"
    bl_region_type = "WINDOW"
    bl_space_type = "PROPERTIES"
    bl_context = "object"

    _height = 1

    def height_getter(self):
        return self._height

    def height_setter(self, value):
        self._height = value

    height = property(fget = height_getter, fset = height_setter)

    def draw(self, context):
        layout = self.layout

        row = layout.row()
        row.prop(self, "height")

控制台:

rna_uiItemR:找不到属性:OBJECT_PT_My_Panel.height

我找到的所有示例都使用现有属性,例如 object.name、object.location 等。

我找不到任何相关文档。 我能做些什么?

谢谢,

阿米尔。

I'm trying to create my own panel (in Blender 2.55), that will help me modify/create objects.

I've tried the following example:

import bpy

class OBJECT_PT_My_Panel(bpy.types.Panel):
    bl_label = "My Panel Test 1"
    bl_region_type = "WINDOW"
    bl_space_type = "PROPERTIES"
    bl_context = "object"

    height = bpy.props.IntProperty(attr="height")

    def draw(self, context):
        layout = self.layout

        row = layout.row()
        row.prop(self, "height")

But it fails :(

Console:

rna_uiItemR: property not found: OBJECT_PT_My_Panel.height

This one also fails:

import bpy

class OBJECT_PT_My_Panel(bpy.types.Panel):
    bl_label = "My Panel Test 1"
    bl_region_type = "WINDOW"
    bl_space_type = "PROPERTIES"
    bl_context = "object"

    _height = 1

    def height_getter(self):
        return self._height

    def height_setter(self, value):
        self._height = value

    height = property(fget = height_getter, fset = height_setter)

    def draw(self, context):
        layout = self.layout

        row = layout.row()
        row.prop(self, "height")

Console:

rna_uiItemR: property not found: OBJECT_PT_My_Panel.height

All the examples that I've found, are using existing properties like object.name, object.location etc..

I couldn't find any related documentation.
What can i do?

Thanks,

Amir.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青衫负雪 2024-10-11 01:02:28

您的问题可能已经解决,但如果没有解决,此链接可能会对您有所帮助。

代码片段。 Blender 2.5x 中的 Python 脚本简介
http://blenderartists.org/forum/showthread.php?t=193908

希望有帮助

Your problem may have already been solved, but if not this link may help you.

Code snippets. Introduction to Python scripting in Blender 2.5x
http://blenderartists.org/forum/showthread.php?t=193908

Hope that helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文