glade aboutDialog doesn't close
Asked Answered
H

2

5

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?

Hexa answered 23/2, 2009 at 11:37 Comment(0)
M
5

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

Mozarab answered 23/2, 2009 at 13:22 Comment(3)
It's working, and I think I have a better understanding of how this all works, thanks again for your help.Hexa
can anyone tell me how to make an about window show up when i click an "about" button in glade ruby?Bacteroid
This works in the Python GTK+3 API too, as of 9th August of 2017.Sandpiper
J
6

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

Johnnyjumpup answered 23/5, 2009 at 3:56 Comment(0)
M
5

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

Mozarab answered 23/2, 2009 at 13:22 Comment(3)
It's working, and I think I have a better understanding of how this all works, thanks again for your help.Hexa
can anyone tell me how to make an about window show up when i click an "about" button in glade ruby?Bacteroid
This works in the Python GTK+3 API too, as of 9th August of 2017.Sandpiper

© 2022 - 2024 — McMap. All rights reserved.