I have a menu:
class NodePopup(tk.Menu):
def __init__(self, master):
super().__init__(master, tearoff=0)
self.send_disabled = tk.BooleanVar()
self.add_checkbutton(label="Disable sending",
command=self.toggle_send, variable=self.send_disabled)
def popup(self, node, event):
self.send_disabled.set(node.some_flag)
print('send_disabled:', self.send_disabled.get())
self.post(event.x_root, event.y_root)
class View:
def __init__(self, master)
self.master = master
self.canvas = #...
# ...
self.node_popup = NodePopup(self.master)
self.canvas.bind("<Button-2>", self.popup)
def popup(self, event):
node_oval, node = self.find_node(event.x, event.y)
self.node_popup.popup(node, event)
When calling my_menu.popup(e), it always pops up without a checkmark. print() prints the right values though.
OS X 10.12, python 3.6.0b4.
What is the problem?
self.node_popup.popup(event, node)with two arguments butdef popup(self, event):expects only one. And what do you do inself.toggle_send?self.send_disabledtoTrueorFalse.