MCPcopy
hub / github.com/PySimpleGUI/PySimpleGUI / update

Method update

PySimpleGUI/PySimpleGUI.py:3093–3174  ·  view source on GitHub ↗

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

(self, value=None, text=None, background_color=None, text_color=None, circle_color=None, disabled=None, visible=None)

Source from the content-addressed store, hash-verified

3091 tooltip=tooltip, visible=visible, metadata=metadata)
3092
3093 def update(self, value=None, text=None, background_color=None, text_color=None, circle_color=None, disabled=None, visible=None):
3094 """
3095 Changes some of the settings for the Radio Button Element. Must call `Window.read` or `Window.finalize` prior
3096
3097 Changes will not be visible in your window until you call window.read or window.refresh.
3098
3099 If you change visibility, your element may MOVE. If you want it to remain stationary, use the "layout helper"
3100 function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there
3101 when made visible.
3102
3103 :param value: if True change to selected and set others in group to unselected
3104 :type value: (bool)
3105 :param text: Text to display next to radio button
3106 :type text: (str)
3107 :param background_color: color of background
3108 :type background_color: (str)
3109 :param text_color: color of the text. Note this also changes the color of the selection dot
3110 :type text_color: (str)
3111 :param circle_color: color of background of the circle that has the dot selection indicator in it
3112 :type circle_color: (str)
3113 :param disabled: disable or enable state of the element
3114 :type disabled: (bool)
3115 :param visible: control visibility of element
3116 :type visible: (bool)
3117 """
3118
3119 if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
3120 return
3121
3122 if self._this_elements_window_closed():
3123 _error_popup_with_traceback('Error in Radio.update - The window was closed')
3124 return
3125
3126 if value is not None:
3127 try:
3128 if value is True:
3129 self.TKIntVar.set(self.EncodedRadioValue)
3130 elif value is False:
3131 if self.TKIntVar.get() == self.EncodedRadioValue:
3132 self.TKIntVar.set(0)
3133 except:
3134 print('Error updating Radio')
3135 self.InitialState = value
3136 if text is not None:
3137 self.Text = str(text)
3138 self.TKRadio.configure(text=self.Text)
3139 if background_color not in (None, COLOR_SYSTEM_DEFAULT):
3140 self.TKRadio.configure(background=background_color)
3141 self.BackgroundColor = background_color
3142 if text_color not in (None, COLOR_SYSTEM_DEFAULT):
3143 self.TKRadio.configure(fg=text_color)
3144 self.TextColor = text_color
3145
3146 if circle_color not in (None, COLOR_SYSTEM_DEFAULT):
3147 self.CircleBackgroundColor = circle_color
3148 self.TKRadio.configure(selectcolor=self.CircleBackgroundColor) # The background of the radio button
3149 elif text_color or background_color:
3150 if self.TextColor not in (None, COLOR_SYSTEM_DEFAULT) and self.BackgroundColor not in (None, COLOR_SYSTEM_DEFAULT) and self.TextColor.startswith(

Callers

nothing calls this directly

Calls 11

_hex_to_hslFunction · 0.85
theme_background_colorFunction · 0.85
_hsl_to_rgbFunction · 0.85
rgbFunction · 0.85
_widget_was_createdMethod · 0.80
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected