RE: Catching key press events while model wx.MessageDialog(...) is shown?
Steve Barnes <[email protected]> Tue, 1 Jun 2021 02:39:57 +0000
| Newsgroups | gmane.comp.python.wxpython |
|---|---|
| Message-ID | <VI1PR03MB657546D9797F0312D657186A9B3E9@VI1PR03MB6575.eurprd03.prod.outlook.com> |
Wouldn't a wx.ProgressDialog or a wx.agw.pyprogress be more appropriate than a modal wx.MessageDialog? You can optionally have an abort button (in addition to the "Stop" and check the returned values when you update it. AFAIK when a progress dialog is shown any active keyboard shortcut bindings should work & you can always disable other controls to have much the same effect as a modal dialog. Steve Barnes From: [email protected] <[email protected]> On Behalf Of [email protected] Sent: 31 May 2021 21:16 To: wxPython-users <[email protected]> Subject: [wxPython-users] Catching key press events while model wx.MessageDialog(...) is shown? I have a program that runs a long task in a background thread, and shows a modal wx.MessageDialog(...) in the foreground with a "Stop" button to stop the background thread. The long task is a sequence of work cycles, and the "Stop" button stops the sequence after completing the currently running cycle. So far, all is good (as in the attached example code). I would like to add a mechanism that allows stopping the background thread immediately (without waiting to complete the current cycle) by pressing a key or key combination on the keyboard. For example, pressing the 'K' key on the keyboard should trigger a call to worker_thread.kill() in the attached example code. What would be a good appraoch to make this work? Is there a way to hook into the event loop of the wx.MessageDialog(...) to check for key press events? Of is there another way to check for key presses? -- You received this message because you are subscribed to the Google Groups "wxPython-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]<mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/7eaaf026-4c98-4389-8c2a-cd2d6b1f8c6en%40googlegroups.com<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fwxpython-users%2F7eaaf026-4c98-4389-8c2a-cd2d6b1f8c6en%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=04%7C01%7C%7C9926c02dad9d4780d99f08d92470e839%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637580889607705786%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=8yZVVmwlXfj%2FkjOjmcn932CbmhCjorg9oyUImAbFdqs%3D&reserved=0>. -- You received this message because you are subscribed to the Google Groups "wxPython-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/VI1PR03MB657546D9797F0312D657186A9B3E9%40VI1PR03MB6575.eurprd03.prod.outlook.com.