def on_button_press(self, w, e, tab_content=None): """there were two problems in the handler: 1. when you click on eventbox, appears extra the signal from the notebook 2. when double-clicking, the first click is handled""" if type(w) == Gtk.EventBox: self.stop_handling = True #add delay in the background def start_handling(): self.stop_handling = False threading.Timer(0.3, start_handling).start() #Get rid of the parasitic signal if self.stop_handling and type(w) != Gtk.EventBox: return #handling of double middle click if is_double_middle_click(e) and type(w) == Gtk.EventBox: #this variable helps to ignore first click, when double-clicking self.val = False self.on_rename_tab(tab_content) #handling of middle click elif is_middle_click(e): self.val = True def midclick(): if self.val: if type(w) == Gtk.EventBox: n = self.page_num(tab_content) self.remove_page(n) else: self.empty_tab() #add delay in the background #for check (is second click or not) threading.Timer(0.5, midclick).start() #to show context menu elif is_rigth_click(e): if type(w) == Gtk.EventBox: w.menu.show_all() w.menu.popup(None, None, None, None, e.button, e.time)