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

Method update

PySimpleGUI/PySimpleGUI.py:5157–5295  ·  view source on GitHub ↗

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

(self, text=None, button_color=(None, None), disabled=None, image_source=None, image_data=None, image_filename=None,
               visible=None, image_subsample=None, image_zoom=None, disabled_button_color=(None, None), image_size=None)

Source from the content-addressed store, hash-verified

5155 return
5156
5157 def update(self, text=None, button_color=(None, None), disabled=None, image_source=None, image_data=None, image_filename=None,
5158 visible=None, image_subsample=None, image_zoom=None, disabled_button_color=(None, None), image_size=None):
5159 """
5160 Changes some of the settings for the Button Element. Must call `Window.Read` or `Window.Finalize` prior
5161
5162 Changes will not be visible in your window until you call window.read or window.refresh.
5163
5164 If you change visibility, your element may MOVE. If you want it to remain stationary, use the "layout helper"
5165 function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there
5166 when made visible.
5167
5168 :param text: sets button text
5169 :type text: (str)
5170 :param button_color: Color of button. default is from theme or the window. Easy to remember which is which if you say "ON" between colors. "red" on "green". Normally a tuple, but can be a simplified-button-color-string "foreground on background". Can be a single color if want to set only the background.
5171 :type button_color: (str, str) | str
5172 :param disabled: True/False to enable/disable at the GUI level. Use BUTTON_DISABLED_MEANS_IGNORE to ignore clicks (won't change colors)
5173 :type disabled: (bool | str)
5174 :param image_source: Image to place on button. Use INSTEAD of the image_filename and image_data. Unifies these into 1 easier to use parm
5175 :type image_source: (str | bytes)
5176 :param image_data: Raw or Base64 representation of the image to put on button. Choose either filename or data
5177 :type image_data: bytes | str
5178 :param image_filename: image filename if there is a button image. GIFs and PNGs only.
5179 :type image_filename: (str)
5180 :param disabled_button_color: colors to use when button is disabled (text, background). Use None for a color if don't want to change. Only ttk buttons support both text and background colors. tk buttons only support changing text color
5181 :type disabled_button_color: (str, str)
5182 :param visible: control visibility of element
5183 :type visible: (bool)
5184 :param image_subsample: amount to reduce the size of the image. Divides the size by this number. 2=1/2, 3=1/3, 4=1/4, etc
5185 :type image_subsample: (int)
5186 :param image_zoom: amount to increase the size of the image. 2=twice size, 3=3 times, etc
5187 :type image_zoom: (int)
5188 :param image_size: Size of the image in pixels (width, height)
5189 :type image_size: (int, int)
5190 """
5191
5192 if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
5193 return
5194
5195 if self._this_elements_window_closed():
5196 _error_popup_with_traceback('Error in Button.update - The window was closed')
5197 return
5198
5199 if image_source is not None:
5200 if isinstance(image_source, bytes):
5201 image_data = image_source
5202 elif isinstance(image_source, str):
5203 image_filename = image_source
5204
5205 if self.UseTtkButtons:
5206 style_name = self.ttk_style_name # created when made initial window (in the pack)
5207 # style_name = str(self.Key) + 'custombutton.TButton'
5208 button_style = ttk.Style()
5209 if text is not None:
5210 btext = text
5211 if DEFAULT_USE_BUTTON_SHORTCUTS is True:
5212 pos = btext.find(MENU_SHORTCUT_CHARACTER)
5213 if pos != -1:
5214 if pos < len(MENU_SHORTCUT_CHARACTER) or btext[pos - len(MENU_SHORTCUT_CHARACTER)] != "\\":

Callers

nothing calls this directly

Tested by

no test coverage detected