Electronics & Programming

develissimo

Open Source electronics development and programming

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

#1 Jan. 17, 2011 10:49:54

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

how to get signal from child widget


hello there,

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.

Thanks

2011-01-17_______________________________________________
gtk-list mailing list
gtk-list@gnome.orghttp://mail.gnome.org/mailman/listinfo/gtk-list

Offline

#2 Jan. 17, 2011 11:19:03

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

how to get signal from child widget


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
gtk-list@gnome.orghttp://mail.gnome.org/mailman/listinfo/gtk-list

Offline

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

Board footer

Moderator control

Enjoy the 24th of August
PoweredBy

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