This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Can't reenable menus in Tkinter on Mac
Type: behavior Stage: resolved
Components: macOS, Tkinter Versions: Python 2.7
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: ronaldoussoren Nosy List: Mark.Bell, ned.deily, r.david.murray, ronaldoussoren
Priority: normal Keywords:

Created on 2014-06-14 14:04 by Mark.Bell, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
tkinter_test.py Mark.Bell, 2014-06-14 14:04
Messages (3)
msg220553 - (view) Author: Mark Bell (Mark.Bell) * Date: 2014-06-14 14:04
The following example is a Tkinter app with a button that toggles the menu being enabled based off of https://mail.python.org/pipermail/tkinter-discuss/2004-September/000204.html

#-----------------------------------

from Tkinter import *

root=Tk()

def hello():
    print('hello!')

def toggle():
	print('I think the menu bar is %s' % menubar.entrycget(0, 'state'))
	if menubar.entrycget(0, 'state')=='normal':
		print('disabling')
		menubar.entryconfig(0,state=DISABLED)
		print('disbled')
	else:
		print('enabling')
		menubar.entryconfig(0,state=NORMAL)
		print('enabled')

menubar = Menu(root)
submenu = Menu(menubar, tearoff=0)
submenu.add_command(label='Hello', command=hello)
menubar.add_cascade(label='test', menu=submenu)

# this cascade will have index 0 in submenu
b = Button(root, text='Toggle', command=toggle)
b.pack()

# display the menu
root.config(menu=menubar)
root.mainloop()

#-----------------------------------

On Windows 7 and Ubuntu 14.04 (using Python 2.7.6 and Tkinter Revision 81008) clicking the button toggles the menu being enabled. However, on Mac 10.9 (again under Python 2.7.6 and Tkinter Revision 81008) the menu becomes stuck disabled. 

Additionally, the example also prints out what state it thinks the menu has (using entrycget) and it would print out that it thought that the menu was in fact alternating between enabled and disabled.

Others have verified this being the case. See: http://stackoverflow.com/questions/24207870/cant-reenable-menus-in-python-tkinter-on-mac
msg220554 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-06-14 14:13
Given the description it sounds likely that this is a tk bug.
msg220571 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2014-06-14 17:35
Yes, it is a Tk bug.  The Cocoa version of Tk 8.5 that Apple has been shipping since OS X 10.6 has numerous problems that have been fixed in more recent versions of Tk 8.5.  With the current ActiveTcl 8.5.15, your test appears to work correctly.  Unfortunately, you can't easily change the version of Tcl/Tk that the Apple-supplied system Pythons use.  One option is to install the current Python 2.7.7 from the python.org binary installer along with ActiveTcl 8.5.15.  There is more information here:

https://www.python.org/download/mac/tcltk/
https://www.python.org/downloads/
History
Date User Action Args
2022-04-11 14:58:04adminsetgithub: 65956
2014-06-14 17:35:36ned.deilysetstatus: open -> closed
resolution: third party
messages: + msg220571

stage: resolved
2014-06-14 14:14:55r.david.murraysetnosy: + ned.deily
2014-06-14 14:13:51r.david.murraysetnosy: + r.david.murray, ronaldoussoren
messages: + msg220554

assignee: ronaldoussoren
components: + macOS
2014-06-14 14:04:10Mark.Bellcreate