alert.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import gi
  2. from gi.repository import Gtk, Gdk, GdkPixbuf
  3. class Alert:
  4. def __init__(self, parent):
  5. self.parent = parent
  6. def show_error_markup(self, title, msg):
  7. '''
  8. Create an error message dialog with title and markup message.
  9. '''
  10. dialog = Gtk.MessageDialog(
  11. parent = self.parent,
  12. type = Gtk.MessageType.ERROR,
  13. buttons = Gtk.ButtonsType.OK)
  14. if self.parent:
  15. dialog.set_transient_for(self.parent)
  16. dialog.set_title(title)
  17. dialog.set_markup(msg)
  18. dialog.show()
  19. dialog.run()
  20. dialog.destroy()
  21. def show_warning(self, title, msg):
  22. '''
  23. Create an error message dialog with title and markup message.
  24. '''
  25. dialog = Gtk.MessageDialog(
  26. parent = self.parent,
  27. type = Gtk.MessageType.ERROR,
  28. buttons = Gtk.ButtonsType.OK,
  29. message_format = msg)
  30. if self.parent:
  31. dialog.set_transient_for(self.parent)
  32. dialog.set_title(title)
  33. dialog.show()
  34. dialog.run()
  35. dialog.destroy()