开发者

pygtk: how to manually emit signal

I have an gtk.Entry() object, and I would like to ma开发者_运维知识库nually emit the focus-out-event. What is the second parameter that I need to pass to the emit method?

In [10]: d.emit('focus-out-event')
TypeError: 1 parameters needed for signal focus-out-event; 0 given

In [11]: d.emit('focus-out-event', d)
TypeError: could not convert type gtk.Entry to GdkEvent required for parameter 0


You need a gtk.gdk.Event as the second parameter.

Here's how you create one: (disclaimer, I didn't test this)

event = gtk.gdk.Event(gtk.gdk.FOCUS_CHANGE)
event.window = entry.get_window()  # the gtk.gdk.Window of the widget
event.send_event = True  # this means you sent the event explicitly
event.in_ = False  # False for focus out, True for focus in

You can look up the different types of event and what parameters they require on the page I linked to above.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜