Change scene values in custom panel on the fly

Hi,

I have two scene values (From, To)

 bpy.types.Scene.my_from= bpy.props.IntProperty(name='From',min=0,max= 300000, default= 1)
    bpy.types.Scene.my_to= bpy.props.IntProperty(name='To',min=0,max= 300000, default= 250)

And I want avoid From > To, so I added this in draw method:


            Draw method
               ...
               ...
            row.prop(scene,"my_from")
            row.prop(scene,"my_to")
            
            if scene.my_from > scene.my_to:
		scene.my_to = scene.my_from

The problem is that it’s not possible in this context, how can I do this?

Thanks,
Antonio

You have to make a slight hack using update= methods.


def update_to(self, context):
    if self.my_from > self.my_to:
        self.my_to = self.my_from

bpy.types.Scene.my_from= bpy.props.IntProperty(name='From',min=0,max= 300000, default= 1)
bpy.types.Scene.my_to= bpy.props.IntProperty(name='To',min=0,max= 300000, default= 250, update=update_to)

Something like this could work.

Ah, ok!

I have used update method before…but as I come from other languages than python I did not think about this way to do it.

Thanks Linusy!

This kind of callback is actually a Blender Python feature, not standard py.