1
$\begingroup$

I have a modal operator that invokes itself and is called from an AddonPreferences PT. I have been trying to scale_x without success. A row.scale_x works within the size of the entire modal, it is 3.35" on my screen. None of the options I've tried, examples below, have changed the width of the modal itself.

def draw(self, context):
    layout = self.layout
    scene = context.scene
    layout.scale_x = 20
    
    row = layout.box()
    row.scale_x = 20
    layout.label(text="scaled_x_space?")
    row = layout.row()
    row.scale_x = 20
    layout.label(text="scaled_x_space?")
    split = layout.split()
    col1 = split.column()
    col1.scale_x = 20
    layout.label(text="scaled_x_space?")

I'm not really trying to scale by a factor of 20, I was using that number just to be sure it wasn't changing by some amount I wasn't noticing.

$\endgroup$
1
$\begingroup$

Just pass a custom width (integer) when calling invoke_props_dialog(operator, width=300) or invoke_popup(operator, width=300). The height is determined dynamically by the size of elements placed onto the props_dialog and there is no option to set it. From the docs:

Parameters

  • operator (Operator) – Operator to call
  • width (int in [0, inf], (optional)) – Width of the popup

Demo based on the code of How to call a confirmation dialog box?

enter image description here

import bpy

class SimplePropConfirmOperator(bpy.types.Operator):
    bl_idname = "my_category.custom_confirm_dialog"
    bl_label = "Do you really want to do that?"

    prop1: bpy.props.BoolProperty()
    prop2: bpy.props.BoolProperty()

    def execute(self, context):
        self.report({'INFO'}, "YES!")
        return {'FINISHED'}

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

    def draw(self, context):
        row = self.layout
        row.prop(self, "prop1", text="Property A")
        row.prop(self, "prop2", text="Property B")

def register():
    bpy.utils.register_class(SimplePropConfirmOperator)

def unregister():
    bpy.utils.unregister_class(SimplePropConfirmOperator)

if __name__ == "__main__":
    register()
    
    # test call
    bpy.ops.my_category.custom_confirm_dialog('INVOKE_DEFAULT') 
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.