# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2011-2015 EDF R&D
+# Copyright (C) 2011-2016 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
from omniORB import CORBA
-from PyQt4.QtCore import QObject, SIGNAL, SLOT
-from PyQt4.QtGui import QIcon, QStandardItemModel, QStandardItem, QMessageBox
+from qtsalome import QIcon, QStandardItemModel, QStandardItem, QMessageBox, pyqtSignal
from inputframe_ui import Ui_InputFrame
-from inputdata import InputData
+from .inputdata import InputData
DEBUG_MODE=True
GROUPNAME_MAXLENGTH=8
TBL_HEADER_LABEL=["Input Mesh", "Output group name"]
+ inputValidated = pyqtSignal()
+
def __init__(self, parent=None, name="InputDialog", modal=0):
"""
This initializes a dialog windows to define the input data of
icon.addFile(os.path.join(iconfolder,"steelbar.png"))
self.__ui.cmbMeshType.setItemIcon(meshTypeIndex, icon)
self.MESHTYPE_ICONS[meshTypeIndex] = icon
-
+
# The click on btnSmeshObject (signal clicked() emitted by the
# button btnSmeshObject) is connected to the slot
# onSelectSmeshObject, etc ...
- self.connect(self.__ui.btnSmeshObject, SIGNAL('clicked()'), self.onSelectSmeshObject )
- self.connect(self.__ui.btnAddInput, SIGNAL('clicked()'), self.onAddInput )
- self.connect(self.__ui.btnDeleteInput, SIGNAL('clicked()'), self.onDeleteInput )
+ self.__ui.btnSmeshObject.clicked.connect( self.onSelectSmeshObject )
+ self.__ui.btnAddInput.clicked.connect( self.onAddInput )
+ self.__ui.btnDeleteInput.clicked.connect( self.onDeleteInput )
# Set up the model of the Qt table list
self.__inputModel = QStandardItemModel(0,2)
self.__ui.tblListInput.horizontalHeader().setStretchLastSection(True)
# Note that the type is not display explicitly in the Qt table
# because it is specified using an icon on the text of the
- # name item.
+ # name item.
+
+ # Setup default values for numerical parameters
+ self.__ui.txtParamNbIter.setValue(3)
# Note that PADDER does not support group name longer than 8
# characters. We apply then this limit in the gui field.
# been validated so that it can process the event
GenericDialog.accept(self)
if self.wasOk():
- self.emit(SIGNAL('inputValidated()'))
+ self.inputValidated.emit()
def onSelectSmeshObject(self):
'''
creates a new entry in the list of input data, or updates this
entry if it already exists.
"""
- meshName = str(self.__ui.txtSmeshObject.text().trimmed())
+ meshName = str(self.__ui.txtSmeshObject.text()).strip()
meshObject = self.__selectedMesh
meshType = self.__ui.cmbMeshType.currentIndex()
- groupName = str(self.__ui.txtGroupName.text().trimmed())
+ groupName = str(self.__ui.txtGroupName.text()).strip()
self.__addInputInGui(meshName, meshObject, meshType, groupName)
self.__addInputInMap(meshName, meshObject, meshType, groupName)
"""
# if the entry already exists, we remove it to replace by a
# new one
- if self.__dictInputData.has_key(meshName):
+ if meshName in self.__dictInputData:
self.__delInputFromMap(meshName)
-
+
inputData = InputData()
inputData.meshName = meshName
inputData.meshObject = meshObject
else:
self.__nbSteelbarMesh += 1
- print inputData
- print "meshType = ",inputData.meshType
- print "nb concrete mesh ",self.__nbConcreteMesh
- print "nb steelbar mesh ",self.__nbSteelbarMesh
-
+ print(inputData)
+ print("meshType = ",inputData.meshType)
+ print("nb concrete mesh ",self.__nbConcreteMesh)
+ print("nb steelbar mesh ",self.__nbSteelbarMesh)
+
def onDeleteInput(self):
"""
def __delInputFromMap(self, meshName):
"""
This function removes the specified entry from the internal
- map (for data management purpose)
+ map (for data management purpose)
"""
inputData = self.__dictInputData.pop(meshName)
if inputData.meshType == InputData.MESHTYPES.CONCRETE:
else:
self.__nbSteelbarMesh -= 1
- print inputData
- print "nb concrete mesh ",self.__nbConcreteMesh
- print "nb steelbar mesh ",self.__nbSteelbarMesh
+ print(inputData)
+ print("nb concrete mesh ",self.__nbConcreteMesh)
+ print("nb steelbar mesh ",self.__nbSteelbarMesh)
def setData(self, listInputData=[]):
meshObject = inputData.meshObject
meshType = inputData.meshType
groupName = inputData.groupName
-
+
self.__addInputInGui(meshName, meshObject, meshType, groupName)
self.__addInputInMap(meshName, meshObject, meshType, groupName)
"""
# Note that the values() function returns a copy of the list
# of values.
- return self.__dictInputData.values()
-
+ return list(self.__dictInputData.values())
+
def checkData(self):
"""
This function checks if the data are valid, from the dialog
"""
if self.__nbConcreteMesh == 0 and self.__nbSteelbarMesh == 0:
self.checkDataMessage = "You must define at least one mesh (CONCRETE or STEELBAR)"
- return False
+ return False
if self.__nbConcreteMesh > 1:
self.checkDataMessage = "You define multiple CONCRETE meshes."
self.checkDataMessage += "You should verify first that your version of PADDER support this configuration."
return True
+ #def setParameters(self,
# ==============================================================================
# Basic use case
#
def TEST_InputDialog():
import sys
- from PyQt4.QtCore import QObject, SIGNAL, SLOT
- from PyQt4.QtGui import QApplication
+ from qtsalome import QApplication
app = QApplication(sys.argv)
- QObject.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
+ app.lastWindowClosed.connect( app.quit )
dlg=InputDialog()
dlg.displayAndWait()
if dlg.wasOk():
- print "OK has been pressed"
+ print("OK has been pressed")
def TEST_InputDialog_setData():
import sys
- from PyQt4.QtCore import QObject, SIGNAL, SLOT
- from PyQt4.QtGui import QApplication
+ from qtsalome import QApplication
app = QApplication(sys.argv)
- QObject.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
+ app.lastWindowClosed.connect( app.quit )
dlg=InputDialog()
- from inputdata import InputData
+ from .inputdata import InputData
inputData = InputData()
inputData.meshName = "myMesh"
inputData.meshObject = None
inputData.groupName = "myGroup"
listInputData = []
listInputData.append(inputData)
-
+
dlg.setData2(listInputData)
-
+
dlg.displayAndWait()
if dlg.wasOk():
- print "OK has been pressed"
+ print("OK has been pressed")
outputListInputData = dlg.getData2()
- print outputListInputData
+ print(outputListInputData)
if __name__ == "__main__":