On Wed, 2023-09-13 at 01:33 +0100, MRAB via Python-list wrote: > On 2023-09-13 00:40, John O'Hagan via Python-list wrote: > > On Tue, 2023-09-12 at 20:51 +0200, Mirko via Python-list wrote: > > > Am 12.09.23 um 07:43 schrieb John O'Hagan via Python-list: > > >
[...] > > > > > > > FWIW, here's a version without after(), solving this purely on > > > the > > > python side, not by temporarily unbinding the event, but by > > > selectively doing nothing in the callback function. > > > > > > from tkinter import * > > > from tkinter.ttk import * > > > > > > class Test: > > > def __init__(self): > > > self.inhibit = False > > > root=Tk() > > > self.tree = Treeview(root) > > > self.tree.pack() > > > self.iid = self.tree.insert('', 0, text='test') > > > Button(root, command=self.temp_inhibit).pack() > > > mainloop() > > > > > > def callback(self, *e): > > > if not self.inhibit: > > > print('called') > > > > > > def temp_inhibit(self): > > > self.inhibit = True > > > self.tree.selection_set(self.iid) > > > self.tree.selection_remove(self.iid) > > > self.tree.selection_set(self.iid) > > > self.inhibit = False > > > self.callback() > > > > > > c=Test() > > > > > > > > > I like this solution better - it's much more obvious to me what > > it's > > doing. > > > That code is not binding at all, it's just calling 'temp_inhibit' > when > the button is clicked. > > You can remove all uses of self.inhibit and rename 'temp_inhibit' to > something more meaningful, like 'delete_item'. You're right of course, not as obvious as I thought! -- https://mail.python.org/mailman/listinfo/python-list