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

Method update

PySimpleGUI/PySimpleGUI.py:8901–8986  ·  view source on GitHub ↗

Changes some of the settings for the Table 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, values=None, num_rows=None, visible=None, select_rows=None, alternating_row_color=None, row_colors=None)

Source from the content-addressed store, hash-verified

8899 return
8900
8901 def update(self, values=None, num_rows=None, visible=None, select_rows=None, alternating_row_color=None, row_colors=None):
8902 """
8903 Changes some of the settings for the Table Element. Must call `Window.Read` or `Window.Finalize` prior
8904
8905 Changes will not be visible in your window until you call window.read or window.refresh.
8906
8907 If you change visibility, your element may MOVE. If you want it to remain stationary, use the "layout helper"
8908 function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there
8909 when made visible.
8910
8911 :param values: A new 2-dimensional table to show
8912 :type values: List[List[str | int | float]]
8913 :param num_rows: How many rows to display at a time
8914 :type num_rows: (int)
8915 :param visible: if True then will be visible
8916 :type visible: (bool)
8917 :param select_rows: List of rows to select as if user did
8918 :type select_rows: List[int]
8919 :param alternating_row_color: the color to make every other row
8920 :type alternating_row_color: (str)
8921 :param row_colors: list of tuples of (row, background color) OR (row, foreground color, background color). Changes the colors of listed rows to the color(s) provided (note the optional foreground color)
8922 :type row_colors: List[Tuple[int, str] | Tuple[Int, str, str]]
8923 """
8924 if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
8925 return
8926
8927 if self._this_elements_window_closed():
8928 _error_popup_with_traceback('Error in Table.update - The window was closed')
8929 return
8930
8931 if values is not None:
8932 for id in self.tree_ids:
8933 self.TKTreeview.item(id, tags=())
8934 if self.BackgroundColor is not None and self.BackgroundColor != COLOR_SYSTEM_DEFAULT:
8935 self.TKTreeview.tag_configure(id, background=self.BackgroundColor)
8936 else:
8937 self.TKTreeview.tag_configure(id, background='#FFFFFF', foreground='#000000')
8938 if self.TextColor is not None and self.TextColor != COLOR_SYSTEM_DEFAULT:
8939 self.TKTreeview.tag_configure(id, foreground=self.TextColor)
8940 else:
8941 self.TKTreeview.tag_configure(id, foreground='#000000')
8942
8943 children = self.TKTreeview.get_children()
8944 for i in children:
8945 self.TKTreeview.detach(i)
8946 self.TKTreeview.delete(i)
8947 children = self.TKTreeview.get_children()
8948
8949 self.tree_ids = []
8950 for i, value in enumerate(values):
8951 if self.DisplayRowNumbers:
8952 value = [i + self.StartingRowNumber] + value
8953 id = self.TKTreeview.insert('', 'end', text=value, iid=i + 1, values=value, tag=i)
8954 if self.BackgroundColor is not None and self.BackgroundColor != COLOR_SYSTEM_DEFAULT:
8955 self.TKTreeview.tag_configure(id, background=self.BackgroundColor)
8956 else:
8957 self.TKTreeview.tag_configure(id, background='#FFFFFF')
8958 self.tree_ids.append(id)

Callers

nothing calls this directly

Calls 6

_widget_was_createdMethod · 0.80
insertMethod · 0.80

Tested by

no test coverage detected