GtkAboutDialog 关闭按钮错误

发布于 2024-09-27 03:41:56 字数 391 浏览 6 评论 0原文

我使用 GtkAboutDialog,除了这个小部件的关闭按钮之外,一切正常。所有其他按钮都工作正常,我不知道如何,但所有按钮都有默认回调,并且它们创建和销毁窗口。 但是 GtkAboutDialog 小部件的“关闭”按钮不起作用。我什至看不到它的小部件。那么,我可以访问它吗?

[澄清] 您看到的是 gtk.AboutDialog — 显示有关应用程序信息的弹出窗口(PyGTK 2.6 中的新增功能)。该窗口包含“关闭”按钮小部件,该小部件包含在 GtkHButtonBox 小部件中。 GtkHButtonBox 小部件是我能够访问的最高级别的小部件。关于如何到达“关闭”按钮并连接回调信号的处理程序有什么想法吗?

替代文本

I use GtkAboutDialog and everything works fine except the close button of this widget. All other buttons works fine, I don't know how but all buttons have default callbacks and they create and destroy the windows.
But the "Close" button of GtkAboutDialog widget does not work. I can not even see it's widget. So, can I access it?

[CLARIFICATION] What you're looking at is gtk.AboutDialog — popup window displaying information about an application (new in PyGTK 2.6). This window contains the 'close' button widget which is contained in a GtkHButtonBox widget. The GtkHButtonBox widget is the highest level widget I am able to access for some. Any ideas on how to get to the "close" button and connect a handler for a callback signal?

alt text

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

旧故 2024-10-04 03:41:56

对话框的信号连接方式与窗口的连接方式不同。我在学习PyGTK时也犯过同样的错误。

对话框最基本的形式是显示并运行对话框:

aboutdialog.run()

通常您会立即调用:

aboutdialog.destroy()

.run() 行是一个循环,它一直运行直到对话框中发生某些情况。

这里有一个有效的示例

You don't conenct signals in the same way for a dialog as you do for a window. I made the same mistake when learning PyGTK.

The most basic form of a dialog is you display and run the dialog with:

aboutdialog.run()

Often you will then immediately call:

aboutdialog.destroy()

The .run() line is a loop, which runs until something happens within the dialog.

There is a working example here.

森林迷了鹿 2024-10-04 03:41:56

gtk.AboutDialog 只是一个 gtk.Dialog,您可以以相同的方式处理来自它的响应。对话框代码不会连接到按钮的单击信号,而是为您处理该信号并从 run() 调用返回响应。您可以检查返回的响应值来确定单击了哪个按钮。

如果您尝试覆盖某些行为,则可以连接到 gtk.Dialogresponse 信号。

The gtk.AboutDialog is just a gtk.Dialog, and you handle responses from it in the same way. Instead of connecting to the clicked signal of the buttons, the dialog code handles that for you and returns a reponse from your run() call. You can check the value of the response returned to figure out what button was clicked.

If you're trying to override some behaviour instead, you can connect to the response signal of gtk.Dialog.

檐上三寸雪 2024-10-04 03:41:56

这是一个老问题,但由于它是谷歌的第一批点击之一,我想我应该提出我找到的解决方案。您需要一个事件处理程序来显示“关于”对话框,并需要一个事件处理程序来关闭它。第一个可能会连接到您的 help->about menuitem 的 activate 信号。后者应该连接到 about 对话框的 response 信号。这两个处理程序将如下所示:

def on_menuitemHelpAbout_activate(self, *args):
    self.builder.get_object('aboutdialog').show()
def on_aboutdialog_response(self, *args):
    self.builder.get_object('aboutdialog').hide()

在上面的示例中,我使用 GtkBuilder 来查找我的 about 对话框,因为我已经使用 Glade 构建了界面。请注意,我使用 .show() 而不是 .run(),因为我看不到在对话框关闭之前暂停程序执行的意义。最后,可以使响应处理程序根据响应采取任何操作,但我在这里忽略它。

This is an old question, but since it's one of the first hits from google, I thought I'd throw in the solution that I found. You need an event handler to show the about dialog and one to close it. The first will likely be connected to your help->about menuitem's activate signal. The latter should be connected to the response signal of the about dialog. The two handlers will look something like this:

def on_menuitemHelpAbout_activate(self, *args):
    self.builder.get_object('aboutdialog').show()
def on_aboutdialog_response(self, *args):
    self.builder.get_object('aboutdialog').hide()

In the example above, I'm using the GtkBuilder to find my about dialog because I've constructed the interface with glade. Note that I'm using .show() over .run() because I don't see the sense in pausing program execution until the dialog is closed. Finally, the response handler can be made to take whatever action depending upon the response, but I'm ignoring it here.

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