classification
Title: Menu.add_checkbutton has no checkmark on OS X
Type: enhancement Stage: resolved
Components: Tkinter Versions: Python 3.6
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: Victor Sergienko, ned.deily
Priority: normal Keywords:

Created on 2016-12-14 01:45 by Victor Sergienko, last changed 2016-12-14 02:04 by ned.deily. This issue is now closed.

Messages (2)
msg283153 - (view) Author: Victor Sergienko (Victor Sergienko) Date: 2016-12-14 01:45
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()
msg283156 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016-12-14 02:04
I'm not totally sure what behavior you expect but it *seems* to work OK for me using the current Python 3.5.2 or the pre-release 3.6.0rc1 from python.org OS X installers and with current ActiveTcl 8.5.18 installed as suggested (https://www.python.org/download/mac/tcltk/).  If you default to using the very out-of-date and buggy Apple-supplied system Tcl/Tk 8.5.9, the checkmark does not appear.
History
Date User Action Args
2016-12-14 02:04:47ned.deilysetstatus: open -> closed

nosy: + ned.deily
messages: + msg283156

resolution: third party
stage: resolved
2016-12-14 01:45:53Victor Sergienkocreate