pic_scanner.gui.helpers
Functions
|
Format a button key based on the provided text. |
Module Contents
- pic_scanner.gui.helpers.format_button_key(text: str, skip_space_replacement=False, replace_spaces_with='_', skip_uppercase_conversion=False, skip_suffix=False, suffix='button') str
Format a button key based on the provided text.
- The function will optionally perform the following actions:
Replace spaces in the string with a specified character (default is ‘_’)
Convert the text to uppercase
Append a suffix to the text (default is ‘button’)
- Parameters:
text (str) – The text to format.
skip_space_replacement (bool) – Whether to skip replacing spaces in the text. Default is False.
replace_spaces_with (str) – The character to replace spaces with. Default is ‘_’.
skip_uppercase_conversion (bool) – Whether to skip converting the text to uppercase. Default is False.
skip_suffix (bool) – Whether to skip appending a suffix to the text. Default is False.
suffix (str) – The suffix to append to the text. Default is ‘button’.
- Returns:
The formatted button key.
- Return type:
str
Examples
>>> format_button_key('My Button') 'MY_BUTTON_BUTTON'
>>> format_button_key('My Button', skip_suffix=True) 'MY_BUTTON'
>>> format_button_key('My Button', skip_uppercase_conversion=True) 'My_button'
>>> format_button_key('My Button', skip_space_replacement=True) 'MY BUTTON button'
>>> format_button_key('My Button', replace_spaces_with='-') 'MY-BUTTON_button'