Here is a small standalone snippet illustrating of the problem.

The allocation for each of the 2 entries does *not* reflect the actual on-screen size of the widgets, but rather the space allocated for them by the container. Can somebody tell me what's happening? Why the entries are not resized to their allocations? How to solve my problem? Thanks!!!

#start
import gobject
import pygtk
pygtk.require('2.0')
import gtk

def on_focus_in(widget, event):
   allocation = widget.get_allocation()
   print allocation.x, allocation.y, allocation.width, allocation.height

if(__name__ == "__main__"):
   window = gtk.Window(gtk.WINDOW_TOPLEVEL)
   window.set_size_request(200, 100)
   window.set_title("GTK Entry")
   window.connect("delete_event", lambda w, e: gtk.main_quit())

   entry1 = gtk.Entry()
   entry2 = gtk.Entry()
entry1.connect("focus-in-event", on_focus_in)
   entry2.connect("focus-in-event", on_focus_in)

   box = gtk.VBox()
   window.add(box)

   box.add(entry1)
   box.add(entry2)

   window.show_all()
   window.show()
   gtk.main()
#end
Hello!

I'm implementing a custom popup window for a gtk.Entry. Actually it's a custom completion popup. but does not really matter. The real question is:

*for a given gtk.Entry (parented, realized) get location of the left-bottom corner of the entry in screen coordinates* (in order to position the popup window).


Part of the problem I solved myself:
    window = entry.get_parent_window()
    origin = window.get_origin()
origin returns left-top corner of window's client area in screen coordinates. It's OK.

But I'm not able to get *actual* entry position and size in window coordinates. entry.get_allocation() returns allocation which not always corresponds to *actual* on-screen size and position, but rather reflects he space devoted to the widget. For example putting gtk.Entry into gtk.VBox gives the above results.

Help is much appreciated! Thanks!
--
Michael Baranov

--
Michael Baranov

_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to