Popup properties not updating correctly

Hello,

I’m trying to create a popup which contains a number of properties including an EnumProperty which allows a user to select a preset, which when selected should cause the various other properties in the popup to update according to the preset.

import bpy
from bpy.types import Operator
from bpy.props import EnumProperty, FloatProperty, StringProperty, IntProperty
import bpy.utils


def getPresetList(self, context):
    return [
        ('0.0' ,'Preset 0', '0.0'),
        ('1.0', 'Preset 1', '1.0'),
        ('2.0', 'Preset 2', '2.0'),
        ('3.0', 'Preset 3', '3.0'),
        ]


def updateEnumProp(self, context):
    self.floatProp = float(self.enumProp)


class MyDialog(Operator):
    bl_label = "Custom Dialog Operator"
    bl_idname = "cust.dialog"
    bl_options = {'REGISTER', 'UNDO'}


    enumProp = EnumProperty(
        name='Preset',
        items=getPresetList,
        update=updateEnumProp
        )
        
    floatProp = FloatProperty(
        name='Float',
        default=0.01
        )
    
    @classmethod
    def poll(cls, context):
        return True
    
    def invoke(self, context, event):
        wm = bpy.context.window_manager
        return wm.invoke_props_dialog(self)
    
    def execute(self, context):
        print("floatProp: {0}".format(self.floatProp))
        return {'FINISHED'}
    
bpy.utils.register_module(__name__)


if __name__ == '__main__':
    bpy.ops.cust.dialog('INVOKE_DEFAULT')

Now, when I run the above code and select a preset in the dropdown, the value of the FloatProperty UI component is only updated when I hover the mouse over it. I would have hoped that it would be updated as soon as I select a preset from the dropdown. Interestingly enough, when I press the Ok button without hovering the mouse over the Float UI control, the print statement prints out the correct (updated) value for the FloatProperty. So it seems that only the UI isn’t updating correctly.

Can anyone tell me if there’s a way to update the UI as soon as the dropdown value changes?

I don’t think so, the UI is event driven. So a mouse event has to occur for the update event to be processed. This is normal Blender UI operation.

Popups don’t support layout changes, you need to use panels for that. As the names state (invoke_props_popup etc.), they are really just for property input.

Ok thanks for that, I searched high and low and couldn’t find anything and was wondering if it was me doing something wrong. I’ll try looking at using panels instead in that case.