[issue21757] Can't reenable menus in Tkinter on Mac

Mark Bell report at bugs.python.org
Sat Jun 14 16:04:10 CEST 2014


New submission from Mark Bell:

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

----------
components: Tkinter
files: tkinter_test.py
messages: 220553
nosy: Mark.Bell
priority: normal
severity: normal
status: open
title: Can't reenable menus in Tkinter on Mac
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file35628/tkinter_test.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21757>
_______________________________________


More information about the Python-bugs-list mailing list