small modifications for cancel action to work correctly

This commit is contained in:
Renaud Nédélec 2014-06-20 13:32:55 +02:00
parent 4d7ec7e96b
commit e53c3df090
2 changed files with 13 additions and 10 deletions

View File

@ -25,6 +25,7 @@ def t_shape_fluid(context):
import t_shape_builder import t_shape_builder
import t_shape_dialog import t_shape_dialog
import xalome import xalome
from PyQt4.QtGui import QMessageBox
activeStudy = context.study activeStudy = context.study
dialog = t_shape_dialog.TShapeDialog() dialog = t_shape_dialog.TShapeDialog()
@ -33,7 +34,9 @@ def t_shape_fluid(context):
# closed using the Ok button, then the data are requested from the # closed using the Ok button, then the data are requested from the
# gui and used to create the shape of the tube. # gui and used to create the shape of the tube.
dialog.exec_() dialog.exec_()
if dialog.wasOk():
r1, r2, h1, h2 = dialog.getData() r1, r2, h1, h2 = dialog.getData()
QMessageBox.about(None, "Building in progress", "building shape, please be patient")
shape = t_shape_builder.build_shape(activeStudy, r1, r2, h1, h2) shape = t_shape_builder.build_shape(activeStudy, r1, r2, h1, h2)
entry = xalome.addToStudy(activeStudy, shape, "T_shape_fluid" ) entry = xalome.addToStudy(activeStudy, shape, "T_shape_fluid" )
xalome.displayShape(entry) xalome.displayShape(entry)

View File

@ -33,6 +33,7 @@ class TShapeDialog(QtGui.QDialog):
self.ui = Ui_Dialog() self.ui = Ui_Dialog()
self.ui.setupUi(self) self.ui.setupUi(self)
self.show() self.show()
self._wasOk = False
def accept(self): def accept(self):
print "DATA ACCEPTED" print "DATA ACCEPTED"
@ -66,13 +67,12 @@ class TShapeDialog(QtGui.QDialog):
## We should test here the validity of values ## We should test here the validity of values
#QtGui.QDialog.accept(self) #QtGui.QDialog.accept(self)
#def reject(self): def reject(self):
#'''Callback function when dialog is rejected (click Cancel)''' self._wasOk = False
#self._wasOk = False QtGui.QDialog.reject(self)
#QtGui.QDialog.reject(self)
#def wasOk(self): def wasOk(self):
#return self._wasOk return self._wasOk
#def setData(self): #def setData(self):
#pass #pass