MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / update

Method update

PySimpleGUI/PySimpleGUI.py:4197–4242  ·  view source on GitHub ↗

Changes some of the settings for the Text 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 stationa

(self, value=None, background_color=None, text_color=None, font=None, visible=None)

Source from the content-addressed store, hash-verified

4195 text_color=self.TextColor, pad=pad, key=key, tooltip=tooltip, visible=visible, metadata=metadata)
4196
4197 def update(self, value=None, background_color=None, text_color=None, font=None, visible=None):
4198 """
4199 Changes some of the settings for the Text Element. Must call `Window.Read` or `Window.Finalize` prior
4200
4201 Changes will not be visible in your window until you call window.read or window.refresh.
4202
4203 If you change visibility, your element may MOVE. If you want it to remain stationary, use the "layout helper"
4204 function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there
4205 when made visible.
4206
4207 :param value: new text to show
4208 :type value: (Any)
4209 :param background_color: color of background
4210 :type background_color: (str)
4211 :param text_color: color of the text
4212 :type text_color: (str)
4213 :param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
4214 :type font: (str or (str, int[, str]) or None)
4215 :param visible: set visibility state of the element
4216 :type visible: (bool)
4217 """
4218
4219 if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
4220 return
4221
4222 if self._this_elements_window_closed():
4223 _error_popup_with_traceback('Error in Text.update - The window was closed')
4224 return
4225
4226 if value is not None:
4227 self.DisplayText = str(value)
4228 self.TKStringVar.set(str(value))
4229 if background_color not in (None, COLOR_SYSTEM_DEFAULT):
4230 self.TKText.configure(background=background_color)
4231 if text_color not in (None, COLOR_SYSTEM_DEFAULT):
4232 self.TKText.configure(fg=text_color)
4233 if font is not None:
4234 self.TKText.configure(font=font)
4235 if visible is False:
4236 self._pack_forget_save_settings()
4237 # self.TKText.pack_forget()
4238 elif visible is True:
4239 self._pack_restore_settings()
4240 # self.TKText.pack(padx=self.pad_used[0], pady=self.pad_used[1])
4241 if visible is not None:
4242 self._visible = visible
4243
4244 def get(self):
4245 """

Callers 1

_print_to_elementMethod · 0.95

Calls 6

_widget_was_createdMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected