Hi everyone,
can you please explain to me why I can declare and use Properties inside of an bpy.types.Operator, but not when I’m using a bpy.types.Panel (using Blender 2.59) ?
For example, this does not display the property, printing an error:
import bpy
from bpy.props import *
class test (bpy.types.Panel):
bl_idname = "tes.t"
bl_label = "TestTest"
bl_region_type = "TOOLS"
bl_space_type = "VIEW_3D"
#properties
gamma = IntProperty(name="", min=1, max=100, default=10, description="Property Test Value")
def draw (self, context):
layout = self.layout
layout.label("Now follows the property")
row = layout.row(align=True)
row.prop(self, 'gamma')
def register():
bpy.utils.register_class(test)
def unregister():
bpy.utils.unregister_class(test)
if __name__ == "__main__":
register()
But in contrast, this works:
import bpy
from bpy.props import *
class test (bpy.types.Operator):
bl_idname = "tes.t"
bl_label = "TestTest"
bl_description = "Operator Description"
bl_options = {'REGISTER', 'UNDO'}
#properties
gamma = IntProperty(name="", min=1, max=100, default=10, description="Property Test Value")
def draw (self, context):
layout = self.layout
layout.label("Now follows the property")
row = layout.row(align=True)
row.prop(self, 'gamma')
def execute(self, context):
print ("executing ...")
return {'FINISHED'}
def register():
bpy.utils.register_class(test)
def unregister():
bpy.utils.unregister_class(test)
if __name__ == "__main__":
register()