空地 aboutDialog 未关闭

发布于 2024-07-13 15:18:03 字数 207 浏览 18 评论 0原文

我有一个在林间空地制作的 AboutDialog 框,但“关闭”按钮不起作用。 我不知道如何将此按钮连接到单独的函数,因为它位于名为 dialog-action_area 的小部件中。

另一个问题是,如果我使用窗口管理器创建的关闭按钮,我无法再次打开它,因为它已被破坏。

我怎样才能改变它,让它隐藏起来?

I have an AboutDialog box made in glade, but the Close button doesn't work. I don't know how to connect this button to a separate function, since it sits in a widget called dialog-action_area.

Another problem is if I use the close button created by the window manager, I can't open it again because it has been destroyed.

How can I change this so it just hides?

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

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

发布评论

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

评论(2

紫瑟鸿黎 2024-07-20 15:18:03

与任何其他对话框窗口一样,它们要求您

  1. 使用 run 方法。
  2. 利用“响应”信号

第一个将阻塞主循环,并在对话框收到响应后立即返回,这可能是单击操作区域中的任何按钮或按 Esc,或调用对话框的响应方法或“销毁”窗口,最后一个并不意味着窗口将被销毁,这意味着 run() 方法将退出并返回响应。 像这样:

response = dialog.run()

如果您使用调试器,您会注意到主循环一直保留在那里,直到您单击按钮或尝试关闭对话框。 收到回复后,您就可以根据需要使用它。

response = dialog.run()
if response == gtk.RESPONSE_OK:
    #do something here if the user hit the OK button 
dialog.destroy()

第二个允许您以非阻塞方式使用对话框,然后您必须将对话框连接到“响应”信号。

def do_response(dialog, response):
    if response == gtk.RESPONSE_OK:
        #do something here if the user hit the OK button 
    dialog.destroy()

dialog.connect('response', do_response)

现在,您注意到必须销毁对话框

As any other Dialog window, they require you to

  1. Make use of the run method.
  2. Make use of the "reponse" signal

The first will block the main loop and will return as soon as the dialog receives a response, this may be, click on any button in the action area or press Esc, or call the dialog's response method or "destroy" the window, the last don't mean that the window wil be destroyed, this means that the run() method will exit and return a response. like this:

response = dialog.run()

If you use a debugger, you will notice that the main loop stays there until you click on a button or try to close the dialog. Once you have received yout response, then you can useit as you want.

response = dialog.run()
if response == gtk.RESPONSE_OK:
    #do something here if the user hit the OK button 
dialog.destroy()

The second allow you to use the dialog in a non-blocking stuff, then you have to connect your dialog to the "response" signal.

def do_response(dialog, response):
    if response == gtk.RESPONSE_OK:
        #do something here if the user hit the OK button 
    dialog.destroy()

dialog.connect('response', do_response)

Now, you notice that you have to destroy your dialog

明媚殇 2024-07-20 15:18:03

当您收到删除或取消信号时,您需要调用小部件的 hide() 方法:

response = self.wTree.get_widget("aboutdialog1").run() # or however you run it
if response == gtk.RESPONSE_DELETE_EVENT or response == gtk.RESPONSE_CANCEL:
  self.wTree.get_widget("aboutdialog1").hide()

您可以找到响应类型常量 GTK 文档

You need to call the widget's hide() method when you receive delete or cancel signals:

response = self.wTree.get_widget("aboutdialog1").run() # or however you run it
if response == gtk.RESPONSE_DELETE_EVENT or response == gtk.RESPONSE_CANCEL:
  self.wTree.get_widget("aboutdialog1").hide()

You can find the Response Type constants in the GTK documentation

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