Electronics & Programming


Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » GTK+
  • » 回复: Re: how to get signal from child widget [RSS Feed]

#1 Jan. 17, 2011 12:00:47

Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

回复: Re: how to get signal from child widget

thanks a lot, man. it works!


发件人: David Nečas <y***@*hysics.muni.cz>
发送时间: 2011-01-17 19:18
主 题: Re: how to get signal from child widget
收件人: "fengzi.gg" <fengzi***@*mail.com>
抄 送: gtk-list <gtk-l***@*nome.org>

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()

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

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


gtk-list mailing list


  • Root
  • » GTK+
  • » 回复: Re: how to get signal from child widget [RSS Feed]

Board footer

Moderator control

Enjoy the 11th of December

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support