Changes some of the settings for the ButtonMenu 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 st
(self, menu_definition=None, visible=None, image_source=None, image_size=(None, None), image_subsample=None, image_zoom=None, button_text=None, button_color=None)
| 5456 | _exit_mainloop(self.ParentForm, self) |
| 5457 | |
| 5458 | def update(self, menu_definition=None, visible=None, image_source=None, image_size=(None, None), image_subsample=None, image_zoom=None, button_text=None, button_color=None): |
| 5459 | """ |
| 5460 | Changes some of the settings for the ButtonMenu Element. Must call `Window.Read` or `Window.Finalize` prior |
| 5461 | |
| 5462 | Changes will not be visible in your window until you call window.read or window.refresh. |
| 5463 | |
| 5464 | If you change visibility, your element may MOVE. If you want it to remain stationary, use the "layout helper" |
| 5465 | function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there |
| 5466 | when made visible. |
| 5467 | |
| 5468 | :param menu_definition: (New menu definition (in menu definition format) |
| 5469 | :type menu_definition: List[List] |
| 5470 | :param visible: control visibility of element |
| 5471 | :type visible: (bool) |
| 5472 | :param image_source: new image if image is to be changed. Can be a filename or a base64 encoded byte-string |
| 5473 | :type image_source: (str | bytes) |
| 5474 | :param image_size: Size of the image in pixels (width, height) |
| 5475 | :type image_size: (int, int) |
| 5476 | :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 |
| 5477 | :type image_subsample: (int) |
| 5478 | :param image_zoom: amount to increase the size of the image. 2=twice size, 3=3 times, etc |
| 5479 | :type image_zoom: (int) |
| 5480 | :param button_text: Text to be shown on the button |
| 5481 | :type button_text: (str) |
| 5482 | :param button_color: 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. |
| 5483 | :type button_color: (str, str) | str |
| 5484 | """ |
| 5485 | |
| 5486 | if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow |
| 5487 | return |
| 5488 | |
| 5489 | if self._this_elements_window_closed(): |
| 5490 | _error_popup_with_traceback('Error in ButtonMenu.update - The window was closed') |
| 5491 | return |
| 5492 | |
| 5493 | if menu_definition is not None: |
| 5494 | self.MenuDefinition = copy.deepcopy(menu_definition) |
| 5495 | top_menu = self.TKMenu = tk.Menu(self.TKButtonMenu, tearoff=self.Tearoff, font=self.ItemFont, tearoffcommand=self._tearoff_menu_callback) |
| 5496 | |
| 5497 | if self.BackgroundColor not in (COLOR_SYSTEM_DEFAULT, None): |
| 5498 | top_menu.config(bg=self.BackgroundColor) |
| 5499 | if self.TextColor not in (COLOR_SYSTEM_DEFAULT, None): |
| 5500 | top_menu.config(fg=self.TextColor) |
| 5501 | if self.DisabledTextColor not in (COLOR_SYSTEM_DEFAULT, None): |
| 5502 | top_menu.config(disabledforeground=self.DisabledTextColor) |
| 5503 | if self.ItemFont is not None: |
| 5504 | top_menu.config(font=self.ItemFont) |
| 5505 | AddMenuItem(self.TKMenu, self.MenuDefinition[1], self) |
| 5506 | self.TKButtonMenu.configure(menu=self.TKMenu) |
| 5507 | if image_source is not None: |
| 5508 | filename = data = None |
| 5509 | if image_source is not None: |
| 5510 | if isinstance(image_source, bytes): |
| 5511 | data = image_source |
| 5512 | elif isinstance(image_source, str): |
| 5513 | filename = image_source |
| 5514 | else: |
| 5515 | warnings.warn('ButtonMenu element - image_source is not a valid type: {}'.format(type(image_source)), UserWarning) |
nothing calls this directly
no test coverage detected