Macro MessageBox: Difference between revisions

From FreeCAD Documentation
(Show how to give information to the user in macros)
 
mNo edit summary
Line 1: Line 1:
{{Macro|Name=MessageBox|Description=Show how to give information to the user in macros|Author=Gaël Ecorchard}}
#! /usr/bin/env python
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
Line 17: Line 18:
raise(Exception(msg))
raise(Exception(msg))


{{languages | {{es|Macro_MessageBox/es}} }}
{{Macro|Name=MessageBox|Description=Show how to give information to the user in macros|Author=Gaël Ecorchard}}

Revision as of 22:50, 19 September 2011

Generic macro icon. Create your personal icon with the same name of the macro MessageBox

Description
Show how to give information to the user in macros

Author: Gaël Ecorchard
Author
Gaël Ecorchard
Download
None
Links
Macro Version
1.0
Date last modified
None
FreeCAD Version(s)
None
Default shortcut
None
See also
None

#! /usr/bin/env python
# -*- coding: utf-8 -*-

"""Show how to give information to the user in macros
"""
from PyQt4 import QtCore, QtGui

def errorDialog(msg):
    # Create a simple dialog QMessageBox
    # The first argument indicates the icon used: one of QtGui.QMessageBox.{NoIcon, Information, Warning, Critical, Question} 
    diag = QtGui.QMessageBox(QtGui.QMessageBox.Warning, 'Error in macro MessageBox', msg)
    diag.setWindowModality(QtCore.Qt.ApplicationModal)
    diag.exec_()

msg = 'Example of warning message'
errorDialog(msg)
raise(Exception(msg))
Available translations of this page: