August 5th, 2005, 01:01 AM
I only recently got introduced to Python in general, and now I'm trying to get the hang of wxPython. So far that has really been a timeconsuming pain in the butt, especially getting a detailed understanding of how the events system works. For some reason I just can't seem to understand it, I can't find a decent tutorial or manual that just explains to me in simple steps how this works, starting from the beginning. All I find are very specific examples for a certain situation (for instance a button press), or complex api's that dazzle me with talk about event tables and wxValidators.
After messing around a long time I managed to bind some keys to my toplevel window (a frame object), using
, and I also set handlers for the wx.EVT_SET_FOCUS and an wx.EVT_KILL_FOCUS event types, using Bind(). This works fine until a widget in my window (for instance a checkbox) gets focus, then none of these bindings work anymore (and the wx.EVT_KILL_FOCUS event fires eventhough I don't want it to). So my question is: how can I make sure these events are handled by the topwindow, regardless of whether a contained object has focus? In Tkinter You could just use the bind_all() method, how does this work in wxPython? I use the wx.EVT_KILL_FOCUS to detect when the user switches to a different application, but apparently wx.EVT_KILL_FOCUS isn't really what I'm looking for. Which event type would be more suitable, and where can I find a good overview of available event types?
So basically what I want is:
- Key bindings that work everywhere in the application, regardless of what widget is selected
- A way to detect whether the application has focus or not
If anyone can help me, or knows a good tutorial for wxPython (besides http://wiki.wxpython.org/ and the wxWidgets api), please let me know!
August 5th, 2005, 03:40 PM
DOwnload wxPython's Docs and Samples. Those will teach you (from examples) everything that you need to know.