You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.2 KiB

  1. """
  2. All of the dialogs used throughout Gooey
  3. """
  4. from collections import namedtuple
  5. import wx
  6. from gooey.gui.lang.i18n import _
  7. # These don't seem to be specified anywhere in WX for some reason
  8. DialogConstants = namedtuple('DialogConstants', 'YES NO')(5103, 5104)
  9. def showDialog(title, content, style):
  10. dlg = wx.MessageDialog(None, content, title, style)
  11. result = dlg.ShowModal()
  12. dlg.Destroy()
  13. return result
  14. def missingArgsDialog():
  15. showDialog(_('error_title'), _('error_required_fields'), wx.ICON_ERROR)
  16. def validationFailure():
  17. showDialog(_('error_title'), _('validation_failed'), wx.ICON_WARNING)
  18. def showSuccess():
  19. showDialog(_('execution_finished'), _('success_message'), wx.ICON_INFORMATION)
  20. def showFailure():
  21. showDialog(_('execution_finished'), _('uh_oh'), wx.ICON_ERROR)
  22. def confirmExit():
  23. result = showDialog(_('sure_you_want_to_exit'), _('close_program'), wx.YES_NO | wx.ICON_INFORMATION)
  24. return result == DialogConstants.YES
  25. def confirmForceStop():
  26. result = showDialog(_('stop_task'), _('sure_you_want_to_stop'), wx.YES_NO | wx.ICON_WARNING)
  27. return result == DialogConstants.YES