> For the complete documentation index, see [llms.txt](https://bkortbus.gitbook.io/unreal-python-recipe-book/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bkortbus.gitbook.io/unreal-python-recipe-book/editor-menus/python-menu-class/editor-utility-widget-launcher.md).

# Editor Utility Widget Launcher

A quick Menu Class to launch Editor Utility Widgets

Expanding off of our base class, let's make a quick class to launch our Editor Utility Widgets!

## Launching an Editor Utility Widget (EUW)

The code to launch an EUW is relatively straight forward, we just need to spawn a tab using the [EditorUtilitySubsystem](https://dev.epicgames.com/documentation/en-us/unreal-engine/python-api/class/EditorUtilitySubsystem?application_version=5.3#unreal.EditorUtilitySubsystem.spawn_and_register_tab):

```python
EditorUtilitySubsystem = unreal.get_editor_subsystem(unreal.EditorUtilitySubsystem)

asset = unreal.load_asset("/Game/Path/To/EUW")
EditorUtilitySubsystem.spawn_and_register_tab(asset)
```

We'll create a generic function to launch an EUW from its asset path:

```python
def launch_editor_utility_widget(asset_path: str):
    """Launch the given utility widget from its asset path"""

    # ensure a valid asset path was provided
    if not isinstance(asset_path, str):
        unreal.log_error(f"The given input is not an asset path: {asset_path}")
        return
    
    if not EditorAssetLibrary.does_asset_exist(asset_path):
        unreal.log_error(f"The given asset path does not exist: {asset_path}")
        return
    
    # open the EUW
    asset = EditorAssetLibrary.load_asset(asset_path)
    EditorUtilitySubsystem.spawn_and_register_tab(asset)

```

***

## The EditorUtilityWidgetMenuTool

With our new function and existing PythonMenuTool base class, this is all we need to declare in our new EUW Launcher class:

```python
@unreal.uclass()
class EditorUtilityWidgetMenuTool(PythonMenuTool):
    """
    menu tool base class to launch specified Editor Utility Widgets
    """
    widget_path = "/Game/editor/utility/widget/path"

    @unreal.ufunction(override=True)
    def execute(self, context):
        """Open the EUW when pressed"""
        launch_editor_utility_widget(self.widget_path)
```

That's all there is to it, on execute it will launch the `widget_path` declared on the class!

***

## Demo Tool

Here's an example tool, the Meta Viewer GUI:

```python
@unreal.uclass()
class MetaViewerTool(EditorUtilityWidgetMenuTool):
    name = "meta_viewer"
    display_name = "Meta Viewer GUI"
    tool_tip = "Launch the Meta Viewer tool"
    widget_path = "/PythonRecipeBook/sample_tools/meta_viewer"
```

This provides a simple menu class setup we can make for each of our first-class Editor Utility Widget tools

<figure><img src="https://368271246-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FStUBkBT2qJGKNkIZ6yc7%2Fuploads%2FqoWUn6JLU1kpKE2BP2sh%2Fimage.png?alt=media&amp;token=2158f7ad-6b6a-47f6-a05a-69e2c0b6ab57" alt="" width="411"><figcaption></figcaption></figure>

Pressing the menu button launches our tool:

<figure><img src="https://368271246-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FStUBkBT2qJGKNkIZ6yc7%2Fuploads%2F2fhYnhNFNr1mD5dgsk0Q%2Fimage.png?alt=media&amp;token=38085ab7-a9f0-4c2c-81e4-963b455e45a9" alt="" width="563"><figcaption></figcaption></figure>
