[pygtk] Re: custom popup dialog
Michael Baranov
michael.baranov at gmail.com
Sun Oct 14 03:24:54 WST 2007
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 =3D widget.get_allocation()
print allocation.x, allocation.y, allocation.width, allocation.height
if(__name__ =3D=3D "__main__"):
window =3D 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 =3D gtk.Entry()
entry2 =3D gtk.Entry()
=
entry1.connect("focus-in-event", on_focus_in)
entry2.connect("focus-in-event", on_focus_in)
box =3D 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 =3D entry.get_parent_window()
> origin =3D 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20071013/fc2b5ec4/at=
tachment.htm
More information about the pygtk
mailing list