[pygtk] Event ordering

Yang Zhang yanghatespam at gmail.com
Wed Jan 28 16:23:02 WST 2009

Walter Leibbrandt wrote:
> Hi,
> Yang Zhang wrote:
>> Yang Zhang wrote:
>>> Hi, I'm trying to position a pop-up Window to always be directly 
>>> under an Entry box, but I'm not sure what signal(s) to react to.
>>> For instance, I tried entry.connect_after('focus-in-event', ...) to 
>>> handle the initial positioning (I also hide the window on 
>>> 'focus-out-event'), and that mostly seems to work, but if I resize 
>>> the window, the reaction is too early since the geometry of the entry 
>>> is not yet fully updated.  How can I handle this situation 
>>> appropriately?
>> Another example: I'd like to set the cursor position in the entry to 
>> the end of the text whenever focus changes to the entry, but doing 
>> this from focus-in-event doesn't work (the entire text still gets 
>> highlighted).
> http://www.pygtk.org/docs/pygtk/class-gtkwidget.html#signal-gtkwidget--configure-event 

Hi, thanks for the reply.  I think that doesn't work and/or you 
misunderstood.  Demo:


from gtk import *
e = Entry()
def handler(*args): print e.get_window().get_geometry()
#e.connect('focus-in-event', handler) 

e.connect('configure-event', handler)
h = HBox()
w = Window()

Try resizing/moving the window - nothing happens.

If you uncomment the commented line, then you'll see that the geometry 
doesn't get updated as soon as you resize the window - only on the next 
move/resize will you see the (prior) updated geometry printed.
Yang Zhang

More information about the pygtk mailing list