Aw: Catching key press events while model wx.MessageDialog(...) is shown?
Karsten Hilbert <[email protected]> Tue, 1 Jun 2021 13:22:41 +0200
| Newsgroups | gmane.comp.python.wxpython |
|---|---|
| Message-ID | <trinity-7e46315b-969a-4710-96b5-64dcba669f05-1622546561477@3c-app-gmx-bap68> |
Is there really a need to *stop* cold the background thread ? Or would it suffice to "abandon" the worker thread, leaving it to its own devices ? Karsten Gesendet: Montag, 31. Mai 2021 um 22:15 Uhr Von: "[email protected]" <[email protected]> An: "wxPython-users" <[email protected]> Betreff: [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] . To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/7eaaf026-4c98-4389-8c2a-cd2d6b1f8c6en%40googlegroups.com . -- 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/trinity-7e46315b-969a-4710-96b5-64dcba669f05-1622546561477%403c-app-gmx-bap68 .