X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=InterfaceQT4%2FmonViewTexte.py;h=2dfcece64768a05113f98d3c31995779f7373d38;hb=96176d0080e0d4efbd29d98c0df700a64a82acdc;hp=8aeddc7ceec5e6d440f4fbc4015b8245ff2fb50a;hpb=283128d5842f911861917b3f15288479061afd64;p=tools%2Feficas.git
diff --git a/InterfaceQT4/monViewTexte.py b/InterfaceQT4/monViewTexte.py
index 8aeddc7c..2dfcece6 100644
--- a/InterfaceQT4/monViewTexte.py
+++ b/InterfaceQT4/monViewTexte.py
@@ -18,12 +18,19 @@
# 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
# ------------------------------- #
@@ -38,8 +45,9 @@ class ViewText(Ui_dView,QDialog):
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)
@@ -56,28 +64,21 @@ class ViewText(Ui_dView,QDialog):
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]
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 %(v_1)s n'a pu etre sauvegarde.
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))) ;
-
-