error_message.py 617 B

123456789101112131415161718192021
  1. import gtk
  2. import textwrap
  3. def info_message(message):
  4. """Creates a GTK MessageDialog and displays a message in it"""
  5. message = textwrap.wrap(message, 50)
  6. mes = ""
  7. for lines in message:
  8. mes += lines + "\n"
  9. dialog = gtk.MessageDialog(None,
  10. gtk.DIALOG_MODAL,
  11. gtk.MESSAGE_INFO,
  12. gtk.BUTTONS_NONE,
  13. mes)
  14. dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_CLOSE)
  15. response = dialog.run()
  16. dialog.hide()
  17. if response == gtk.RESPONSE_CLOSE:
  18. dialog.destroy()