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,
    enable_events = False,
    font = None,
    size = (200, 600),
    justification = "right",
    header_text_color = None,
    header_background_color = None,
    header_font = None,
    text_color = None,
    background_color = None,
    num_rows = None,
    pad = None,
    key = None,
    k = None,
    tooltip = None,
    visible = True,
    size_px = (None, None),
    metadata = 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
enable_events bool False Turns on the element specific events. Tree events happen when row is clicked
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
header_background_color str None sets the background color for the header
header_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
header_text_color str None sets the text color for the header
headings List[str] None List of individual headings for each column
justification str right 'left', 'right', 'center' are valid choices
k str or int or tuple or object None Same as the Key. You can use either k or key. Which ever is set will be used.
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
metadata Any None User metadata that can be set to ANYTHING
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) 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
size (int, int) or (None, None) (200, 600) w=characters-wide, h=rows-high
size_px (int, int) or (None, None) (None, None) w=pixels-wide, h=pixels-high
text_color str None color of the text
tooltip str None text, that will appear when mouse hovers over the element
visible bool True set visibility state of 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 expand
 def get_stylesheet
 def set_stylesheet
 def update

expand

WARNING - NOT USED IN PySimpleGUIQt port. Provided as dummy method

expand(
    expand_x = False,
    expand_y = False,
    expand_row = True
)

Parameter Descriptions

Name Type Default Description
expand_row bool True If True the row containing the element will also expand. Without this your element is "trapped" within the row
expand_x bool False If True Element will expand in the Horizontal directions
expand_y bool False If True Element will expand in the Vertical directions
RETURN None None

get_stylesheet

Returns the stylesheet for element's associated Qt Widget

get_stylesheet()

Parameter Descriptions

Name Type Default Description
RETURN str stylesheet

set_stylesheet

Sets the stylesheet for a Qt Widget

set_stylesheet(
    stylesheet
)

Parameter Descriptions

Name Type Default Description
stylesheet str Stylesheet (string) to set stylesheet to

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.

If you change visibility, your element may MOVE.

update(
    values = None,
    key = None,
    value = None,
    text = None,
    visible = 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
visible bool None control visibility of element