From 7be378954e21b2a1b25e8f3715d646786cb737be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCdepohl?= Date: Fri, 10 Jun 2016 23:07:47 +0200 Subject: [PATCH] PathProfile.py: Fix non-GUI usage The call to QtGui.QApplication.translate is not possible and necessary without a GUI --- src/Mod/Path/PathScripts/PathProfile.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathProfile.py b/src/Mod/Path/PathScripts/PathProfile.py index b1d397458..acbdef707 100644 --- a/src/Mod/Path/PathScripts/PathProfile.py +++ b/src/Mod/Path/PathScripts/PathProfile.py @@ -33,6 +33,14 @@ if FreeCAD.GuiUp: import FreeCADGui from PySide import QtCore, QtGui from DraftTools import translate + # Qt tanslation handling + try: + _encoding = QtGui.QApplication.UnicodeUTF8 + def translate(context, text, disambig=None): + return QtGui.QApplication.translate(context, text, disambig, _encoding) + except AttributeError: + def translate(context, text, disambig=None): + return QtGui.QApplication.translate(context, text, disambig) else: def translate(ctxt, txt): return txt @@ -43,16 +51,6 @@ __url__ = "http://www.freecadweb.org" """Path Profile object and FreeCAD command""" -# Qt tanslation handling -try: - _encoding = QtGui.QApplication.UnicodeUTF8 - def translate(context, text, disambig=None): - return QtGui.QApplication.translate(context, text, disambig, _encoding) -except AttributeError: - def translate(context, text, disambig=None): - return QtGui.QApplication.translate(context, text, disambig) - - class ObjectProfile: def __init__(self, obj):