thanks a lot, man. it works!

2011-01-17






发件人: David Nečas <[email protected]>
发送时间: 2011-01-17 19:18
主 题: Re: how to get signal from child widget
收件人: "fengzi.gg" <[email protected]>
抄 送: gtk-list <[email protected]>





On Mon, Jan 17, 2011 at 02:49:33AM -0800, fengzi.gg wrote: 
> I've got a question: I have a parent-vbox, and I add some 
> child-widgets such as paned-box, label, entry, text-view in it. Now 
> when one(it could be anyone) of the child-widgets get focus in, I 
> wanna get the signal to handle something. 
>  
> How should I do? Should I connect "focus-in" signal to every 
> child-widget, or some better way? I tried to connect "focus-in" signal 
> to the parent-vbox, but seems not work. 

Only widgets that can receive keyboard focus themselves can emit 
"focus-in".  But containers have a "set-focus-child" signal so this 
might be what you need: 

===================================================================== 
import gtk 

win = gtk.Window(gtk.WINDOW_TOPLEVEL) 
win.connect('destroy', gtk.main_quit) 

hbox = gtk.HBox() 
win.add(hbox) 

def child_focused(widget, child, i): 
    print('A child in vbox #%u got focus.' % i) 

for i in range(3): 
    vbox = gtk.VBox() 
    hbox.add(vbox) 
    for j in range(5): 
        entry = gtk.Entry() 
        vbox.add(entry) 
    vbox.connect('set-focus-child', child_focused, i+1) 

win.show_all() 
gtk.main() 
===================================================================== 

Yeti 
_______________________________________________
gtk-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtk-list

Reply via email to