Author Victor Sergienko
Recipients Victor Sergienko
Date 2016-12-14.01:45:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1481679953.88.0.548860195336.issue28966@psf.upfronthosting.co.za>
In-reply-to
Content
On Linux, this code toggles the checkmark on a checkbutton in right-click menu. On OS X 10.12 it doesn't.

OS X 10.12, python 3.6.0b4.

#!/usr/bin/env python3
import tkinter as tk


class NodePopup(tk.Menu):
    def __init__(self, master):
        super().__init__(master, tearoff=0)

        self.send_disabled = tk.BooleanVar()

        self.add_checkbutton(label="Disable sending",
                             variable=self.send_disabled, command=self.toggle_send)

    def popup(self, event):
        print('send_disabled before:', self.send_disabled.get())
        self.post(event.x_root, event.y_root)

    def toggle_send(self):
        print('send_disabled after:', self.send_disabled.get())


def change():
    state = not menu.send_disabled.get()
    menu.send_disabled.set(state)

root = tk.Tk()
root.pack_propagate(0)

menu = NodePopup(root)
root.bind('<Button-2>', menu.popup)

root.mainloop()
History
Date User Action Args
2016-12-14 01:45:53Victor Sergienkosetrecipients: + Victor Sergienko
2016-12-14 01:45:53Victor Sergienkosetmessageid: <1481679953.88.0.548860195336.issue28966@psf.upfronthosting.co.za>
2016-12-14 01:45:53Victor Sergienkolinkissue28966 messages
2016-12-14 01:45:52Victor Sergienkocreate