[pygtk] grab_focus

Alessandro Dentella sandro at e-den.it
Fri May 16 15:50:28 WST 2008


On Fri, May 16, 2008 at 09:19:01AM +0200, Alessandro Dentella wrote:
> hi,
> 
>   I want to let an entry to (be created and) get the focus when I select a
>   menu item on another window.
> 
>   I'm using grab_focus, but that only does half of the job. It get focus *if
>   I move the mouse over the window of the entry*.
> 
>   I'd rather have the mouse stay where it is. How can I do that?
>   I'm afraid that depends on the focus model of the window manager but I'm
>   not sure.


It turns out grab_focus works as expected if the creation of the entry (and
successive grab_focus) starts from the callback ov a click on an eventBox,
but not from the menu entry. Can it depend on some interaction with the menu
entry? 

I set it with this code:


   item = gtk.MenuItem(label="add %s to filter" % field_name.replace('_', ' '))
   item.connect('activate', self.filter_panel.add, ev, field_name )
   menu.append(item)


where sel.filter_panel.add works correctly if called from the EventBox cb.


TIA
sandro


More information about the pygtk mailing list