Hello,
i have a simple button which shows a property on click. Now i want to change the property of that button accordingly to the value i (as a user) set the property to. Because currently if i change the property to “5” and click on that button again, the property value is not “5” but still “0” (so the default value). Do you have any ideas how i can set the property value to the value i selected?
My Panel:
class Panel(bpy.types.Panel):
bl_label = "Property Example"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "render"
def draw(self, context):
layout = self.layout
col = layout.column()
col.operator("my.operator", text="Click to open Operator").rndValue = 0 #add Button
My Operator which shows the property:
class Operator(bpy.types.Operator):
bl_idname = "my.operator"
bl_label = "My Operator"
rndValue = bpy.props.IntProperty(name="rndValue",description="it is a rndValue", default=0, min=0, max=5)
def execute(self,context):
self.report({'INFO'}, str(self.rndValue))
return {'FINISHED'}
def invoke(self,context,event):
wm = context.window_manager
return wm.invoke_props_dialog(self)
def draw(self,context):
layout = self.layout
col = layout.column()
col.prop(self,"rndValue")