Macro MessageBox/it: Difference between revisions
mNo edit summary |
(Updating to match new version of source page) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
{{Macro/it |
{{Macro/it |
||
|Name=MessageBox |
|Name=MessageBox |
||
|Icon=Macro MessageBox.png |
|||
|Translate=Finestre di messaggi |
|Translate=Finestre di messaggi |
||
|Description=Mostra come fornire informazioni all'utente attraverso l'interfaccia grafica. |
|Description=Mostra come fornire informazioni all'utente attraverso l'interfaccia grafica. |
||
Line 7: | Line 8: | ||
|Version=1.0 |
|Version=1.0 |
||
|Date=2011-09-19 |
|Date=2011-09-19 |
||
|FCVersion=Tutte |
|||
|Download=[https://www.freecadweb.org/wiki/images/7/7f/Macro_MessageBox.png Icon] |
|||
}} |
}} |
||
Line 16: | Line 19: | ||
==Script== |
==Script== |
||
ToolBar Icon [[Image:Macro_MessageBox.png]] |
|||
'''Macro_MessageBox.FCMacro''' |
'''Macro_MessageBox.FCMacro''' |
||
{{ |
{{MacroCode|code= |
||
#! /usr/bin/env python |
#! /usr/bin/env python |
||
# -*- coding: utf-8 -*- |
# -*- coding: utf-8 -*- |
||
Line 42: | Line 47: | ||
In order to use the accented characters in the text field from '''Qt''', using the tag ''' #-*-coding: utf-8-*- ''' must be added a '''u''' before the message to display<br /> Example : |
In order to use the accented characters in the text field from '''Qt''', using the tag ''' #-*-coding: utf-8-*- ''' must be added a '''u''' before the message to display<br /> Example : |
||
{{ |
{{MacroCode|code= |
||
diag = QtGui.QMessageBox(QtGui.QMessageBox.Warning, u'Trop d'éléments désignés', msg) |
diag = QtGui.QMessageBox(QtGui.QMessageBox.Warning, u'Trop d'éléments désignés', msg) |
||
... |
... |
||
Line 54: | Line 59: | ||
Example : |
Example : |
||
{{ |
{{MacroCode|code= |
||
diag = QtGui.QMessageBox(QtGui.QMessageBox.Information,u"Coordonnées",u"Coordonnée X : "+str(x)+"\r\n"+u"Coordonnée Y : "+str(y)+"\n"+u"Coordonnée Z :<br> |
diag = QtGui.QMessageBox(QtGui.QMessageBox.Information,u"Coordonnées",u"Coordonnée X : "+str(x)+"\r\n"+u"Coordonnée Y : "+str(y)+"\n"+u"Coordonnée Z :<br> |
||
"+str(z)+"\nRayon\t : "+str(r)) |
"+str(z)+"\nRayon\t : "+str(r)) |
Latest revision as of 11:09, 23 May 2020
Descrizione |
---|
Mostra come fornire informazioni all'utente attraverso l'interfaccia grafica. Versione macro: 1.0 Ultima modifica: 2011-09-19 Versione FreeCAD: Tutte Download: Icon Autore: Gaël Ecorchard |
Autore |
Gaël Ecorchard |
Download |
Icon |
Link |
Raccolta di macro Come installare le macro Personalizzare la toolbar |
Versione macro |
1.0 |
Data ultima modifica |
2011-09-19 |
Versioni di FreeCAD |
Tutte |
Scorciatoia |
Nessuna |
Vedere anche |
Nessuno |
Descrizione
Mostra come fornire informazioni all'utente attraverso l'interfaccia grafica.
MessageBox
Script
Macro_MessageBox.FCMacro
#! /usr/bin/env python # -*- coding: utf-8 -*- """Show how to give information to the user in macros """ from PySide 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))
In order to use the accented characters in the text field from Qt, using the tag #-*-coding: utf-8-*- must be added a u before the message to display
Example :
diag = QtGui.QMessageBox(QtGui.QMessageBox.Warning, u'Trop d'éléments désignés', msg) ... ... msg = u'Élément sélectionnés affichés'
To display multiple lines in a dialog box Qt, must be added "\n" (quotation, valid also between apostrophes) between each line.
Valid also "\r\n" which correspond to CR carriage return, and LF end of line, valid also " \t" is a tab, characters should be between quotation marks (and apostrophes) as a character string, the tags can be found next to the text to display " \nRayon\t: ", the tag " \ " (reversed slash) defines the command.
Example :
diag = QtGui.QMessageBox(QtGui.QMessageBox.Information,u"Coordonnées",u"Coordonnée X : "+str(x)+"\r\n"+u"Coordonnée Y : "+str(y)+"\n"+u"Coordonnée Z :<br> "+str(z)+"\nRayon\t : "+str(r))