delete-event cannot be caught

Asked by guarini

I am trying to catch the delete-event signal from a dialog box.
I currently have the followign code but this does not work as expected

def on_about_delete_event(widget, data, wtree):
    widget.hide()
    return True

now this code should work but does not and I think it may be related with how gladex does it's magik

do you have any suggestions or am I missing something here?

thanks

Question information

Language:
English Edit question
Status:
Solved
For:
Gladex Edit question
Assignee:
No assignee Edit question
Solved by:
guarini
Solved:
Last query:
Last reply:
Revision history for this message
Christopher Pax (paxmanchris) said :
#1

The code you have is not the way you want to handle a dialog.

Take a good look at the code for the calculator example in the examples file. Look for the function on_about_dialog_activate in the calculator_callbacks file.

def on_about_dialog_activate(widget, data, wtree):
 about = wtree.get_widget("aboutdialog1")
 responce = about.run()
 if responce == gtk.RESPONSE_CANCEL or responce==gtk.RESPONSE_DELETE_EVENT:
  about.hide()
 pass

This function is called when a button is pressed (open the calculator glade file to see this). The gtk dialog returns a response id, which is really just a number. You then take that number and match it to one of the gtk constance (http://pygtk.org/docs/pygtk/gtk-constants.html).

Hope this helps you.

Revision history for this message
guarini (jguarini) said :
#2

not wanting to use the run() that example did not help.

I ended up creating the widget myself then hiding/showing at will.

thanks for your response

btw I appreciate the work that goes into this app, it's very handy

Revision history for this message
Christopher Pax (paxmanchris) said :
#3

And thank you for using it. Up until now we had no idea that there are people using are program.

So. Fear not to ask us any question or report any bugs.

If you have any suggestions or comments, please let us know.
you can email us: just check out the AUTHORS file for email.
or you can register a blueprint (where you can define a new feature you want in the program or plugin).

Thanks once again.

Revision history for this message
guarini (jguarini) said :
#4

one note: I had made a couple of changes since for some reason the app
was having issues finding gladex.glade in the current dir

basically I changed the following

gladex.py: self.gladefile =
os.path.abspath(os.curdir)+'/gladex.glade'

from

self.gladefile = os.path.split(__file__)[0]+'/gladex.glade'

did that in a few other files/places as well. If you would like I can
post a diff

-Jeremy

Revision history for this message
Charles Edward Pax (pax) said :
#5

I reported your your last comment as a bug #129355 (https://bugs.launchpad.net/gladex/+bug/129355). Let's move the conversation there. Question marked as solved.