]> SALOME platform Git repositories - modules/hydrosolver.git/commitdiff
Salome HOME
PN: imports and connects
authorPaul RASCLE <paul.rascle@edf.fr>
Wed, 1 Feb 2017 16:50:32 +0000 (17:50 +0100)
committerPaul RASCLE <paul.rascle@edf.fr>
Wed, 1 Feb 2017 16:50:32 +0000 (17:50 +0100)
src/HYDROGUI/HYDROSOLVERGUI.py
src/salome_hydro/gui_utils.py
src/salome_hydro/interpolz_gui.py
src/salome_hydro/mascaret/eficas/appli.py
src/salome_hydro/pytel/eficas/appli.py
src/salome_hydro/pytel/genjobwindow.py
src/salome_hydro/telemac2d/eficas/appli.py

index bb2f4222807b1d5e3928e32c2065de1dcf593abe..c921a47368664c005d1f12aef6f802cbef540312 100755 (executable)
@@ -20,9 +20,7 @@ import os
 import traceback
 import logging
 
-from PyQt5.QtCore import *
-from PyQt5.QtGui import *
-from PyQt5.QtWidgets import *
+from PyQt5.QtWidgets import QMessageBox, QApplication, QDialog
 
 import salome
 import SALOME
@@ -316,7 +314,7 @@ class MyTextDisplayDialog(Ui_TextDisplayDialog, QDialog):
         QDialog.__init__(self, parent)
         Ui_TextDisplayDialog.__init__(self)
         self.setupUi(self)
-        self.connect(self.closeButton, SIGNAL("clicked()"), self.close)
+        (self.closeButton.clicked.connect(self.close)
     
     def set_log(self, log):
         self.contentTextEdit.setPlainText(log)
index cc080aab08fb4e1250aded43617fefdf9d8f17b9..7684fe68dec6e230625b27b135a6e534ef478279 100644 (file)
 #  along with SALOME HYDRO module.  If not, see <http://www.gnu.org/licenses/>.
 
 import os
-from PyQt5.QtCore import *
-from PyQt5.QtGui import *
-from PyQt5.QtWidgets import *
+#from PyQt4 import QtCore, QtGui
+from PyQt5.QtWidgets import QApplication
+from PyQt5.QtGui  import QCursor
+from PyQt5.QtCore import Qt
 
 import salome
 from salome.kernel.studyedit import getStudyEditor
@@ -41,11 +42,14 @@ class OverrideCursorCM:
     self.cursor = cursor
   
   def __enter__(self):
+    #QtGui.QApplication.setOverrideCursor(self.cursor)
     QApplication.setOverrideCursor(self.cursor)
   
   def __exit__(self, exc_type, exc_value, traceback):
+    #QtGui.QApplication.restoreOverrideCursor()
     QApplication.restoreOverrideCursor()
 
+#wait_cursor = OverrideCursorCM(QCursor(QtCore.Qt.WaitCursor))
 wait_cursor = OverrideCursorCM(QCursor(Qt.WaitCursor))
 
 
@@ -58,6 +62,7 @@ def get_and_check_selected_file_path():
   sobj = ed.study.FindObjectID(salome.sg.getSelected(0))
   filepath = sobj.GetComment()
   if not os.path.isfile(filepath):
+    #raise HSGUIException(QtGui.QApplication.translate("get_and_check_selected_file_path",
     raise HSGUIException(QApplication.translate("get_and_check_selected_file_path",
-                                                      "File %1 does not exist").arg(filepath))
+                                                 "File %1 does not exist").arg(filepath))
   return filepath
index b521c0423203db7a855d3908b420a6e9ff5fe283..a3a5842978a7f3ddcc217b7fad286e404c9a92a8 100644 (file)
@@ -1,8 +1,9 @@
 
 import sys, os
-#sys.path.append(os.path.join(os.environ['MED3HOME'], 'lib/python2.7/site-packages/med'))
+#sys.path.append(os.path.join(os.environ['MEDFILE_ROOT_DIR'], 'lib/python2.7/site-packages/med'))
+sys.path.append(os.path.join(os.environ['MEDFICHIER_INSTALL_DIR'], 'lib/python2.7/site-packages/med'))
 hydro_solver_root = os.path.join(os.environ['HYDROSOLVER_ROOT_DIR'], 'lib', 'python2.7', 'site-packages', 'salome', 'salome', 'hydro')
-#sys.path.append(hydro_solver_root)
+sys.path.append(hydro_solver_root)
 
 import salome
 salome.salome_init()
@@ -10,9 +11,7 @@ salome.salome_init()
 import MEDLoader
 import HYDROPy
 
-from PyQt5.QtCore import *
-from PyQt5.QtGui import *
-from PyQt5.QtWidgets import *
+from PyQt5.QtWidgets import QDialog, QFileDialog, QTableWidgetItem, QComboBox, QMessageBox
 from PyQt5 import uic
 
 import SalomePyQt
@@ -22,7 +21,7 @@ salome_gui = libSALOME_Swig.SALOMEGUI_Swig()
 from generate_interpolz import generate
 
 def get_med_groups( file_path ):
-    print "get_med_groups", file_path
+    #print "get_med_groups", file_path
     try:
         meshes = MEDLoader.GetMeshNames(file_path)
     except:
@@ -34,7 +33,7 @@ def get_med_groups( file_path ):
     mesh1 = meshes[0]
     print 'Found mesh:', mesh1
     try:
-        groups = list(MEDLoader.MEDLoader_GetMeshGroupsNames(file_path, mesh1))
+        groups = list(MEDLoader.GetMeshGroupsNames(file_path, mesh1))
         print 'Found groups:', groups
     except:
         print 'No groups found'
@@ -51,12 +50,12 @@ def get_hydro_regions( calc_case_name ):
       for r in regions:
         rname = r.GetName()
         regions_names.append( str(rname) )
-
-      #shape_groups = case.GetGeometryGroups()
-      #for sg in shape_groups:
-          #sgname = sg.GetName()
-          #regions_names.append( sgname )
-
+      
+      shape_groups = case.GetGeometryGroups()
+      for sg in shape_groups:
+          sgname = sg.GetName()
+          regions_names.append( sgname )
+      
       return regions_names
     else:
       return []
@@ -72,7 +71,7 @@ def get_selected_calc_case():
             if isinstance(case, HYDROPy.HYDROData_CalculationCase):
                 return name
     return None
-
+    
 class InterpolzDlg( QDialog ):
     def __init__(self, parent = None):
         QDialog.__init__( self, parent )
@@ -91,30 +90,30 @@ class InterpolzDlg( QDialog ):
         self.Apply.clicked.connect(self.onApply)
         self.Close.clicked.connect(self.onClose)
         self.Help.clicked.connect(self.onHelp)
-
+         
     def onSelectionChanged( self ):
         calc_case_name = get_selected_calc_case()
         if calc_case_name is not None:
           self.CalcCase.setText( calc_case_name )
-
+          
     def onOutputFile( self ):
       caption = "Python file"
       mask = "*.py"
       fname, filt = QFileDialog.getSaveFileName( self, caption, ".", mask )
       if fname!=None and fname!="":
         self.OutputPath.setText( fname )
-
+      
     def onMEDFile( self ):
       caption = "MED file"
       mask = "*.med"
       fname, filt = QFileDialog.getOpenFileName( self, caption, ".", mask )
       if fname!=None and fname!="":
         self.MEDFile.setText( fname )
-
+        
     def onCalcCaseChanged( self ):
       self.regions = get_hydro_regions( str(self.CalcCase.text()) )
       self.onMEDChanged()
-
+        
     def onMEDChanged( self ):
       self.med_groups = get_med_groups( str(self.MEDFile.text()) )
       print self.med_groups
@@ -125,9 +124,8 @@ class InterpolzDlg( QDialog ):
           self.Groups.setItem( i, 0, QTableWidgetItem() )
           self.Groups.setItem( i, 1, QTableWidgetItem() )
         self.Groups.item( i, 0 ).setText( self.med_groups[i] )
-
+        
         cb = QComboBox( self.Groups )
-        cb.addItem( 'None' )
         for r in self.regions:
           cb.addItem( r )
         self.Groups.setCellWidget( i, 1, cb )
@@ -135,7 +133,7 @@ class InterpolzDlg( QDialog ):
     def onApplyClose( self ):
         if self.onApply():
             self.onClose()
-
+        
     def onApply( self ):
         path = str(self.OutputPath.text())
         calc_case = str(self.CalcCase.text())
@@ -144,11 +142,11 @@ class InterpolzDlg( QDialog ):
         for i in range( 0, self.Groups.rowCount() ):
             med_group = str( self.Groups.item( i, 0 ).text() )
             hydro_reg = str( self.Groups.cellWidget( i, 1 ).currentText() )
-            if len(med_group)>0 and len(hydro_reg)>0 and hydro_reg != 'None':
+            if len(med_group)>0 and len(hydro_reg)>0:
                 med_groups_regions[med_group] = hydro_reg
         z_undef = self.UndefZ.value()
         interp = str(self.InterpMethod.currentText())
-
+        
         msg = ""
         if len(path)==0:
             msg = "Please input the output path"
@@ -160,21 +158,18 @@ class InterpolzDlg( QDialog ):
             msg = "Please fill groups table"
         elif len(interp)==0:
             msg = "Please choose interpolation method"
-
+        
         result = False
         if len(msg)==0:
-            iinterp = 0
-            if "Linear" in interp:
-              iinterp =1
-            generate( path, calc_case, med_file, med_groups_regions, z_undef, iinterp )
+            generate( path, calc_case, med_file, med_groups_regions, z_undef, interp )
             msg = "InterpolZ script is successfully generated"
             result = True
-
+            
         QMessageBox.information( self, "", msg )
         return result
-
+        
     def onClose( self ):
-        self.close()
+        self.close()     
 
     """Shows help page"""
     def onHelp( self ):
index b5fe0841829ac324d8e25e32a39e4a69cca50866..1fd132631e967cdb471d12abb3f70fee173ec967 100644 (file)
@@ -21,8 +21,7 @@ import os
 import sys
 import re
 
-from PyQt5.QtGui import *
-from PyQt5.QtWidgets import *
+from PyQt5.QtWidgets import QMessageBox 
 
 
 import salome
index 35f669592ac3a49b5d7c4f72701a2556661221b9..1f86a10069fea0e101a6fd4661d0b154ca3ed87f 100644 (file)
@@ -18,8 +18,7 @@
 import os
 import sys
 
-from PyQt5.QtGui import *
-from PyQt5.QtWidgets import *
+from PyQt5.QtWidgets import QMessageBox 
 
 
 import salome
index df7df10fe74952c47c824f241580a0605a9193d4..8e1b5f03d89032510244ade9365fca4a024d1f20 100644 (file)
 #  along with SALOME HYDRO module.  If not, see <http://www.gnu.org/licenses/>.
 
 import os
-from PyQt5.QtCore import *
-from PyQt5.QtGui import *
-from PyQt5.QtWidgets import *
+from PyQt5.QtWidgets import QDialog , QFileDialog
 
 import salome
 from salome.hydro.pytel.genjob import generate_job
 from genjobwindow_ui import Ui_GenJobDialog
 
 
-class GenJobDialog(QtGui.QDialog, Ui_GenJobDialog):
+class GenJobDialog(QDialog, Ui_GenJobDialog):
 
   def __init__(self, parent, pytel_params):
-    QtGui.QDialog.__init__(self, parent)
+    QDialog.__init__(self, parent)
     self.setupUi(self)
-    self.connect(self.dialogButtonBox, SIGNAL("accepted()"), self.validate)
-    self.connect(self.dialogButtonBox, SIGNAL("rejected()"), self.close)
-    self.connect(self.chooseInputDataDirectoryButton, SIGNAL("clicked()"), self.choose_input_dir)
-    self.connect(self.chooseResultDirectoryButton, SIGNAL("clicked()"), self.choose_result_dir)
+    self.dialogButtonBox.accepted.connect(self.validate)
+    self.dialogButtonBox.rejected.connect( self.close)
+    self.chooseInputDataDirectoryButton.clicked.connect( self.choose_input_dir)
+    self.chooseResultDirectoryButton.clicked.connect(self.choose_result_dir)
+
     self.telemacRootDirLE.setText("/home/projets-bgq/systel/V6P2")
     self.telemacEnvFileLE.setText("/home/projets-bgq/systel/V6P2/config/pysource.zumbrota.xlf14.sh")
     casedir = os.path.dirname(pytel_params["FICHIER_CAS"])
index 0df10c2360fdf73c0e5dac838e7098dc633f31ac..369995aed783a3d531d86cb3008df8fd1254700b 100644 (file)
@@ -21,8 +21,7 @@ import os
 import sys
 import re
 
-from PyQt5.QtGui import *
-from PyQt5.QtWidgets import *
+from PyQt5.QtWidgets import QMessageBox
 
 
 import salome