Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In GTK, how do I get the actual size of a widget on screen?

First I looked at the get_size_request method. The docs there end with:

To get the size a widget will actually use, call the size_request() instead of this method.

I look at size_request(), and it ends with

Also remember that the size request is not necessarily the size a widget will actually be allocated.

So, is there any function in GTK to get what size a widget actually is? This is a widget that is on-screen and actually being displayed, so GTK definitely has this information somewhere.

like image 288
Claudiu Avatar asked Aug 05 '09 16:08

Claudiu


1 Answers

This should be it (took some time to find):

The get_allocation() method returns a gtk.gdk.Rectangle containing the bounds of the widget's allocation.

From here.

like image 83
balpha Avatar answered Oct 22 '22 06:10

balpha