Here is a fix that we use instead of the built in widget method. The one built
into widget wasn't returning quite the right size.
def get_real_abs_rect(widget):
"""Get the absolute position and dimensions of a widget on the screen.
(Does what gui.Widget.get_abs_rect() claims to do, but actually does it
correctly.)"""
# HACK: This gets into the PGU GUI implementation details quite a bit.
# The code here is copied from get_abs_rect(self) in pgu/gui/widget.py,
# without the lines that add self._rect_content.x/y to x/y. This seems
# slightly less likely to break in a future PGU version than simply
# subtracting widget._rect_content.x/y from the results of
# Widget.get_abs_rect(), because the bug in get_abs_rect may be fixed in a
# future version.
x, y = widget.rect.x, widget.rect.y
c = getattr(widget,'container',None)
while c:
x += c.rect.x
y += c.rect.y
if hasattr(c,'_rect_content'):
x += c._rect_content.x
y += c._rect_content.y
c = getattr(c,'container',None)
return pygame.Rect(x, y, widget.rect.w, widget.rect.h)
Original issue reported on code.google.com by sliverdr...@gmail.com on 6 Jul 2010 at 10:42
Original issue reported on code.google.com by
sliverdr...@gmail.com
on 6 Jul 2010 at 10:42