如何创建 UI“输入字段”在面板中(3D Blender 2.55)?
我正在尝试创建自己的面板(在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的问题可能已经解决,但如果没有解决,此链接可能会对您有所帮助。
代码片段。 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