tkinter.ttk.Treeview

class tkinter.ttk.Treeview

bbox(item, column=None)

Returns the bounding box (relative to the treeview widget’s window) of the specified item in the form (x, y, width, height).

If column is specified, returns the bounding box of that cell. If the item is not visible (i.e., if it is a descendant of a closed item or is scrolled offscreen), returns an empty string.

get_children(item=None)

Returns the list of children belonging to item.

If item is not specified, returns root children.

set_children(item, *newchildren)

Replaces item‘s child with newchildren.

Children present in item that are not present in newchildren are detached from the tree. No items in newchildren may be an ancestor of item. Note that not specifying newchildren results in detaching item‘s children.

column(column, option=None, **kw)

Query or modify the options for the specified column.

If kw is not given, returns a dict of the column option values. If option is specified then the value for that option is returned. Otherwise, sets the options to the corresponding values.

The valid options/values are:

  • id

    Returns the column name. This is a read-only option.

  • anchor: One of the standard Tk anchor values.

    Specifies how the text in this column should be aligned with respect to the cell.

  • minwidth: width

    The minimum width of the column in pixels. The treeview widget will not make the column any smaller than specified by this option when the widget is resized or the user drags a column.

  • stretch: True/False

    Specifies whether the column’s width should be adjusted when the widget is resized.

  • width: width

    The width of the column in pixels.

To configure the tree column, call this with column = “#0”

delete(*items)

Delete all specified items and all their descendants.

The root item may not be deleted.

detach(*items)

Unlinks all of the specified items from the tree.

The items and all of their descendants are still present, and may be reinserted at another point in the tree, but will not be displayed.

The root item may not be detached.

exists(item)

Returns True if the specified item is present in the tree.

focus(item=None)

If item is specified, sets the focus item to item. Otherwise, returns the current focus item, or ‘’ if there is none.

heading(column, option=None, **kw)

Query or modify the heading options for the specified column.

If kw is not given, returns a dict of the heading option values. If option is specified then the value for that option is returned. Otherwise, sets the options to the corresponding values.

The valid options/values are:

  • text: text

    The text to display in the column heading.

  • image: imageName

    Specifies an image to display to the right of the column heading.

  • anchor: anchor

    Specifies how the heading text should be aligned. One of the standard Tk anchor values.

  • command: callback

    A callback to be invoked when the heading label is pressed.

To configure the tree column heading, call this with column = “#0”.

identify(component, x, y)

Returns a description of the specified component under the point given by x and y, or the empty string if no such component is present at that position.

identify_row(y)

Returns the item ID of the item at position y.

identify_column(x)

Returns the data column identifier of the cell at position x.

The tree column has ID #0.

identify_region(x, y)

Returns one of:

region meaning
heading Tree heading area.
separator Space between two columns headings.
tree The tree area.
cell A data cell.

Availability: Tk 8.6.

identify_element(x, y)

Returns the element at position x, y.

Availability: Tk 8.6.

index(item)

Returns the integer index of item within its parent’s list of children.

insert(parent, index, iid=None, **kw)

Creates a new item and returns the item identifier of the newly created item.

parent is the item ID of the parent item, or the empty string to create a new top-level item. index is an integer, or the value “end”, specifying where in the list of parent’s children to insert the new item. If index is less than or equal to zero, the new node is inserted at the beginning; if index is greater than or equal to the current number of children, it is inserted at the end. If iid is specified, it is used as the item identifier; iid must not already exist in the tree. Otherwise, a new unique identifier is generated.

See Item Options for the list of available points.

item(item, option=None, **kw)

Query or modify the options for the specified item.

If no options are given, a dict with options/values for the item is returned. If option is specified then the value for that option is returned. Otherwise, sets the options to the corresponding values as given by kw.

move(item, parent, index)

Moves item to position index in parent‘s list of children.

It is illegal to move an item under one of its descendants. If index is less than or equal to zero, item is moved to the beginning; if greater than or equal to the number of children, it is moved to the end. If item was detached it is reattached.

next(item)

Returns the identifier of item‘s next sibling, or ‘’ if item is the last child of its parent.

parent(item)

Returns the ID of the parent of item, or ‘’ if item is at the top level of the hierarchy.

prev(item)

Returns the identifier of item‘s previous sibling, or ‘’ if item is the first child of its parent.

reattach(item, parent, index)

An alias for Treeview.move().

see(item)

Ensure that item is visible.

Sets all of item‘s ancestors open option to True, and scrolls the widget if necessary so that item is within the visible portion of the tree.

selection(selop=None, items=None)

If selop is not specified, returns selected items. Otherwise, it will act according to the following selection methods.

selection_set(items)

items becomes the new selection.

selection_add(items)

Add items to the selection.

selection_remove(items)

Remove items from the selection.

selection_toggle(items)

Toggle the selection state of each item in items.

set(item, column=None, value=None)

With one argument, returns a dictionary of column/value pairs for the specified item. With two arguments, returns the current value of the specified column. With three arguments, sets the value of given column in given item to the specified value.

tag_bind(tagname, sequence=None, callback=None)

Bind a callback for the given event sequence to the tag tagname. When an event is delivered to an item, the callbacks for each of the item’s tags option are called.

tag_configure(tagname, option=None, **kw)

Query or modify the options for the specified tagname.

If kw is not given, returns a dict of the option settings for tagname. If option is specified, returns the value for that option for the specified tagname. Otherwise, sets the options to the corresponding values for the given tagname.

tag_has(tagname, item=None)

If item is specified, returns 1 or 0 depending on whether the specified item has the given tagname. Otherwise, returns a list of all items that have the specified tag.

Availability: Tk 8.6

xview(*args)

Query or modify horizontal position of the treeview.

yview(*args)

Query or modify vertical position of the treeview.

doc_python
2016-10-07 17:44:58
Comments
Leave a Comment

Please login to continue.