用按钮填充 gtk.Dialog 窗口的操作区域 - 而不是让它们向右对齐

发布于 2024-11-19 06:51:29 字数 773 浏览 5 评论 0原文

使用 PyGTK,我使用 add_button() 方法在 gtk.Dialog 的操作区域中创建一堆按钮,如下所示:

self.replace_all_button = self.add_button(_("Replace All"), 
            gtk.RESPONSE_ACCEPT)

生成的对话框将所有按钮对齐到右侧,如下图所示:

gtk.Dialog,操作按钮右对齐

但是,我想用按钮填充操作区域,就像此图像:

在此处输入图像描述

我尝试了一些奇怪的策略,例如从操作区域,如下面的代码所示,但它不起作用。

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:

gtk.Dialog with action buttons aligned to the right

However, I want to fill the action area with the buttons, just like in this image:

enter image description here

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

丿*梦醉红颜 2024-11-26 06:51:29

也许您可以用普通的 hbox 替换对话框中的 hbuttonbox,然后更轻松地控制打包。

Maybe you could replace the hbuttonbox in the dialog with a normal hbox and then more easily control the packing.

嘿咻 2024-11-26 06:51:29

当我发现我正在寻找一个不存在的问题时,我的问题就“解决了”。

我正在尝试复制 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:

Search and replace dialog with labels in English

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文