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

Method update

PySimpleGUI/PySimpleGUI.py:5678–5731  ·  view source on GitHub ↗

Changes some of the settings for the ProgressBar Element. Must call `Window.Read` or `Window.Finalize` prior Now has the ability to modify the count so that the update_bar method is not longer needed separately Changes will not be visible in your window until you call windo

(self, current_count=None, max=None, bar_color=None, visible=None)

Source from the content-addressed store, hash-verified

5676 return True
5677
5678 def update(self, current_count=None, max=None, bar_color=None, visible=None):
5679 """
5680 Changes some of the settings for the ProgressBar Element. Must call `Window.Read` or `Window.Finalize` prior
5681 Now has the ability to modify the count so that the update_bar method is not longer needed separately
5682
5683 Changes will not be visible in your window until you call window.read or window.refresh.
5684
5685 If you change visibility, your element may MOVE. If you want it to remain stationary, use the "layout helper"
5686 function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there
5687 when made visible.
5688
5689 :param current_count: sets the current value
5690 :type current_count: (int)
5691 :param max: changes the max value
5692 :type max: (int)
5693 :param bar_color: The 2 colors that make up a progress bar. Easy to remember which is which if you say "ON" between colors. "red" on "green".
5694 :type bar_color: (str, str) or str
5695 :param visible: control visibility of element
5696 :type visible: (bool)
5697 :return: Returns True if update was OK. False means something wrong with window or it was closed
5698 :rtype: (bool)
5699 """
5700 if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
5701 return False
5702
5703 if self._this_elements_window_closed():
5704 _error_popup_with_traceback('Error in ProgressBar.update - The window was closed')
5705 return
5706
5707 if self.ParentForm.TKrootDestroyed:
5708 return False
5709
5710 if visible is False:
5711 self._pack_forget_save_settings()
5712 elif visible is True:
5713 self._pack_restore_settings()
5714
5715 if visible is not None:
5716 self._visible = visible
5717 if bar_color is not None:
5718 bar_color = _simplified_dual_color_to_tuple(bar_color, default=DEFAULT_PROGRESS_BAR_COLOR)
5719 self.BarColor = bar_color
5720 style = ttk.Style()
5721 style.configure(self.ttk_style_name, background=bar_color[0], troughcolor=bar_color[1])
5722 if current_count is not None:
5723 self.TKProgressBar.Update(current_count, max=max)
5724
5725 try:
5726 self.ParentForm.TKroot.update()
5727 except:
5728 # Window._DecrementOpenCount()
5729 # _my_windows.Decrement()
5730 return False
5731 return True
5732
5733 Update = update
5734 UpdateBar = update_bar

Callers

nothing calls this directly

Calls 8

_widget_was_createdMethod · 0.80
UpdateMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected