views:

93

answers:

1

I'm building an app that uses global shortcut keys (using python-keybinder), but there's a problem. The frame pops up and raises properly but doesn't have focus. I have to click on frame.

After I press my keyboard shortcut my frame appears, but it is not focused. I can see that the frame I was focused on previously (e.g. my Firefox frame) still has focus (i.e., the title bar is still white & bold). Only after I click on my app's frame does Firefox's title bar become grey and dim.

I try to SetFocus and CaptureMouse but neither do anything. FindFocus and GetCapture return None.

This only happens on Ubuntu (GNOME). On Windows, the frame gets focus immediately. Is there a way to force GNOME to give focus to my app/frame?

A: 

How are you showing the frmae initially, with frame.Show()? I'm not sure if you're saying the frame itself doesn't have focus (but/or a child of the frame does), or your application doesn't have focus?

Are you calling SetFocus in the Frame that initialises all your widgets? It could be an issue of the focus being given to a child of the frame. Try using wx.CallAfter(self.SetFocus) at the end of your Frame.init method - it should ensure the focus is set after all widget creation is done

Steven Sproat
I was not calling SetFocus in the init method. I was only calling it from my keyboard shortcut even handler. I tried your suggestion, but there still isn't focus. I also clarified my problem above.
Cristian