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

Method update

PySimpleGUI/PySimpleGUI.py:9421–9517  ·  view source on GitHub ↗

Changes some of the settings for the Tree 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, values=None, key=None, value=None, text=None, icon=None, visible=None, expand_node=None, select_node_keys=None)

Source from the content-addressed store, hash-verified

9419 self.add_treeview_data(node)
9420
9421 def update(self, values=None, key=None, value=None, text=None, icon=None, visible=None, expand_node=None, select_node_keys=None):
9422 """
9423 Changes some of the settings for the Tree Element. Must call `Window.Read` or `Window.Finalize` prior
9424
9425 Changes will not be visible in your window until you call window.read or window.refresh.
9426
9427 If you change visibility, your element may MOVE. If you want it to remain stationary, use the "layout helper"
9428 function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there
9429 when made visible.
9430
9431 :param values: Representation of the tree
9432 :type values: (TreeData)
9433 :param key: identifies a particular item in tree to update
9434 :type key: str | int | tuple | object
9435 :param value: sets the node identified by key to a particular value
9436 :type value: (Any)
9437 :param text: sets the node identified by key to this string
9438 :type text: (str)
9439 :param icon: can be either a base64 icon or a filename for the icon
9440 :type icon: bytes | str
9441 :param visible: control visibility of element
9442 :type visible: (bool)
9443 :param expand_node: if True the node specified by key parameter will be expanded
9444 :type expand_node: (bool)
9445 :param select_node_keys: List of nodes to select as if user selected. You'll want to use Extended mode + control key to navigate to retain selection
9446 :type select_node_keys: List[str | int | tuple | object]
9447 """
9448
9449 if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
9450 return
9451
9452 if self._this_elements_window_closed():
9453 _error_popup_with_traceback('Error in Tree.update - The window was closed')
9454 return
9455
9456 if values is not None:
9457 children = self.TKTreeview.get_children()
9458 for i in children:
9459 self.TKTreeview.detach(i)
9460 self.TKTreeview.delete(i)
9461 children = self.TKTreeview.get_children()
9462 self.TreeData = values
9463 self.IdToKey = {'': ''}
9464 self.KeyToID = {'': ''}
9465 self.add_treeview_data(self.TreeData.root_node)
9466 self.SelectedRows = []
9467 if key is not None:
9468 for id in self.IdToKey.keys():
9469 if key == self.IdToKey[id]:
9470 break
9471 else:
9472 id = None
9473 print('** Key not found **')
9474 else:
9475 id = None
9476 if id:
9477 # item = self.TKTreeview.item(id)
9478 if value is not None:

Callers

nothing calls this directly

Calls 7

add_treeview_dataMethod · 0.95
_widget_was_createdMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected