2

I'm using Gtk to build an application on Linux using Python 3. I'm trying to use a Gtk.HeaderBar. So far it's been working Ok, but it seems that I can't get it to expand it's child widgets. For example:

Gtk.HeaderBar issue

As you can see above, I've tried putting my Gtk.Entry into the Gtk.HeaderBar, but even with things like Gtk.Entry.set_hexpand(True) it simply refuses to expand. I've even tried putting it inside a Gtk.Box, expanding the Gtk.Box, then adding the Gtk.Entry inside that. Even when I set the Gtk.Entry as a custom title for the Gtk.HeaderBar, this happens:

enter image description here

What's causing this? How can I fix it?

4

2 回答 2

1

启用hexpand仅表示您希望为小部件分配所有剩余空间;它实际上并没有调整您的小部件的大小。除了hexexpand之外,您还希望将halign属性设置为GTK_ALIGN_FILL(或在 Python 中调用的任何内容) 。

检查此页面上的图表以获得直观的解释。

于 2014-09-03T22:59:34.263 回答
1

您可以通过 window.set_titlebar 方法使用 Box 而不是 Headerbar

于 2015-12-04T21:24:14.483 回答