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

Method update

PySimpleGUI/PySimpleGUI.py:2072–2177  ·  view source on GitHub ↗

Changes some of the settings for the Input 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 station

(self, value=None, disabled=None, select=None, visible=None, text_color=None, background_color=None, font=None, move_cursor_to='end', password_char=None, paste=None,
               readonly=None)

Source from the content-addressed store, hash-verified

2070 font=font, tooltip=tooltip, visible=visible, metadata=metadata)
2071
2072 def update(self, value=None, disabled=None, select=None, visible=None, text_color=None, background_color=None, font=None, move_cursor_to='end', password_char=None, paste=None,
2073 readonly=None):
2074 """
2075 Changes some of the settings for the Input Element. Must call `Window.Read` or `Window.Finalize` prior.
2076 Changes will not be visible in your window until you call window.read or window.refresh.
2077
2078 If you change visibility, your element may MOVE. If you want it to remain stationary, use the "layout helper"
2079 function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there
2080 when made visible.
2081
2082 :param value: new text to display as default text in Input field
2083 :type value: (str)
2084 :param disabled: disable or enable state of the element (sets Entry Widget to readonly or normal)
2085 :type disabled: (bool)
2086 :param select: if True, then the text will be selected
2087 :type select: (bool)
2088 :param visible: change visibility of element
2089 :type visible: (bool)
2090 :param text_color: change color of text being typed
2091 :type text_color: (str)
2092 :param background_color: change color of the background
2093 :type background_color: (str)
2094 :param font: specifies the font family, size. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
2095 :type font: (str or (str, int[, str]) or None)
2096 :param move_cursor_to: Moves the cursor to a particular offset. Defaults to 'end'
2097 :type move_cursor_to: int | str
2098 :param password_char: Password character if this is a password field
2099 :type password_char: str
2100 :param paste: If True "Pastes" the value into the element rather than replacing the entire element. If anything is selected it is replaced. The text is inserted at the current cursor location.
2101 :type paste: bool
2102 :param readonly: if True make element readonly (user cannot change any choices). Enables the element if either choice are made.
2103 :type readonly: (bool)
2104 """
2105 if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
2106 return
2107
2108 if self._this_elements_window_closed():
2109 _error_popup_with_traceback('Error in Input.update - The window was closed')
2110 return
2111
2112 if background_color is not None:
2113 if _widget_set_bg_color(self.TKEntry, background_color): # set background using refactored function to check for errors, etc.
2114 self.BackgroundColor = background_color
2115 if text_color is not None:
2116 # self.TKEntry.configure(fg=text_color)
2117 if _widget_set_fg_color(self.TKEntry, text_color): # set foreground using refactored function to check for errors, etc.
2118 self.TextColor = text_color # save new color if all is OK
2119
2120 if disabled is True:
2121 if self.UseReadonlyForDisable:
2122 _widget_set_fg_color(self.TKEntry, self.disabled_readonly_text_color)
2123 _widget_set_bg_color(self.TKEntry, self.disabled_readonly_background_color)
2124 self.TKEntry['state'] = 'readonly'
2125 else:
2126 self.TKEntry['state'] = 'disabled'
2127 self.Disabled = True
2128 elif disabled is False:
2129 self.TKEntry['state'] = 'normal'

Callers

nothing calls this directly

Calls 9

_widget_set_bg_colorFunction · 0.85
_widget_set_fg_colorFunction · 0.85
_widget_was_createdMethod · 0.80
insertMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected