Formation Logo

Getting Started

  • Installation
  • Quick Start
  • The Studio
  • Component Pane
  • Component Tree
  • Canvas
  • Menus
    • Adding Menu Items
    • Repositioning Menu Items
    • Previewing Menus
    • Styling Menu Items
    • Connecting a menu to a widget
  • Variables
  • Callbacks
  • Events
  • Themes
  • Custom Widgets
  • Custom Properties

Examples:

  • Simple Calculator

API reference

  • Formation
  • Hoverset
  • Studio
Formation
  • Menus
  • View page source

Menus

Formation provides a simple way to create menus. You can add a menu by dragging the menu component from the components pane to the designer. The menu component will be in the legacy (tk) group under Container.

Note

Note. The menu component is a non-visual component and will only be visible in the component tree.

_images/menu_component.png

Menu Component

Adding Menu Items

Once the menu has been added and selected in the component tree, the Menu section will be displayed in the components pane.

_images/menu_component_group.png

Menu Component Group

The menu allows addition of 5 types of sub-items:

  • Command - A menu item that will execute a command when clicked.

  • Cascade - A menu item that will display a submenu when clicked.

  • Checkbutton - A menu item that will toggle a checkmark when clicked.

  • Radiobutton - A menu item that will toggle a radio button when clicked.

  • Separator - A separator line between menu items.

With the menu selected, click on the item type you want to add. The item will be added to the menu

_images/menu_add_items.png

Menu Items Added

To add items to a cascade menu, select the cascade item in the component tree and click on the item type you want to add from the component pane.

Tip

You can add items to multiple cascade menus at the same time by selecting multiple cascade items in the component tree.

_images/menu_add_items_cascade.png

Cascade Menu Items Added

Repositioning Menu Items

To reposition a menu item, select the item in the component tree and drag it to the desired position. You can also reposition multiple items at the same time this way.

_images/menu_item_reposition.png

Repositioning Menu Items

Previewing Menus

To preview the menu, right-click on the menu component in the component tree and select Preview. You can also preview a specific cascade menu by right-clicking on the cascade item in the component tree and selecting Preview.

_images/menu_preview.png _images/menu_cascade_preview.png

Styling Menu Items

You can style the menu items by selecting the item in the component tree and changing the properties in the Menu Item section of the style pane. When multiple items are selected, the properties that are common to all the selected items will be displayed in the style pane.

_images/menu_stylepane.png

Styling Menu Items

You can also style the underlying cascade menu in the Cascade Menu Attributes section of the style pane.

_images/menu_cascade_stylepane.png

Styling Cascade Menu

Connecting a menu to a widget

The menu can be connected to a widget by setting the menu attribute of the widget to the menu component. Widgets that support menus are:

  • Tk

  • Toplevel

  • Menubutton

Setting the menu attribute of toplevel widget will create a menubar.

_images/menu_attribute.png

Menu attribute

Note

The menu component must be a descendants of the widget for the menu to be displayed. When setting the menu attribute of a widget, only menus that are descendants of the widget will be displayed on the dropdown.

Previous Next

© Copyright 2019-2025, Emmanuel Obara.

Built with Sphinx using a theme provided by Read the Docs.