Terry J. Reedy <tjre...@udel.edu> added the comment:
You neglected to state the observation that led to the conclusion of 'not linked'. Using 3.8 on Win10, I replaced "plt.set_cmap('x')" with "tk.Tk()". Then, clicking the button prints 'False' even when the checkbutton is checked. After either removing 'tk.Tk()' *or* changing 'BooleanVar()' to 'BooleanVar(root)', button clicks print 'True' when the checkbutton is checked. Explanation of what I see: tkinter has attribute tkinter._default_root initialized to None. By default, this is rebound to the *first* root created by an internal or user tkinter.Tk() call. Barring exceptional circumstances, one should either always use the default root and never create and pass a named root *or* never use the default one and create a named root and always pass it. Your program is buggy in using the default root for the var and the named root for the buttons. When the two are different, the expected linkage does not work. I assume that you see the same failure with the code you posted and the same fix after (re)moving the .set_cmap call. So I am further assuming that set_cmap somehow results in a default root being created and that fixing the buggy BooleanVar call will also fix things. To test the set_cmap assumption, add "print(tk._default_root)" *before* "root = tk.Tk()". Do you see 'None' or '.'? Does adding 'root' to the var call fix the link? If you seen 'None' and the link still does not work, then 'set_cmap' must be affecting tkinter some other way, which would likely be a 3rd party bug in that function or pyplot. ---------- nosy: +terry.reedy resolution: -> not a bug stage: -> resolved status: open -> closed versions: +Python 3.7, Python 3.8, Python 3.9 -Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue38292> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com