宽度

2024-04-25 15:18:58 发布

您现在位置:Python中文网/ 问答频道 /正文

在PyGTK中,什么是计算小部件尺寸的最简单方法?我知道这是很容易做到的gtk.窗口对象,但我在参考手册中找不到任何方法来获取其他对象的尺寸。你知道吗

非常感谢您的帮助


Tags: 对象方法gtk部件尺寸pygtk参考手册
1条回答
网友
1楼 · 发布于 2024-04-25 15:18:58

您可能正在寻找get_allocation方法:

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

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.

后者是小部件希望拥有的大小(给定字体信息),前者是在布局小部件时由其容器实际给定的大小。你知道吗

相关问题 更多 >

    热门问题