Friday, January 1, 2016

Python Tkinter destroy widget

For my status screen, I'd like to have some things come and go depending on what's happening. No problem; in Tkinter each widget has a destroy function. This was the first example I found; although the question in this forum thread is about how to make destroy() work, the actual problem was an interesting reminder of the importance of watching one's scope when assigning the results of a widget init!

http://stackoverflow.com/questions/17673662/tkinter-removing-a-button-from-a-running-program

While working on this feature I also leaned that depending on the layout manager being used and how the frame was defined, using destroy() could result in resizing of the frame. This tutorial covers layout managers excellently:

http://zetcode.com/gui/tkinter/layout/