> 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/adding-a-drop-down-menu.md).

# Adding a Drop Down Menu

## For Most Editor Menus

With a valid menu loaded, in most sections of the Editor we can use the following code to add our own dropdown menu:

<pre class="language-python"><code class="lang-python">ToolMenus= unreal.ToolMenus.get()
<strong>menu = ToolMenus.find_menu("LevelEditor.MainMenu")
</strong>
dropdown_menu = menu.add_sub_menu(
    owner="custom_owner", # this is used to delete menus later if needed
    section_name="",
    name="DemoTools",
    label="Demo Tools"
)
ToolMenus.refresh_all_widgets()
</code></pre>

This will add a new `Demo Tools` entry to the top bar of the Editor:

<figure><img src="/files/tyz9sE8qp979sznF07tS" alt=""><figcaption></figcaption></figure>

The `name` argument is used for the programmatic name, used for the menu path:

```
LevelEditor.MainMenu.DemoTools
```

The `label` argument is what actually gets displayed in the UI

The `owner` argument is useful for if we ever want to remove our menu:

```python
ToolMenus.unregister_owner_by_name("custom_owner")
```

***

## For ToolBar Menus (before 5.5)

{% hint style="info" %} <mark style="color:yellow;">Note</mark>: In UE 5.5 Epic provided better support for the above code style to work with ToolBars, this is for UE 5.0-5.4
{% endhint %}

For ToolBar Menus such as Sequencer, the above code does not work before UE 5.5. Instead, we need to create our own Toolbar Dropdown Menu Class and use it instead.

### The Dropdown Class

This is using concepts covered in the Menu Class section, but here is a minimal class that will let us add a Dropdown Menu to Sequencer:

```python
@unreal.uclass()
class ToolbarDropdownMenu(unreal.ToolMenuEntryScript):
    """Drop down menu class that can be used with Sequencer"""

    def __init__(self, menu, name, label, section="", tooltip=""):
        super().__init__()
        self.data.advanced.entry_type = unreal.MultiBlockType.TOOL_BAR_COMBO_BUTTON
        parent_menu = menu.get_editor_property("menu_name")
        self.init_entry("custom_owner", parent_menu, section, name, label, tooltip)
        menu.add_menu_entry_object(self)
```

They key to this class is that its `entry_type` has been updated to `TOOL_BAR_COMBO_BUTTON`. This will allow us to add it to Sequencer and other Tool Bars&#x20;

### Using Our Custom Class

With our <mark style="color:green;">ToolbarDropdownMenu</mark> class initialized, we can run the following to add our Dropdown Menu to Sequencer:

```python
ToolMenus = unreal.ToolMenus.get()
menu = ToolMenus.find_menu("Sequencer.MainToolBar")

dropdown_menu = ToolbarDropdownMenu(
    menu=menu,
    name="DemoTools",
    label="Demo Tools"
)
ToolMenus.refresh_all_widgets()
```

This will add a new `Demo Tools` entry to Sequencer's Toolbar:

<figure><img src="/files/I8IKf6Pn6nP5Z9NTXHfm" alt=""><figcaption></figcaption></figure>
