用按钮填充 gtk.Dialog 窗口的操作区域 - 而不是让它们向右对齐
使用 PyGTK,我使用 add_button()
方法在 gtk.Dialog
的操作区域中创建一堆按钮,如下所示:
self.replace_all_button = self.add_button(_("Replace All"),
gtk.RESPONSE_ACCEPT)
生成的对话框将所有按钮对齐到右侧,如下图所示:
但是,我想用按钮填充操作区域,就像此图像:
我尝试了一些奇怪的策略,例如从操作区域,如下面的代码所示,但它不起作用。
def redefine_packing(widget):
_, _, padding, _ = self.action_area.query_child_packing(widget)
self.action_area.set_child_packing(widget, True, True, padding, _)
self.action_area.foreach(redefine_packing)
我怎样才能做到呢? (如果我可以直观地从原始语言翻译解决方案,则不需要用 Python 编写解决方案,我通常可以做到)
Using PyGTK, I create a bunch of buttons in the action area of a gtk.Dialog
using the add_button()
method, as below:
self.replace_all_button = self.add_button(_("Replace All"),
gtk.RESPONSE_ACCEPT)
The resulting dialog has all the buttons aligned to the right, as seen in the following image:
However, I want to fill the action area with the buttons, just like in this image:
I have tried some curious strategies, such as to redefine the packing parameters of all widgets from the action area, as seen in the code below, but it did not work.
def redefine_packing(widget):
_, _, padding, _ = self.action_area.query_child_packing(widget)
self.action_area.set_child_packing(widget, True, True, padding, _)
self.action_area.foreach(redefine_packing)
How could I do it? (A solution does not need to be written in Python if I can intuitively translate it from the original language, which I usually can do)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您可以用普通的
hbox
替换对话框中的hbuttonbox
,然后更轻松地控制打包。Maybe you could replace the
hbuttonbox
in the dialog with a normalhbox
and then more easily control the packing.当我发现我正在寻找一个不存在的问题时,我的问题就“解决了”。
我正在尝试复制 Gedit 搜索和替换窗口的外观。然后我使用“C”语言环境启动 Gedit,搜索和替换对话框如下所示:
所以我试图复制的对话框就像我拥有的对话框一样。我看到的原始对话框似乎有所不同,只是因为它的标签采用不同的语言并且更大。
My problem was "solved" when I discovered I was looking for a nonexistent problem.
I am trying to copying the look-and-feel fo the Gedit search and replace window. Then I started Gedit using the "C" locale and the search and replace dialog looked like this:
So the dialog I am trying to copy is just like the dialog I have. The original dialog I was looking at seemed different just because its labels were in a different language and were bigger.