[issue40210] ttk.Combobox focus-out event inheritage
Nikolai Ehrhardt
report at bugs.python.org
Mon Apr 6 16:18:21 EDT 2020
New submission from Nikolai Ehrhardt <n.ehrhardt88 at gmail.com>:
Hi Guys,
I'm spawning entry fields in a treeview to make values editable while runtime, my codepiece:
the edit method is bind to left click:
def edit(self, event):
region = self.identify_region(event.x, event.y)
if region == 'cell':
# the user clicked on a cell
def enter(event):
self.set(item, column, entry.get())
entry.destroy()
column = self.identify_column(event.x) # identify column
item = self.identify_row(event.y) # identify item
self.parent_split = self.parent(item).split("__", 1)
print(column, item, self.parent_split)
if not tree_const.isEntryField(self.parent_split, column) or len(self.get_children(item)):
return
x, y, width, height = self.bbox(item, column)
value = self.set(item, column)
entry = None
if tree_const.tc_index_column_map[column] == tree_const.col_op:
entry = ttk.Combobox(self, state="readonly", values=tree_const.combo_ops)
entry.bind('<<ComboboxSelected>>', enter)
entry.set(value)
else:
entry = ttk.Entry(self)
entry.insert(0, value) # put former value in entry
entry.bind('<Return>', enter) # validate with Enter
entry.bind('<FocusOut>', enter)
# display the Entry
# create edition entry
entry.place(x=x, y=y, width=width, height=height,
anchor='nw') # display entry on top of cell
entry.focus_set()
And now is the problem: The entries are not properly destroyed when focusing out, so I assume, that the button created for combobox, is not well connected to the focus-out event. When the button would just inherit the binding, the combobox would already disappear,while selecting.
So there is some logic missing. For destroying widget properly on focusing out.
----------
files: treeview_spawn_entries.png
messages: 365878
nosy: Nikolai Ehrhardt
priority: normal
severity: normal
status: open
title: ttk.Combobox focus-out event inheritage
type: behavior
versions: Python 3.5
Added file: https://bugs.python.org/file49041/treeview_spawn_entries.png
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40210>
_______________________________________
More information about the Python-bugs-list
mailing list