python 3.x - In Python3/tkinter is there a way to temporarily stop accepting clicks in a Treeview widget? -


i have gui based in python 3 , tkinter has big ttk.treeview. have defined methods row selection (one click) , opening advanced info panel (double-click). need ensure that, after being double-clicked, next 1 or 2 seconds, treeview state won't changed click. possible deactivate treeview mouse bindings, buttons?

doing little more research, able come solution this. created empty method called when tree widget supposed inactive. so, can use "unbind" mouse events , re-bind them few seconds later, needed:

def nothing(self, *event):     """ # hacking moment: function nothing, times need it...     """     pass   def bind_tree(self):     """ # bind mouse , keyboard events respective functions or methods...     """     self.tree.bind('<<treeviewselect>>', self.selectitem_popup)     self.tree.bind('<double-1>', self.show_details)     self.tree.bind("<button-2>", self.popupmenu)     self.tree.bind("<button-3>", self.popupmenu)  def unbind_tree(self):     """ # unbind mouse , keyboard events, binding them empty method...     """     self.tree.bind('<<treeviewselect>>', self.nothing)     self.tree.bind('<double-1>', self.nothing)     self.tree.bind("<button-2>", self.nothing)     self.tree.bind("<button-3>", self.nothing) 

then, in rest of code, need call bind_tree() , unbind_tree() needed.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -