Web Analytics Made Easy - Statcounter
Skip to content

Tree

Tree Element - Presents data in a tree-like manner, much like a file/folder browser. Uses the TreeData class to hold the user's data and pass to the element for display.

Tree(
    data = None,
    headings = None,
    visible_column_map = None,
    col_widths = None,
    col0_width = 10,
    def_col_width = 10,
    auto_size_columns = True,
    max_col_width = 20,
    select_mode = None,
    show_expanded = False,
    change_submits = False,
    font = None,
    justification = "right",
    text_color = None,
    background_color = None,
    num_rows = None,
    pad = None,
    key = None,
    tooltip = None
)

Parameter Descriptions

Name Type Default Description
auto_size_columns bool True if True, the size of a column is determined using the contents of the column
background_color str None color of background
change_submits bool False DO NOT USE. Only listed for backwards compat - Use enable_events instead
col0_width int 10 Size of Column 0 which is where the row numbers will be optionally shown
col_widths List[int] None List of column widths so that individual column widths can be controlled
data TreeData None The data represented using a PySimpleGUI provided TreeData class
def_col_width int 10 default column width
font (str or (str, int[, str]) or None) None specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
headings List[str] None List of individual headings for each column
justification str right 'left', 'right', 'center' are valid choices
key str or int or tuple or object None Used with window.find_element and with return values to uniquely identify this element to uniquely identify this element
max_col_width int 20 the maximum size a column can be
num_rows int None The number of rows of the table to display at a time
pad (int, int or (int, int),(int,int) or int,(int,int)) or ((int, int),int) or int None Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int)
select_mode enum None Use same values as found on Table Element. Valid values include: TABLE_SELECT_MODE_NONE TABLE_SELECT_MODE_BROWSE TABLE_SELECT_MODE_EXTENDED
show_expanded bool False if True then the tree will be initially shown with all nodes completely expanded
text_color str None color of the text
tooltip str None text, that will appear when mouse hovers over the element
visible_column_map List[bool] None Determines if a column should be visible. If left empty, all columns will be shown

Class Properties

This class has no public properties

Class Methods

 def update

update

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.

update(
    values = None,
    key = None,
    value = None,
    text = None
)

Parameter Descriptions

Name Type Default Description
key str or int or tuple or object None identifies a particular item in tree to update
text str None sets the node identified by key to this string
value Any None sets the node identified by key to a particular value
values TreeData None Representation of the tree