Page MenuHome

Popup dialog does not redraw updated labels
Closed, ResolvedPublic

Description

Blender 2.77 linux64

In this scenario, the main operator popup display another operator, also calling using invoke_props_dialog, which update a property displayed as label in the main popup. It seems there is no redraw triggered after validating the second popup.

import bpy

bpy.types.Scene.myInt = bpy.props.IntProperty()


class Increment(bpy.types.Operator):

    bl_idname = "test.increment"
    bl_label = "Increment"
    bl_options = {'REGISTER', 'UNDO'}
    
    value = bpy.props.IntProperty(default=10)  
    
    def invoke(self, context, event):
        return context.window_manager.invoke_props_dialog(self, width=200)

    def execute(self, context):
        context.scene.myInt += self.value
        context.area.tag_redraw()    
        return {'FINISHED'}



class Dialog(bpy.types.Operator):
    bl_idname = "ui.propsdialog"
    bl_label = "Props Dialog"
    bl_options = {'REGISTER', 'UNDO'}

    def check(self, context):
        return True

    def draw(self, context):
        scn = context.scene
        layout = self.layout
        row = layout.row()
        row.label(str(scn.myInt))
        row.operator('test.increment')

    def execute(self, context):
        return {'FINISHED'}

    def invoke(self, context, event):
        return context.window_manager.invoke_props_dialog(self)


bpy.utils.register_module(__name__)

bpy.ops.ui.propsdialog('INVOKE_DEFAULT')

It work correctly if the same draw function is used in a panel:

class PANEL(bpy.types.Panel):
    bl_category = "TEST"
    bl_label = "Tst"
    bl_space_type = "VIEW_3D"
    bl_region_type = "TOOLS"

    def draw(self, context):
        scn = context.scene
        layout = self.layout
        row = layout.row()
        row.label(str(scn.myInt))
        row.operator('test.increment')