Thread: wxPython events

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2005
    Location
    Amsterdam, the Netherlands
    Posts
    12
    Rep Power
    0

    wxPython events


    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

    Code:
    frame.Bind(wx.EVT_KEY_UP, onKeyUp)
    , 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!
  2. #2
  3. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    DOwnload wxPython's Docs and Samples. Those will teach you (from examples) everything that you need to know.

IMN logo majestic logo threadwatch logo seochat tools logo