beeware / beeware/toga

Add a SegmentedButton widget

Open
#4,470 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
5.4k
Forks
827
Avg merge
15h 39m
Merged PRs (30d)
40

Description

### What is the problem or limitation you are having?

Many platforms provide a widget that presents as a single horizontal button, where different segments can be selected - for example:

Image

Toga does not currently have a widget for this type of construct.

### Describe the solution you'd like

Toga should gain a new SegmentedButton widget. The API for this button will be almost identical to Selection, except that it will also have a `multiple_selection` option (with semantics matching Table's handling of selections).

Suggested implementations:

* Android: [Segmented button](https://m3.material.io/m3/pages/segmented-buttons/overview) (or a [button group](https://m3.material.io/components/button-groups/overview) - Button Group is the current suggested approach, but was only introduced in May 2025; availability may be a concern)
* GTK3: [GTKButtonBox](https://docs.gtk.org/gtk3/class.ButtonBox.html)
* GTK4: [https://docs.gtk.org/gtk4/class.ToggleButton.html]
* Qt: [QButtonGroup](https://doc.qt.io/qtforpython-6/PySide6/QtWidgets/QButtonGroup.html)
* macOS: [NSSegmentedControl](https://developer.apple.com/documentation/appkit/nssegmentedcontrol?language=objc)
* iOS: [UISegmentedControl](https://developer.apple.com/documentation/uikit/uisegmentedcontrol?language=objc)

GTK4 ToggleButton doesn't appear to support multiple selection - when this occurs, the platform should warn the user on construction, but return the *semantics* of multiple selection (i.e., selection is a list) within a single-selection implementation.

### Describe alternatives you've considered

Don't support this type of widget. However, given the prevalence of this type of widget in practice, that seems undesirable.

### Additional context

This is functionally equivalent to a Radio Button, but the rendering is easier because it's guaranteed to be on a single line (rather than requiring a grouping syntax).

There may be an opportunity to have a common base class implementation for SegmentedButton and Selection - any opportunity to provide a common base class should be taken.

There will be be overlap on iOS in the updated implementation of OptionContainer (See #4297) - a SegmentedControl is the basis for building a container based on that selection.

Contributor guide

Open the contributing guide

Research direction

Start by reading Toga's existing Selection and Table APIs, then inspect their platform implementations and the related OptionContainer work in #4297. Compare the suggested Android, GTK, Qt, macOS, and iOS controls and determine how their selection behavior maps to the proposed API. Done means a consistent SegmentedButton API and supported platform implementations with tests for single and multiple selection semantics.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, ios, macos, python
Domain
desktop, frontend, mobile
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.