sugar4.graphics.radiopalette
Radio palette provides a way to create radio button groups within palettes, allowing users to select one option from multiple choices.
This implementation modernizes the radio palette system while maintaining compatibility with Sugar’s palette interface patterns.
Example
Create a radio palette with multiple tool options.
from gi.repository import Gtk
from sugar4.graphics.radiopalette import RadioToolsButton, RadioPalette
from sugar4.graphics.toolbutton import ToolButton
# Create the main radio button
radio_button = RadioToolsButton(
icon_name='tool-brush',
tooltip='Drawing Tools'
)
# Create the palette
palette = RadioPalette(primary_text='Drawing Tools')
radio_button.set_palette(palette)
# Add tool options
brush_btn = ToolButton(icon_name='tool-brush')
palette.append(brush_btn, 'Brush')
pen_btn = ToolButton(icon_name='tool-pen')
palette.append(pen_btn, 'Pen')
Attributes
Classes
A toolbar button that shows a radio palette when clicked. |
|
A toolbar button that shows a radio palette when clicked. |
|
A palette containing radio button options. |
Module Contents
- class sugar4.graphics.radiopalette.RadioMenuButton(**kwargs)[source]
Bases:
sugar4.graphics.toolbutton.ToolButtonA toolbar button that shows a radio palette when clicked.
- class sugar4.graphics.radiopalette.RadioToolsButton(**kwargs)[source]
Bases:
RadioMenuButtonA toolbar button that shows a radio palette when clicked.
- class sugar4.graphics.radiopalette.RadioPalette(**kwargs)[source]
Bases:
sugar4.graphics.palette.PaletteA palette containing radio button options.
- append(button, label)[source]
Add a button option to the radio palette.
- Parameters:
button – The ToolButton to add to the radio group
label – The label text for this option