File: pyedit-products/unzipped/docetc/examples/Assorted-demos/Triage/phantom-dock-items-mac-tk85.py

from tkinter import *

def destroyer():
   popup = Toplevel()
   popup.title('destroyer')
   Button(popup, text='Destroy', command=popup.destroy, width=40).pack()
   popup.protocol('WM_DELETE_WINDOW', popup.destroy)

def quitter():
   popup = Toplevel()
   popup.title('quitter')
   Button(popup, text='Quit', command=popup.quit, width=40).pack()
   popup.protocol('WM_DELETE_WINDOW', popup.quit)

root = Tk()
root.title('root')
Button(root, text='destroyer', command=destroyer, width=40).pack()
Button(root, text='quitter', command=quitter, width=40).pack()
root.mainloop()




"""
----------------------------------------------------------------------
Date: Wed, 07 Dec 2016
pythonmac-sig@python.org
Phantom Dock menu entries for tkinter dialogs on Mac

When using Tk on a Mac (Python 3.5, ActiveState Tk 8.5, Mac 10.11),
why does the Python launcher retain Dock right-click menu entries 
for every Toplevel window that has been closed?  This doesn't happen
for common dialogs, but does for every custom dialog the closes with 
a widget.destroy().  It also happens for IDLE dialogs that are not 
withdrawn/redrawn, so it seems fairly pervasive.  

A simple demo of the problem is attached below: every "destroy" popup 
lingers on in the launcher's Dock menu after it's closed (whether by
the red "X" or the widget.destroy() callback), and remains in the Dock
menu until the main window is closed (by widget.quit() or otherwise).  
This happens whether the script is run by click or command line.

Any ideas?  The phantom Dock menu entries are useless (and even buggy)
for modal dialogs that have been dismissed.

Thanks,
--Mark Lutz, http://learning-python.com
----------------------------------------------------------------------
"""



[Home page] Books Code Blog Python Author Train Find ©M.Lutz