row_height parameter for Tree Elements
This commit is contained in:
parent
493c4a2e6d
commit
e456713a6d
|
@ -3168,7 +3168,7 @@ class Table(Element):
|
|||
# ---------------------------------------------------------------------- #
|
||||
class Tree(Element):
|
||||
def __init__(self, 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, justification='right', text_color=None, background_color=None, num_rows=None, pad=None, key=None, tooltip=None,right_click_menu=None, visible=True):
|
||||
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, justification='right', text_color=None, background_color=None, num_rows=None, row_height=None, pad=None, key=None, tooltip=None,right_click_menu=None, visible=True):
|
||||
'''
|
||||
Tree
|
||||
:param data:
|
||||
|
@ -3213,8 +3213,10 @@ class Tree(Element):
|
|||
self.SelectedRows = []
|
||||
self.ChangeSubmits = change_submits or enable_events
|
||||
self.RightClickMenu = right_click_menu
|
||||
self.RowHeight = row_height
|
||||
self.IconList = {}
|
||||
|
||||
|
||||
super().__init__(ELEM_TYPE_TREE, text_color=text_color, background_color=background_color, font=font, pad=pad,
|
||||
key=key, tooltip=tooltip, visible=visible)
|
||||
return
|
||||
|
@ -5577,6 +5579,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form:Window):
|
|||
element.TooltipObject = ToolTip(element.TKScale, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME)
|
||||
# ------------------------- TABLE element ------------------------- #
|
||||
elif element_type == ELEM_TYPE_TABLE:
|
||||
element = element # type: Table
|
||||
frame = tk.Frame(tk_row_frame)
|
||||
|
||||
height = element.NumRows
|
||||
|
@ -5608,7 +5611,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form:Window):
|
|||
column_headings = [element.RowHeaderText, ] + element.ColumnHeadings
|
||||
element.TKTreeview = ttk.Treeview(frame, columns=column_headings,
|
||||
displaycolumns=displaycolumns, show='headings', height=height,
|
||||
selectmode=element.SelectMode)
|
||||
selectmode=element.SelectMode,)
|
||||
treeview = element.TKTreeview
|
||||
if element.DisplayRowNumbers:
|
||||
treeview.heading(element.RowHeaderText, text=element.RowHeaderText) # make a dummy heading
|
||||
|
@ -5681,6 +5684,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form:Window):
|
|||
element.TKTreeview.bind('<Button-3>', element.RightClickMenuCallback)
|
||||
# ------------------------- Tree element ------------------------- #
|
||||
elif element_type == ELEM_TYPE_TREE:
|
||||
element = element #type: Tree
|
||||
frame = tk.Frame(tk_row_frame)
|
||||
|
||||
height = element.NumRows
|
||||
|
@ -5702,7 +5706,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form:Window):
|
|||
# ------------- GET THE TREEVIEW WIDGET -------------
|
||||
element.TKTreeview = ttk.Treeview(frame, columns=column_headings,
|
||||
displaycolumns=displaycolumns, show='tree headings', height=height,
|
||||
selectmode=element.SelectMode, )
|
||||
selectmode=element.SelectMode)
|
||||
treeview = element.TKTreeview
|
||||
for i, heading in enumerate(element.ColumnHeadings): # Configure cols + headings
|
||||
treeview.heading(heading, text=heading)
|
||||
|
@ -5742,6 +5746,9 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form:Window):
|
|||
if element.TextColor is not None and element.TextColor != COLOR_SYSTEM_DEFAULT:
|
||||
ttk.Style().configure("Treeview", foreground=element.TextColor)
|
||||
|
||||
ttk.Style().configure("Treeview", font=font)
|
||||
if element.RowHeight:
|
||||
ttk.Style().configure("Treeview", rowheight=element.RowHeight)
|
||||
scrollbar = tk.Scrollbar(frame)
|
||||
scrollbar.pack(side=tk.RIGHT, fill='y')
|
||||
scrollbar.config(command=treeview.yview)
|
||||
|
@ -5762,6 +5769,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form:Window):
|
|||
element.TKTreeview.bind('<Button-3>', element.RightClickMenuCallback)
|
||||
# ------------------------- Separator element ------------------------- #
|
||||
elif element_type == ELEM_TYPE_SEPARATOR:
|
||||
element = element # type: VerticalSeparator
|
||||
separator = ttk.Separator(tk_row_frame, orient=element.Orientation, )
|
||||
separator.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], fill='both', expand=True)
|
||||
# ------------------------- StatusBar element ------------------------- #
|
||||
|
|
Loading…
Reference in New Issue