Hi,
I have a problem with close/shutdown events not being caught when i
shutdown or log off in windows. I've bound all close-related events i
know of both to my App and Frame objects. The events are caught
properly when i manually close the application, but when i shutdown
windows or log off, nothing happens at all.
I've tested this in the following environments:
* 2 diffent VPC machines running windows XP
* 1 VPC running Vista SP1
* 1 real pc running Vista
* 1 real pc running Windows 7
The *only* events i caught were the EVT_QUERY_END_SESSION &
EVT_END_SESSION events on Windows 7. In ALL the other situation,
nothing is caught at all.
I'm working with wxPython 2.8.7.1 and Python 2.5.2.
I know for sure that the EVT_CLOSE event was being caught in earlier
versions of either python or wxPython, but i dont know since when this
problem started.
I need to catch the close events in my main application to close it in
a proper way, as it is now crashing when the user logs out while its
running. The code below is what i've used to isolate the problem.
Please ignore the ugly parts, it has been subject to hours of
tinkering/hacking
Thanks in advance for your help.
···
------------------------------------------
import wx
import time
def log(text):
logFile = open("log.txt", "a")
now = time.localtime()
timeString = "%04d/%02d/%02d %02d:%02d:%02d" % (now[0], now[1],
now[2], now[3], now[4], now[5])
print timeString + " " + text
logFile.write(timeString + " " + text + "\n")
logFile.close()
class Frame(wx.Frame):
def __init__(self, parent, ID, title,
pos=wx.DefaultPosition,size=wx.DefaultSize,
style=wx.DEFAULT_FRAME_STYLE):
wx.Frame.__init__(self, parent, ID, title, pos, size, style)
panel = wx.Panel(self, -1)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
#self.Bind(wx.EVT_QUERY_END_SESSION, self.OnCloseAppQuery)
#self.Bind(wx.EVT_END_SESSION, self.OnCloseApp)
def OnCloseAppQuery(self, event):
log("OnCloseAppQuery(): received close QUERY event!")
def OnCloseApp(self, event):
log("OnCloseApp(): received close event!")
def OnCloseWindow(self, event):
log("OnCloseWindow(): -FRAME- received close event!")
event.Skip()
class App(wx.App):
def OnInit(self):
self.frame = Frame(None, -1, "Test afsluiten")
self.frame.Show(True)
self.SetTopWindow(self.frame)
self.Bind(wx.EVT_QUERY_END_SESSION, self.frame.OnCloseAppQuery)
self.Bind(wx.EVT_END_SESSION, self.frame.OnCloseApp)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
return True
#def OnCloseAppQuery(self, event):
# log("OnCloseAppQuery(): received close QUERY event!")
#
#def OnCloseApp(self, event):
# log("OnCloseApp(): received close event!")
def OnExit(self):
log("OnExit(): called")
def OnCloseWindow(self, event):
log("OnCloseWindow(): -APP- received close event!")
app = App(0)
app.MainLoop()
--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en