OK, so let’s try to solve your issues in a simple way
So simply add AddInput() and use gVirtualX->GrabKey(), like for example with ctrl-s:
yourFrame->AddInput(kKeyPressMask);
gVirtualX->GrabKey(yourFrame->GetId(), gVirtualX->KeysymToKeycode(kKey_s),
kKeyControlMask, on);
You can try to add gVirtualX->SetInputFocus(yourFrame->GetId());
in addition to the method described above, but this will work only if the Window Manager allows it, and we cannot prevent other applications to steal the focus… There is not much we can do to change the way the Window Manager control the focus (but you can most probably change your WM settings)
There are several ways in C++, but I’m afraid I can’t really help on the Python side…
Cheers, Bertrand