Web Analytics Made Easy - Statcounter
Skip to content

Radio

Radio Button Element - Used in a group of other Radio Elements to provide user with ability to select only 1 choice in a list of choices.

Radio(
    text,
    group_id,
    default = False,
    disabled = False,
    size = (None, None),
    auto_size_text = None,
    background_color = None,
    text_color = None,
    font = None,
    key = None,
    pad = None,
    tooltip = None,
    change_submits = False,
    enable_events = False,
    visible = True,
    size_px = (None, None)
)

Parameter Descriptions

Name Type Default Description
auto_size_text bool None if True will size the element to match the length of the text
background_color str None color of background. Can be in #RRGGBB format or a color name "black"
change_submits bool False DO NOT USE. Only listed for backwards compat - Use enable_events instead
default bool False Set to True for the one element of the group you want initially selected
disabled bool False set disable state
enable_events bool False Turns on the element specific events. Radio Button events happen when an item is selected
font (str or (str, int[, str]) or None) None specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
group_id Any Groups together multiple Radio Buttons. Any type works
key str or int or tuple or object None Used with window.find_element and with return values to uniquely identify this element
pad (int, int or (int, int),(int,int) or int,(int,int)) or ((int, int),int) or int None Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int)
size (int, int) or (None, None) or int (None, None) (w, h) w=characters-wide, h=rows-high
size_px (int, int) or (None, None) (None, None) w=pixels-wide, h=pixels-high
text str Text to display next to button
text_color str None element's text color. Can be in #RRGGBB format or a color name "black"
tooltip str None text, that will appear when mouse hovers over the element
visible bool True set visibility state of the element

Class Properties

This class has no public properties

Class Methods

 def reset_group
 def update

reset_group

Sets all Radio Buttons in the group to not selected

reset_group()

update

Changes some of the settings for the Radio Button Element. Must call Window.read or Window.finalize prior

Changes will not be visible in your window until you call window.read or window.refresh.

If you change visibility, your element may MOVE. If you want it to remain stationary, use the "layout helper" function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there when made visible.

update(
    value = None,
    disabled = None,
    background_color = None,
    text_color = None,
    font = None,
    visible = None
)

Parameter Descriptions

Name Type Default Description
background_color str None color of background. Can be in #RRGGBB format or a color name "black"
disabled bool None disable or enable state of the element
font (str or (str, int[, str]) or None) None specifies the font family, size. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
text_color str None element's text color. Can be in #RRGGBB format or a color name "black"
value bool None if True change to selected and set others in group to unselected
visible bool None control visibility of element