AmesimKnowledge

The Plot Python API environment in detail

Add entry in a menu or a toolbar

If you want to provide a specific feature inside the plot widget, you can add an entry in a menu or a toolbar. This section shows how to do that.

Figure 12: Custom action in menu and toolbar

The MenusAndToolBars object

All the interactions with menus and toolbars are done through the MenusAndToolBars object. You can get it from the plot widget like this:

Copy


# Access to the MenusAndToolbars object
entries = widget.menusAndToolBars()

You can display the menu bar like this:

Copy


# Show the menu bar
entries.setMenuBarVisible(True)

Menus

To access to a specific menu, you need to know its name. Use the function allMenusNames to obtain the names of all available menus. Then you can add an action like this:

Copy


# Get the "view" menu
menu = entries.getMenu("view")

# Add a separator
menu.addSeparator()

# Add the custom action
menu.addAction(customAction)

Toolbars

To access to a specific toolbar, you need to know its name. Use the function allToolBarsNames to obtain the names of all available toolbars. Then you can add an action like this:

Copy


# Get the "view" toolbar
toolbar = entries.getToolBar("view")

# Add a separator
toolbar.addSeparator()

# Add the custom action
toolbar.addAction(customAction)

Source: https://docs.sw.siemens.com/en-US/doc/254352342/PL20250521841123434.amesim_collection.Plots_Python_API/xid1204686 · retrieved 2026-07-17