Adding a User Interface to ChatGPT with BeeWare — Part 3

David Such
8 min readJan 28, 2024

In this part we will talk about configuring menus in BeeWare, particularly adding separators, sub-menus, and a recently opened file list. We also look at an app exit handler, to remind users to save their work before leaving, and using your own modules. There are a some things that weren’t immediately obvious to us even if they are mentioned in the documentation.

Figure 1. Cyber Bee [Image Credit: DALL-E]

Configuring “Advanced” Menus in BeeWare

This section is only relevant for desktop applications (macOS, Windows, or Linux), so feel free to jump ahead if you are working on a mobile app.

Menu Separators

Generally, the menu setup stuff is pretty well explained. Check out the Command documentation, or the example on GitHub, or Part 1 of this series where we introduced menus. What was subsequently causing us some grief, was how to you position a separator (Figure 2) within your menu?

Figure 2. Menu with Separators

The key to adding separators, is use of the section parameter in Group (Figure 3). All the commands in the same Group and section will be put together; commands that are in the same Group but a different section will have a separator between the sections.

Figure 3. Extract from Toga Documentation on Group

For example, we wanted to add a separator line in the Help menu. Our command definition to achieve this is:

help_cmd = toga.Command(
self.help_action,
text='Copy Editor Help',
section=1,
group=toga.Group.HELP
)

Sub-Menus

What about if you want to add a sub-menu (Figure 4)? To do this, you first create a sub-menu Group and allocate the parent parameter to the menu Group. For example:

--

--

David Such

Reefwing Software · Embedded Systems Engineer · iOS & AI Development · Robotics · Drones · Arduino · Raspberry Pi · Flight Control