From cb56e0fed86b53578c729b321662a9b84113a1eb Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Tue, 6 Nov 2018 10:36:31 -0500 Subject: [PATCH] Window property RowHeaderText - can change what's displayed in the column headers for the row number column --- PySimpleGUI.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 60355012..6e4a71da 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -2555,7 +2555,7 @@ class Table(Element): self.ChangeSubmits = change_submits self.BindReturnKey = bind_return_key self.StartingRowNumber = 0 # When displaying row numbers, where to start - + self.RowHeaderText = 'Row' super().__init__(ELEM_TYPE_TABLE, text_color=text_color, background_color=background_color, font=font, size=size, pad=pad, key=key, tooltip=tooltip) return @@ -2569,8 +2569,8 @@ class Table(Element): children = self.TKTreeview.get_children() # self.TKTreeview.delete(*self.TKTreeview.get_children()) for i, value in enumerate(values): - if self.DisplayRowNumbers: - value = [i] + value + if self.DisplayRowNumbrs: + value = [i+self.StartingRowNumber] + value id = self.TKTreeview.insert('', 'end', text=i, iid=i + 1, values=value, tag=i % 2) if self.AlternatingRowColor is not None: self.TKTreeview.tag_configure(1, background=self.AlternatingRowColor) @@ -4618,15 +4618,15 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form): displaycolumns.append(element.ColumnHeadings[i]) column_headings = element.ColumnHeadings if element.DisplayRowNumbers: # if display row number, tack on the numbers to front of columns - displaycolumns = ['Row', ] + displaycolumns - column_headings = ['Row', ] + element.ColumnHeadings + displaycolumns = [element.RowHeaderText, ] + displaycolumns + column_headings = [element.RowHeaderText, ] + element.ColumnHeadings element.TKTreeview = ttk.Treeview(frame, columns=column_headings, displaycolumns=displaycolumns, show='headings', height=height, selectmode=element.SelectMode) treeview = element.TKTreeview if element.DisplayRowNumbers: - treeview.heading('Row', text='Row') # make a dummy heading - treeview.column('Row', width=50, anchor=anchor) + treeview.heading(element.RowHeaderText, text=element.RowHeaderText) # make a dummy heading + treeview.column(element.RowHeaderText, width=50, anchor=anchor) for i, heading in enumerate(element.ColumnHeadings): treeview.heading(heading, text=heading) if element.AutoSizeColumns: