You can take all the GUI building logic and state source code from mainloop and include it in functions. Call these functions from mainloop (something like: buildgui () and initstate ()), and then when the user clicks your menu icon, just call initstate () to return it, as it was when you first started the application.