Skip to content

Tutorial EzLang RadioButton

ddbnl edited this page Aug 29, 2022 · 1 revision

A radio button is a clickable switch that can be either on or off. The difference with the checkbox is that the radio button is meant to be part of a group (which can be set using the 'group' EzLang property). Only one radio button can be active in a group, so when the user activates one, the others will become inactive. To make the radio buttons functional, bind 'on_value_change' callbacks to each button in the group. More info on callbacks is given in the scheduler chapter, but an example will be given here. Only the radio button that became active will receive an 'on_value_change' event.

The look of the radio button can be altered through the 'active_symbol' and 'inactive_symbol' properties.

Regular radio button group

// These are regular radio buttons
- Layout:
    mode: box
    orientation: horizontal
    auto_scale: true, true
    padding_bottom: 1
    border: true
    - RadioButton:
        active: true
        group: regular
        fg_color: yellow
        selection_order: 1
    - Label:
        text: Option 1
        auto_scale: true, true
        padding_right: 1
    - RadioButton:
        group: regular
        fg_color: yellow
        selection_order: 2
    - Label:
        text: Option 2
        auto_scale: true, true
        padding_right: 1
    - RadioButton:
        group: regular
        fg_color: yellow
        selection_order: 3
    - Label:
        text: Option 3
        auto_scale: true, true

radio_button_1

Styled radio button group

// These are styled radio buttons
- Layout:
    mode: box
    orientation: horizontal
    auto_scale: true, true
    padding_bottom: 1
    border: true
    - RadioButton:
        active: true
        group: styled
        fg_color: yellow
        selection_order: 4
        active_symbol: 
        inactive_symbol: x
    - Label:
        text: Option 1
        auto_scale: true, true
        padding_right: 1
    - RadioButton:
        group: styled
        fg_color: yellow
        selection_order: 5
        active_symbol: 
        inactive_symbol: x
    - Label:
        text: Option 2
        auto_scale: true, true
        padding_right: 1
    - RadioButton:
        group: styled
        fg_color: yellow
        selection_order: 6
        active_symbol: 
        inactive_symbol: x
    - Label:
        text: Option 3
        auto_scale: true, true

radio_button_2

Disabled radio button group

// These are Disabled radio buttons
- Layout:
    mode: box
    orientation: horizontal
    auto_scale: true, true
    padding_bottom: 1
    border: true
    - RadioButton:
        active: true
        group: disabled
        fg_color: yellow
        selection_order: 7
        disabled: true
    - Label:
        text: Option 1
        auto_scale: true, true
        padding_right: 1
    - RadioButton:
        group: disabled
        fg_color: yellow
        selection_order: 8
        disabled: true
    - Label:
        text: Option 2
        auto_scale: true, true
        padding_right: 1
    - RadioButton:
        group: disabled
        fg_color: yellow
        selection_order: 9
        disabled: true
    - Label:
        text: Option 3
        auto_scale: true, true

radio_button_3

Radio button group with callbacks

// These radio buttons with on_value_change callbacks, they change the label below them
- Layout:
    mode: box
    orientation: vertical
    auto_scale: true, true
    border: true
    - Layout:
        mode: box
        orientation: horizontal
        auto_scale: true, true
        padding_bottom: 1
        - RadioButton:
            id: my_radio_1
            active: true
            group: callback
            fg_color: yellow
            selection_order: 10
        - Label:
            text: Option 1
            auto_scale: true, true
            padding_right: 1
        - RadioButton:
            id: my_radio_2
            group: callback
            fg_color: yellow
            selection_order: 11
        - Label:
            text: Option 2
            auto_scale: true, true
            padding_right: 1
        - RadioButton:
            id: my_radio_3
            group: callback
            fg_color: yellow
            selection_order: 12
        - Label:
            text: Option 3
            auto_scale: true, true
    - Label:
        text: Choice: Option 1
        id: my_label
        auto_scale: true, true

radio_button_4

Continue

The general tutorial continues with: EzLang Dropdown.

Tutorial Tutorial-Project-Structure
  Minimal example
EzLang
  EzLang basics
  EzLang Templates
  Ezlang Layout modes
   EzLang Box mode layouts
   EzLang Stack mode layouts
   EzLang Table mode layouts
   EzLang Float mode layouts
   EzLang Tab mode layouts
   EzLang Screen mode layouts
   EzLang Layout Scrolling
   EzLang Layout Views
  EzLang Widget overview
   EzLang Label
   EzLang Text Input
   EzLang Button
   EzLang Checkbox
   EzLang Radio button
   EzLang Dropdown
   EzLang Slider
   EzLang Canvas
  EzLang Property Binding
  EzLang Sizing
   EzLang Size hints
   EzLang Auto scaling
   EzLang Maths Sizing
   EzLang Manual Sizing
  EzLang Positioning
   EzLang Layout Mode Positioning
   EzLang Position Hints
   EzLang Position Maths
   EzLang Manual Position
   EzLang Adjusting Position
  EzLang Keyboard Selection
Scheduler
  Widget States and the State Tree
  The Scheduler Object
  Managing callbacks
   Callback Structure
   Callback Configs
   Callback: On keyboard enter
   Callback: On Left Mouse Click
   Callback: On Press
   Callback: On Select
   Callback: On Deselect
   Callback: On Right Mouse Click
   Callback: On Hover
   Callback: On Drag
   Callback: On Scroll Up
   Callback: On Scroll Down
   Callback: On Value Change
   Callback: Custom Key Binds
   Callback: Global Key Binds
   Callback: Property Binds
  Tasks
   Scheduled Single Exectution Tasks
   Scheduled Recurring Tasks
   Threaded Tasks
  Custom Properties
  Modals
  Programmatic Widgets
  Updating widgets
  Managing selection
Default global (key)binds
Performance
ExamplesLayout: Box Mode Nested
Layout: Box Mode Size Hints
Layout: Stack Mode
Layout: Table Mode Dynamic
Layout: Table Mode Static
Layout: Float Mode Manual
Layout: Float Mode Position hints
Layout: Screen Mode
Layout: Tab Mode
Layout: Scrolling
Layout: Views
Widget: Label
Widget: Text input
Widget: Button
Widget: Checkbox
Widget: Radio Button
Widget: Dropdown
Widget: Slider
Widget: Progress Bar
Widget: Canvas
Scheduler: Schedule Once
Scheduler: Schedule Once Callback
Scheduler: Schedule Recurring
Scheduler: Schedule Recurring Callback
Scheduler: Threaded Task State Tree
Scheduler: Threaded Task Custom Property
Scheduler: Create Widgets
Scheduler: Modal Popup
Reference Widgets
  Common Properties
  Label
  Text Input
  Button
  Checkbox
  Radio button
  Dropdown
  Slider
  Canvas
Scheduler
  Schedule once
  Schedule Recurring
  Schedule Threaded
  Cancel Task
  Cancel Recurring Task
  Create Widget
  Remove Widget
  Select Widget
  Deselect Widget
  Update Widget
  Force Redraw
  Open Modal
  Dismiss Modal
  Bind Global Key
  Remove Global Key
  Clear Global Keys
  Bind Property
  Create Custom Properties
  Get Property
  Get Property Mut
  Overwrite Callback Config
  Update Callback Config
  Exit
Clone this wiki locally