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

Method update

PySimpleGUI/PySimpleGUI.py:3310–3388  ·  view source on GitHub ↗

Changes some of the settings for the Checkbox Element. Must call `Window.Read` or `Window.Finalize` prior. Note that changing visibility may cause element to change locations when made visible after invisible Changes will not be visible in your window until you call window.

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

Source from the content-addressed store, hash-verified

3308 return self.TKIntVar.get() != 0
3309
3310 def update(self, value=None, text=None, background_color=None, text_color=None, checkbox_color=None, disabled=None, visible=None):
3311 """
3312 Changes some of the settings for the Checkbox Element. Must call `Window.Read` or `Window.Finalize` prior.
3313 Note that changing visibility may cause element to change locations when made visible after invisible
3314
3315 Changes will not be visible in your window until you call window.read or window.refresh.
3316
3317 If you change visibility, your element may MOVE. If you want it to remain stationary, use the "layout helper"
3318 function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there
3319 when made visible.
3320
3321 :param value: if True checks the checkbox, False clears it
3322 :type value: (bool)
3323 :param text: Text to display next to checkbox
3324 :type text: (str)
3325 :param background_color: color of background
3326 :type background_color: (str)
3327 :param text_color: color of the text. Note this also changes the color of the checkmark
3328 :type text_color: (str)
3329 :param disabled: disable or enable element
3330 :type disabled: (bool)
3331 :param visible: control visibility of element
3332 :type visible: (bool)
3333 """
3334
3335 if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
3336 return
3337
3338 if self._this_elements_window_closed():
3339 _error_popup_with_traceback('Error in Checkbox.update - The window was closed')
3340 return
3341
3342 if value is not None:
3343 value = bool(value)
3344 try:
3345 self.TKIntVar.set(value)
3346 self.InitialState = value
3347 except:
3348 print('Checkbox update failed')
3349 if disabled is True:
3350 self.TKCheckbutton.configure(state='disabled')
3351 elif disabled is False:
3352 self.TKCheckbutton.configure(state='normal')
3353 self.Disabled = disabled if disabled is not None else self.Disabled
3354
3355 if text is not None:
3356 self.Text = str(text)
3357 self.TKCheckbutton.configure(text=self.Text)
3358 if background_color not in (None, COLOR_SYSTEM_DEFAULT):
3359 self.TKCheckbutton.configure(background=background_color)
3360 self.BackgroundColor = background_color
3361 if text_color not in (None, COLOR_SYSTEM_DEFAULT):
3362 self.TKCheckbutton.configure(fg=text_color)
3363 self.TextColor = text_color
3364 # Color the checkbox itself
3365 if checkbox_color not in (None, COLOR_SYSTEM_DEFAULT):
3366 self.CheckboxBackgroundColor = checkbox_color
3367 self.TKCheckbutton.configure(selectcolor=self.CheckboxBackgroundColor) # The background of the checkbox

Callers

nothing calls this directly

Calls 10

_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

Tested by

no test coverage detected