Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #103478

Re: [Newbie] Tkinter Question

From Wildman <best_lay@yahoo.com>
Subject Re: [Newbie] Tkinter Question
Newsgroups comp.lang.python
References <Ye-dnZQLyOFiR1HLnZ2dnUU7-YPOydjZ@giganews.com>
Organization Wildman Productions
Message-ID <DumdnVLDRa4MEFPLnZ2dnUU7-fWdnZ2d@giganews.com> (permalink)
Date 2016-02-24 23:13 -0600

Show all headers | View raw


On Tue, 23 Feb 2016 16:19:43 -0600, Wildman wrote:

> <snip for brevity>

Thanks to Christian and Chris.  You both gave me much
to think about and to experiment with.  That adds to
my on-going learning experience.

This is the first thing I tried:

The Exit button has this:  command=self.quit

Then I have this:

def clean_up():
     # delete temp files

root = Tk()
app = Window(root)
root.protocol("DELETE_WINDOW", clean_up)
root.mainloop()

And I also tried:

root.wm_protocol("WM_DELETE_WINDOW", clean_up)

Both worked when the window [X] button was clicked but
neither worked when the Exit button was clicked.
However, when I removed the protocol statement and
replaced with this, it worked for both:

import atexit

atexit.register(clean_up)

Nothing I tried would fire the clean_up routine when
the program was force killed.

In addition I should mention that I can't us the OS
to delete the temp files because a shelled process
creates them.  It may be possible to still do it but
my limited experience does not allow me to pursue it.

Anyway, I am happy with the outcome even though I have
not found a way to detect when the program is force
killed.  It is unlikely that would ever occur as long
as the program does not lock up.  It is up to me to
make sure that doesn't happen. :-)

Thanks again.

-- 
<Wildman> GNU/Linux user #557453
"Philosophy is common sense with big words."
  -James Madison

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[Newbie] Tkinter Question Wildman <best_lay@yahoo.com> - 2016-02-23 16:19 -0600
  Re: [Newbie] Tkinter Question Christian Gollwitzer <auriocus@gmx.de> - 2016-02-23 23:37 +0100
  Re: [Newbie] Tkinter Question Chris Kaynor <ckaynor@zindagigames.com> - 2016-02-23 14:41 -0800
  Re: [Newbie] Tkinter Question Wildman <best_lay@yahoo.com> - 2016-02-24 23:13 -0600
    Re: [Newbie] Tkinter Question Randy Day <randy.day@sasktel.netx> - 2016-02-25 11:13 -0600

csiph-web