Enable setting text and background colors for rows

This commit is contained in:
MikeTheWatchGuy 2019-01-03 11:38:33 -05:00
parent 6a6fcd6054
commit c1ffd5c5ec
1 changed files with 8 additions and 4 deletions

View File

@ -5616,12 +5616,16 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form:Window):
if element.DisplayRowNumbers:
value = [i+element.StartingRowNumber] + value
id = treeview.insert('', 'end', text=value, iid=i + 1, values=value, tag=i)
if element.AlternatingRowColor is not None:
if element.AlternatingRowColor is not None: # alternating colors
for row in range(0, len(element.Values), 2):
treeview.tag_configure(row, background=element.AlternatingRowColor)
if element.RowColors is not None:
for row,color in element.RowColors:
treeview.tag_configure(row, background=color)
if element.RowColors is not None: # individual row colors
for row_def in element.RowColors:
if len(row_def) == 2: # only background is specified
treeview.tag_configure(row_def[0], background=row_def[1])
else:
treeview.tag_configure(row_def[0], background=row_def[2], foreground=row_def[1])
if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT:
ttk.Style().configure("Treeview", background=element.BackgroundColor,
fieldbackground=element.BackgroundColor)