Detecting focus-out event on a frame
I have a GtkFrame开发者_Go百科 containing a set of GtkEntries. I want to hide this GtkFrame when the focus is removed from the GtkFrame. I connected an handler to the "focus-out-event" signal of the frame, but it nevers get's invoked.
Any ideas on how to achieve this ?
Probably that your frame just never had the focus !
Try to give it the focus first :
theFrame.grab_focus()
Hope it works (I didn't test it)
"So what I need to "detect" is when the focus moves out of an element contained on the frame"
You may connect an event "focus-out-event" to every entry of your frame such as :
def outOfFocus(self, widget):
focusInFrame = False
for child in widget.get_parent():
if child.has_focus():
focusInFrame = True
if focusInFrame == False:
theFrame.hide()
I still did not test it, but will have more time this evening.
精彩评论