How to make python tkinter root close itself only? -


i have number of roots (frames) in program. how set command os's exit button (the x @ top of panel)? want make can close 1 pane, not entire program. found code making own exit button on frame itself, don't want have reset position of buttons have.

edit: forgot mention i'm using ubuntu

edit2:

root3 = tk() root = tk() root2 = tk() 

this how i'm initializig objects 3 frames (i don't have enough reputation post images). looked @ toplevel , think bryan oakley means should this:

frame1 = toplevel() frame2 = toplevel() frame3 = toplevel() 

however, doing makes fourth (empty) frame appear, while 3 need still intact widgets need present.

could explain difference between using tk() , toplevel() , how each meant used?

i attempted use fredrik's solution received following error:

traceback (most recent call last):   file "gui_robot_control.py", line 823, in <module>     root.protocol("wm_delete_window", root.destroy())   file "/usr/lib/python2.7/lib-tk/tkinter.py", line 1630, in wm_protocol     'wm', 'protocol', self._w, name, command) _tkinter.tclerror: can't invoke "wm" command:  application has been destroyed 

thanks in advance!

not clear if mean multiple tk instances or multiple toplevel windows, if need control happens when user clicks close button on either of them, can use register protocol handler:

widget.protocol("wm_delete_window", handler) 

after call, close button call function handler instead of closing window. default behaviour similar to:

widget.protocol("wm_delete_window", widget.destroy) 

(yes, bit obscure, tkinter book should explain this)


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -