Skip to content

Latest commit

 

History

History
171 lines (105 loc) · 5.16 KB

dbpp.widgets.xtreeview.md

File metadata and controls

171 lines (105 loc) · 5.16 KB

dbpp.widgets package: GuiBaseClass - AutoScrollbar - Balloon - Ctext - LabEntry - RoText - Scrolled - SqlText - StatusBar - TableView - TextMixins - XTableView - XTreeView

dbpp.kroki - dbpp.kroki.KrokiEncoder - dbpp.utils - dbpp.utils.SqlUtils -

apps: dbpp.peditor

module widgets.xtreeview

Tree widget based on ttk.Treeview with scrollbars shown if needed and default images.

This a widget to tree like data using the standard ttk.Treeview widget, inheriting all its methods and options. Further the widget has automatically shown or hidden scrollbars and as well some default images which simplify creating nice tree widgets. To use the pack geometry manager you can just use the pack and the pack_forget commands of this widget as these are forwarded to the frame. For other geometry managers like grid, the panedwindow or the notenbook you should use the getFrame method.

Examples:

import tkinter as tk
import tkinter.ttk as ttk
from dbpb.widgets.xtreeview import XTreeView
root = tk.Tk()
root.title('DGApp')
dgtree=XTreeView(root,sheetsym=False)
dgtree.configure(columns=("one","two"))
dgtree.column("one", width=100 )
dgtree.column("two", width=100)
dgtree.heading("#0", text="tree column")    
dgtree.heading("one", text="column A")
dgtree.heading("two", text="column B")
dgtree.insert("",0,text="Line 1",values=("1A","1b")),
id2 = dgtree.insert("",1,"dir2",text="Dir 2")
dgtree.insert(id2,"end","dir 2",
    text="sub dir 2", values=("2A","2B"))

dgtree.insert("", 3, "dir3", text="Dir 3")
dgtree.insert("dir3", 3,
    text=" sub dir 3",values=("3A"," 3B"))
def printSelection(event):
    item = dgtree.identify('item',event.x,event.y)
    print(item)
dgtree.bind("<Double-1>",printSelection)
dgtree.bookify()
root.mainloop()

Author: Detlef Groth, University of Potsdam, 2019-2023

License: MIT - License


class XTreeView

Extended ttk.Treeview widget.

method __init__

__init__(parent, sheetsym=False, *args, **kwargs)

The constructor to create a XTreeView widget.

Args:

  • parent (ttk.Frame): the parent widget wherein the ttk.Treeview widget will be placed.
  • sheetsym (bool): should table sheet symbols be shown, defaults to False
  • *args (list): standard ttk.Treeview arguments which will be delegated to the widget
  • **kwargs (dict): standard ttk.Treeview arguments which will be delegated to the widget

method bookify

bookify(item='')

Displays all images in the tree widget, starting from root or from the given item.

Args:

  • item (ttk.Treeview item): the parent item from where the images, should be initialized, defaults to the empty string, the root item.

method getFrame

getFrame()

Returns the frame in which the widget is embedded to perform, useful for packing or gridding the widget.

This function is needed by geometry managers like grid or ttk.PanedWindow to manage the parent frame of the widget in the layout. For pack the default methods pack and pack_forget are defined.


method pack

pack(**kwargs)

Overwrites the default pack method to use the internal frame.


method pack_forget

pack_forget(**kwargs)

Overwrites the default pack_forget method to use the internal frame.


This file was automatically generated via lazydocs.