开发者

Width of widget

开发者 https://www.devze.com 2023-01-09 11:34 出处:网络
In PyGTK what is the easiest way to figure out the dimensions of a widget? I know that it is easy to do with the gtk.Window object, but I can\'t find in the reference manual any way to get dimensions

In PyGTK what is the easiest way to figure out the dimensions of a widget? I know that it is easy to do with the gtk.Window object, but I can't find in the reference manual any way to get dimensions for the other objects.

Any 开发者_开发问答help is greatly appreciated thanks :D


You may be looking for the get_allocation method:

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

or size_request:

The size_request() method returns the preferred size of a widget as a tuple containing its required width and height. This method is typically used when implementing a gtk.Container subclass to arrange the container's child widgets and decide what size allocations to give them with the size_allocate() method. Obtaining a size request requires that the widget be associated with a screen, because font information may be needed.

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

The latter is what the widget would like to have as its size (given font information), the former what it's actually given by its container when it lays out the widgets.

0

精彩评论

暂无评论...
验证码 换一张
取 消