# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2013 EDF R&D
+# Copyright (C) 2007-2017 EDF R&D
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
# Modules Python
-import string,types,os
+from __future__ import absolute_import
+try :
+ from builtins import str
+except : pass
+
+import types,os
import traceback
from Extensions.i18n import tr
-from PyQt4.QtGui import *
-from PyQt4.QtCore import *
+import six
+
+from PyQt5.QtWidgets import QDialog, QMessageBox, QFileDialog
+from PyQt5.QtCore import QSize
from desViewTexte import Ui_dView
# ------------------------------- #
self.setupUi(self)
self.resize( QSize(largeur,hauteur).expandedTo(self.minimumSizeHint()) )
- self.connect( self.bclose,SIGNAL("clicked()"), self, SLOT("close()") )
- self.connect( self.bsave,SIGNAL("clicked()"), self.saveFile )
+ self.bclose.clicked.connect(self.close)
+ self.bsave.clicked.connect(self.saveFile )
+
if entete != None : self.setWindowTitle (entete)
if entete != None : self.setText (texte)
def saveFile(self):
#recuperation du nom du fichier
if self.editor != None :
- dir=self.editor.appliEficas.CONFIGURATION.savedir
+ dir=self.editor.appliEficas.maConfiguration.savedir
else:
dir='/tmp'
fn = QFileDialog.getSaveFileName(None,
tr("Sauvegarder le fichier"),
dir)
- if fn.isNull() : return
- ulfile = os.path.abspath(unicode(fn))
+ fn=fn[0]
+ if fn == "" : return
+ if fn == None : return (0, None)
+
+ ulfile = os.path.abspath(six.text_type(fn))
if self.editor != None :
- self.editor.appliEficas.CONFIGURATION.savedir=os.path.split(ulfile)[0]
+ self.editor.appliEficas.maConfiguration.savedir=os.path.split(ulfile)[0]
try:
- f = open(fn, 'wb')
+ f = open(fn, 'w')
f.write(str(self.view.toPlainText()))
f.close()
return 1
- except IOError, why:
+ except IOError as why:
QMessageBox.critical(self, tr("Sauvegarder le fichier"),
- tr("Le fichier <b>%(v_1)s</b> n'a pu etre sauvegarde. <br>Raison : %(v_2)s", {'v_1': unicode(fn), 'v_2': unicode(why)}))
+ tr('Le fichier')+str(fn) + tr('n a pas pu etre sauvegarde : ') + str(why))
return
-class ViewText2(ViewText):
- def __init__(self,parent,cmd,editor=None,entete=None,texte=None,largeur=600,hauteur=600):
- ViewText.__init__(self,parent,editor,entete,texte,largeur,hauteur)
- import subprocess
- p = subprocess.Popen(cmd,stdout=subprocess.PIPE)
- (output, err) = p.communicate()
- if output != None : self.view.append(QString.fromUtf8(output,len(output))) ;
- if err != None : self.view.append(QString.fromUtf8(err,len(err))) ;
-
-