Table double click and return key supprt
This commit is contained in:
parent
681951d45f
commit
3fc648209c
|
@ -2452,7 +2452,7 @@ class Table(Element):
|
||||||
def __init__(self, values, headings=None, visible_column_map=None, col_widths=None, def_col_width=10,
|
def __init__(self, values, headings=None, visible_column_map=None, col_widths=None, def_col_width=10,
|
||||||
auto_size_columns=True, max_col_width=20, select_mode=None, display_row_numbers=False, num_rows=None,
|
auto_size_columns=True, max_col_width=20, select_mode=None, display_row_numbers=False, num_rows=None,
|
||||||
font=None, justification='right', text_color=None, background_color=None, alternating_row_color=None,
|
font=None, justification='right', text_color=None, background_color=None, alternating_row_color=None,
|
||||||
size=(None, None), change_submits=False, pad=None, key=None, tooltip=None):
|
size=(None, None), change_submits=False, bind_return_key=False, pad=None, key=None, tooltip=None):
|
||||||
'''
|
'''
|
||||||
Table Element
|
Table Element
|
||||||
:param values:
|
:param values:
|
||||||
|
@ -2491,6 +2491,7 @@ class Table(Element):
|
||||||
self.AlternatingRowColor = alternating_row_color
|
self.AlternatingRowColor = alternating_row_color
|
||||||
self.SelectedRows = []
|
self.SelectedRows = []
|
||||||
self.ChangeSubmits = change_submits
|
self.ChangeSubmits = change_submits
|
||||||
|
self.BindReturnKey = bind_return_key
|
||||||
|
|
||||||
super().__init__(ELEM_TYPE_TABLE, text_color=text_color, background_color=background_color, font=font,
|
super().__init__(ELEM_TYPE_TABLE, text_color=text_color, background_color=background_color, font=font,
|
||||||
size=size, pad=pad, key=key, tooltip=tooltip)
|
size=size, pad=pad, key=key, tooltip=tooltip)
|
||||||
|
@ -2527,6 +2528,20 @@ class Table(Element):
|
||||||
self.ParentForm.TKroot.quit()
|
self.ParentForm.TKroot.quit()
|
||||||
|
|
||||||
|
|
||||||
|
def treeview_double_click(self, event):
|
||||||
|
selections = self.TKTreeview.selection()
|
||||||
|
self.SelectedRows = [int(x) - 1 for x in selections]
|
||||||
|
if self.BindReturnKey:
|
||||||
|
MyForm = self.ParentForm
|
||||||
|
if self.Key is not None:
|
||||||
|
self.ParentForm.LastButtonClicked = self.Key
|
||||||
|
else:
|
||||||
|
self.ParentForm.LastButtonClicked = ''
|
||||||
|
self.ParentForm.FormRemainedOpen = True
|
||||||
|
if self.ParentForm.CurrentlyRunningMainloop:
|
||||||
|
self.ParentForm.TKroot.quit()
|
||||||
|
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
super().__del__()
|
super().__del__()
|
||||||
|
|
||||||
|
@ -4566,7 +4581,9 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
|
||||||
ttk.Style().configure("Treeview", foreground=element.TextColor)
|
ttk.Style().configure("Treeview", foreground=element.TextColor)
|
||||||
# scrollable_frame.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1], expand=True, fill='both')
|
# scrollable_frame.pack(side=tk.LEFT, padx=element.Pad[0], pady=element.Pad[1], expand=True, fill='both')
|
||||||
treeview.bind("<<TreeviewSelect>>", element.treeview_selected)
|
treeview.bind("<<TreeviewSelect>>", element.treeview_selected)
|
||||||
|
if element.BindReturnKey:
|
||||||
|
treeview.bind('<Return>', element.treeview_double_click)
|
||||||
|
treeview.bind('<Double-Button-1>', element.treeview_double_click)
|
||||||
scrollbar = tk.Scrollbar(frame)
|
scrollbar = tk.Scrollbar(frame)
|
||||||
scrollbar.pack(side=tk.RIGHT, fill='y')
|
scrollbar.pack(side=tk.RIGHT, fill='y')
|
||||||
scrollbar.config(command=treeview.yview)
|
scrollbar.config(command=treeview.yview)
|
||||||
|
|
Loading…
Reference in New Issue