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.

48 lines
1.3 KiB

2 years ago
2 years ago
  1. """
  2. All of the dialogs used throughout Gooey
  3. """
  4. from collections import namedtuple
  5. import wx # type: ignore
  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) # type: ignore
  9. def showDialog(title, content, style):
  10. dlg = wx.MessageDialog(None, content, title, style)
  11. dlg.SetYesNoLabels(_('dialog_button_yes'), _('dialog_button_no'))
  12. dlg.SetOKLabel(_('dialog_button_ok'))
  13. result = dlg.ShowModal()
  14. dlg.Destroy()
  15. return result
  16. def missingArgsDialog():
  17. showDialog(_('error_title'), _('error_required_fields'), wx.ICON_ERROR)
  18. def validationFailure():
  19. showDialog(_('error_title'), _('validation_failed'), wx.ICON_WARNING)
  20. def showSuccess():
  21. showDialog(_('execution_finished'), _('success_message'), wx.ICON_INFORMATION)
  22. def showFailure():
  23. showDialog(_('execution_finished'), _('uh_oh'), wx.ICON_ERROR)
  24. def confirmExit():
  25. result = showDialog(_('sure_you_want_to_exit'), _('close_program'), wx.YES_NO | wx.ICON_INFORMATION)
  26. return result == DialogConstants.YES
  27. def confirmForceStop():
  28. result = showDialog(_('stop_task'), _('sure_you_want_to_stop'), wx.YES_NO | wx.ICON_WARNING)
  29. return result == DialogConstants.YES