wxPython: Transferring keyboard events from one frame to another

Discussion in 'Python' started by Ziv Forshtat, Feb 2, 2004.

  1. Ziv Forshtat

    Ziv Forshtat Guest

    Hi All,
    I'm in the process of implementing a virtual keypad: I have a wxFrame
    which contains a photo the keypad of some device, and I'm using it to
    enter special keywords into an editor window (wxStc). Each part of the
    photo is associated with a certain keyword, which is sent to the
    editor frame and displayed inside the editor. This is working fine.
    However, if I want a proper virtual keyboard I should also be able to
    transfer the regular keypresses (keyboard events) from my virtual
    keypad frame to the editor frame, in order to save the user the
    trouble of clicking on the editor window every time in order to set
    the focus.

    I tried using wxPostEvent to transfer the KEY_DOWN event from the
    keypad frame to the appropriate control in the editor frame. The
    problem is that the event which I am posting is only caught if I
    override the KEY_DOWN event. It does not find its way to the default
    event handler of this event.

    I have read that there are some problems with wxPostEvent in this
    context, but was wondering if someone has found a workaround for this
    issue, as this would be the simplest solution for my problem. Other
    ideas are also welcome...

    BTW, I'm working on MSW.

    Thanks,
    Ziv
    Ziv Forshtat, Feb 2, 2004
    #1
    1. Advertising

  2. > I'm in the process of implementing a virtual keypad: I have a wxFrame
    > which contains a photo the keypad of some device, and I'm using it to
    > enter special keywords into an editor window (wxStc). Each part of the
    > photo is associated with a certain keyword, which is sent to the
    > editor frame and displayed inside the editor. This is working fine.
    > However, if I want a proper virtual keyboard I should also be able to
    > transfer the regular keypresses (keyboard events) from my virtual
    > keypad frame to the editor frame, in order to save the user the
    > trouble of clicking on the editor window every time in order to set
    > the focus.


    Question:
    Is your 'virtual keypad' /showing keypresses/, or is your 'virtual
    keypad' used for text entry with a mouse?
    Josiah Carlson, Feb 3, 2004
    #2
    1. Advertising

  3. Ziv Forshtat

    Ziv Forshtat Guest

    Josiah Carlson <> wrote in message news:<bvmolq$aud$>...
    > > I'm in the process of implementing a virtual keypad: I have a wxFrame
    > > which contains a photo the keypad of some device, and I'm using it to
    > > enter special keywords into an editor window (wxStc). Each part of the
    > > photo is associated with a certain keyword, which is sent to the
    > > editor frame and displayed inside the editor. This is working fine.
    > > However, if I want a proper virtual keyboard I should also be able to
    > > transfer the regular keypresses (keyboard events) from my virtual
    > > keypad frame to the editor frame, in order to save the user the
    > > trouble of clicking on the editor window every time in order to set
    > > the focus.

    >
    > Question:
    > Is your 'virtual keypad' /showing keypresses/, or is your 'virtual
    > keypad' used for text entry with a mouse?


    Hi Josiah,
    My virtual keypad is used for text entry with a mouse, but I also want
    to transfer regular keyboard key presses from the keypad to the
    'client' window.

    Ziv
    Ziv Forshtat, Feb 3, 2004
    #3
  4. > Hi Josiah,
    > My virtual keypad is used for text entry with a mouse, but I also want
    > to transfer regular keyboard key presses from the keypad to the
    > 'client' window.


    If your virtual keypad is a subclass of wxDialog, you're going to have a
    problem. wxDialogs eat keypresses if you are not careful, especially 'tab'.

    You should instead try to use a plain wxFrame or wxMiniFrame (check the
    wxPython demo for code). Then just ignore keyboard events in the keypad
    window (using event.Skip()), they should be passed up the parent
    heirarchy and get to your main application without much effort. If this
    doesn't work for you, here's what I like to do:

    #parent frame
    def OnKeypress(self, event):
    #handle the standard keypress events

    #child frame
    def OnKeypress(self, event):
    self.parent.OnKeyPress(event)


    Get that event to the keypress handler, no matter what the cost *wink*.
    Another option would be to do the following:

    #child frame
    def OnKeypress(self, event):
    a = event.Copy()
    wxPostEvent(self.parent, a)


    I hope this helps,
    - Josiah
    Josiah Carlson, Feb 4, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vikram
    Replies:
    1
    Views:
    442
    =?Utf-8?B?TmlrYW5kZXIgJiBNYXJncmlldCBCcnVnZ2VtYW4=
    Feb 21, 2005
  2. Fred
    Replies:
    4
    Views:
    451
  3. Saketh
    Replies:
    1
    Views:
    519
    jean-michel bain-cornu
    Jun 12, 2006
  4. Stimp
    Replies:
    9
    Views:
    306
    Juan T. Llibre
    Dec 14, 2006
  5. Raghuram Banda

    Transferring value from one select box to another

    Raghuram Banda, Sep 23, 2003, in forum: Javascript
    Replies:
    1
    Views:
    109
    G Roydor
    Sep 24, 2003
Loading...

Share This Page