From 633cc86b6d47c7350e829c7101e15687d5e1084b Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Wed, 1 Feb 2017 17:50:32 +0100 Subject: [PATCH] PN: imports and connects --- src/HYDROGUI/HYDROSOLVERGUI.py | 6 +-- src/salome_hydro/gui_utils.py | 13 +++-- src/salome_hydro/interpolz_gui.py | 59 ++++++++++------------ src/salome_hydro/mascaret/eficas/appli.py | 3 +- src/salome_hydro/pytel/eficas/appli.py | 3 +- src/salome_hydro/pytel/genjobwindow.py | 17 +++---- src/salome_hydro/telemac2d/eficas/appli.py | 3 +- 7 files changed, 49 insertions(+), 55 deletions(-) diff --git a/src/HYDROGUI/HYDROSOLVERGUI.py b/src/HYDROGUI/HYDROSOLVERGUI.py index bb2f422..c921a47 100755 --- a/src/HYDROGUI/HYDROSOLVERGUI.py +++ b/src/HYDROGUI/HYDROSOLVERGUI.py @@ -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) diff --git a/src/salome_hydro/gui_utils.py b/src/salome_hydro/gui_utils.py index cc080aa..7684fe6 100644 --- a/src/salome_hydro/gui_utils.py +++ b/src/salome_hydro/gui_utils.py @@ -16,9 +16,10 @@ # along with SALOME HYDRO module. If not, see . 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 diff --git a/src/salome_hydro/interpolz_gui.py b/src/salome_hydro/interpolz_gui.py index b521c04..a3a5842 100644 --- a/src/salome_hydro/interpolz_gui.py +++ b/src/salome_hydro/interpolz_gui.py @@ -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 ): diff --git a/src/salome_hydro/mascaret/eficas/appli.py b/src/salome_hydro/mascaret/eficas/appli.py index b5fe084..1fd1326 100644 --- a/src/salome_hydro/mascaret/eficas/appli.py +++ b/src/salome_hydro/mascaret/eficas/appli.py @@ -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 diff --git a/src/salome_hydro/pytel/eficas/appli.py b/src/salome_hydro/pytel/eficas/appli.py index 35f6695..1f86a10 100644 --- a/src/salome_hydro/pytel/eficas/appli.py +++ b/src/salome_hydro/pytel/eficas/appli.py @@ -18,8 +18,7 @@ import os import sys -from PyQt5.QtGui import * -from PyQt5.QtWidgets import * +from PyQt5.QtWidgets import QMessageBox import salome diff --git a/src/salome_hydro/pytel/genjobwindow.py b/src/salome_hydro/pytel/genjobwindow.py index df7df10..8e1b5f0 100644 --- a/src/salome_hydro/pytel/genjobwindow.py +++ b/src/salome_hydro/pytel/genjobwindow.py @@ -16,24 +16,23 @@ # along with SALOME HYDRO module. If not, see . 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"]) diff --git a/src/salome_hydro/telemac2d/eficas/appli.py b/src/salome_hydro/telemac2d/eficas/appli.py index 0df10c2..369995a 100644 --- a/src/salome_hydro/telemac2d/eficas/appli.py +++ b/src/salome_hydro/telemac2d/eficas/appli.py @@ -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 -- 2.39.2