MCPcopy
hub / github.com/PySimpleGUI/PySimpleGUI / _parse_colors_parm

Function _parse_colors_parm

PySimpleGUI/PySimpleGUI.py:18707–18735  ·  view source on GitHub ↗

Parse a colors parameter into its separate colors. Some functions accept a dual colors string/tuple. This function parses the parameter into the component colors :param colors: Either a tuple or a string that has both the text and background colors :type colors: (str) or (str,

(colors)

Source from the content-addressed store, hash-verified

18705
18706
18707def _parse_colors_parm(colors):
18708 """
18709 Parse a colors parameter into its separate colors.
18710 Some functions accept a dual colors string/tuple.
18711 This function parses the parameter into the component colors
18712
18713 :param colors: Either a tuple or a string that has both the text and background colors
18714 :type colors: (str) or (str, str)
18715 :return: tuple with the individual text and background colors
18716 :rtype: (str, str)
18717 """
18718 if colors is None:
18719 return None, None
18720 dual_color = colors
18721 kw_text_color = kw_background_color = None
18722 try:
18723 if isinstance(dual_color, tuple):
18724 kw_text_color = dual_color[0]
18725 kw_background_color = dual_color[1]
18726 elif isinstance(dual_color, str):
18727 if ' on ' in dual_color: # if has "on" in the string, then have both text and background
18728 kw_text_color = dual_color.split(' on ')[0]
18729 kw_background_color = dual_color.split(' on ')[1]
18730 else: # if no "on" then assume the color string is just the text color
18731 kw_text_color = dual_color
18732 except Exception as e:
18733 print('* warning * you messed up with color formatting', e)
18734
18735 return kw_text_color, kw_background_color
18736
18737
18738# ============================== set_global_icon ====#

Callers 1

easy_printFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected