{"action":"opened","issue":{"url":"https://api.github.com/repos/wxWidgets/Phoenix/issues/504","repository_url":"https://api.github.com/repos/wxWidgets/Phoenix","labels_url":"https://api.github.com/repos/wxWidgets/Phoenix/issues/504/labels{/name}","comments_url":"https://api.github.com/repos/wxWidgets/Phoenix/issues/504/comments","events_url":"https://api.github.com/repos/wxWidgets/Phoenix/issues/504/events","html_url":"https://github.com/wxWidgets/Phoenix/issues/504","id":255609304,"number":504,"title":"wxPython ignores OS signal to close application immediately (Windows)","user":{"login":"cztomczak","id":1187415,"avatar_url":"https://avatars2.githubusercontent.com/u/1187415?v=4","gravatar_id":"","url":"https://api.github.com/users/cztomczak","html_url":"https://github.com/cztomczak","followers_url":"https://api.github.com/users/cztomczak/followers","following_url":"https://api.github.com/users/cztomczak/following{/other_user}","gists_url":"https://api.github.com/users/cztomczak/gists{/gist_id}","starred_url":"https://api.github.com/users/cztomczak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cztomczak/subscriptions","organizations_url":"https://api.github.com/users/cztomczak/orgs","repos_url":"https://api.github.com/users/cztomczak/repos","events_url":"https://api.github.com/users/cztomczak/events{/privacy}","received_events_url":"https://api.github.com/users/cztomczak/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-09-06T13:45:20Z","updated_at":"2017-09-06T13:45:20Z","closed_at":null,"author_association":"NONE","body":"**Operating system**:\r\nWindows 10 Pro\r\n\r\n**wxPython version**:\r\nReproducible on both 3.0.0.2 and 4.0.0b1 msw (phoenix)\r\n\r\n**Stock or custom build**:\r\nNo\r\n\r\n**Python version**:\r\n2.7.13\r\n\r\n**Stock or custom build**:\r\nNo\r\n\r\n**Description of the problem**:\r\n\r\nI have `class MainFrame(wx.Frame):` in which I bind `wx.EVT_CLOSE`. My application has an option to minimize to system tray when close button is closed, thus when Close event gets called I do not close the window, I just hide it. User can quit application using 'Quit' menu option in system tray icon. Everything works fine except when operating system signals application to exit, this happens in two scenarios:\r\n\r\n1. User clicks \"End task\" on application in Task Manager\r\n2. User Restarts OS (Start > Power > Restart)\r\n\r\nIn both of these scenarios occur, in OnClose, event.CanVeto() returns True, which I believe is incorrect, it should return False. From documentation:\r\n\r\n```\r\nCanVeto(self)\r\nReturns True if you can veto a system shutdown or a window close event.\r\n\r\nVetoing a window close event is not possible if the calling code wishes to \r\nforce the application to exit, and so this function must be called to check this.\r\n```\r\nand\r\n\r\n```\r\nVeto(self, veto=True)\r\nCall this from your event handler to veto a system shutdown or to signal to the \r\ncalling application that a window close did not happen.\r\n\r\nYou can only veto a shutdown if CanVeto returns True.\r\n```\r\n\r\nRef: https://wxpython.org/Phoenix/docs/html/wx.CloseEvent.html#wx.CloseEvent.CanVeto\r\n\r\nSo what I do is check `event.CanVeto()`, it returns True, so I do not close application and then call `event.Veto()` (whether I call it doesn't change anything). This is causing OS to terminate my application immediately without any warning and it results in ugly message boxes alerting about `Memory Read` errors and/or `Exception breakpoint`.\r\n\r\nI have tested with both wxPython 3 and wxPython 4 and it behaves the same on Windows 10, `event.CanVeto()` always returns True. On Mac OS X `event.CanVeto()` works fine and returns False when it should.\r\n\r\nIs there some workaround for this, how can I differentiate if the Close event is User clicking X close button or whether it is OS telling to quit?"}}
{"actor":{"display_login":"cztomczak"}}