How do you load an Editor Utility Widget with Python

Hello Everyone,

I have a editor utility widget blueprint that I need to open via python. I have managed to get the blueprint generated class of the widget and then the class default object from that, but when I use the EditorUtilityWidget.run() command nothing happens.

widget_generated_class = unreal.load_object(None, ‘Path/Utility_Widget.Utility_Widget_C’)
class_default_object = unreal.get_default_object(widget_generated_class)
unreal.EditorUtilityWidget.run(class_default_object)

According to the docs I’m feeding it the correct object. https://docs.unrealengine.com/en-US/PythonAPI/class/EditorUtilityWidget.html

I just want to get the window for the editor utility to open, the same as if you right clicked on the blueprint “Run Editor Utility Widget”.

Thanks in advance!

Rob

I used this to execute widget from a python menu:

unreal.EditorUtilitySubsystem().spawn_and_register_tab(unreal.EditorAssetLibrary.load_asset("/path_to_your_widget"))

2 Likes

@Il_Berna That worked, thank you so much!

I knew I was loading the asset but not spawning it! That is the perfect solution, it seems to handle multiple instances of a window correctly as well, by only making one current instance.

For anyone interest you need to pass the path of the Blueprint widget but you need to append .nameOfWidget_C at the end as it wants the class object not the asset object.

e.g.

“/path_to_your_widget/widgetname.widgetname_C”

Amazing stuff :slight_smile:

Thank you.

1 Like