Salome HOME
style: black format
[tools/sat.git] / data / templates / PythonComponent8 / src / Dialog / CreatePolylineDialog.py
1 from Dialog import Dialog
2 from qtsalome import *
3
4
5 class CreatePolylineDialog(Dialog):
6     def __init__(self, helpFile, controller, widgetDialogBox):
7         """Constructor"""
8
9         # Initializing parent widget
10         Dialog.__init__(self, helpFile, controller, widgetDialogBox)
11
12         # Setting default name
13         nbPolylines = controller.getNbPolylines()
14         self.entryName.setText("polyline_" + str(nbPolylines + 1))
15         pass
16
17     def addSpecialWidgets(self):
18
19         intValidator = QIntValidator(self)
20
21         lNbPoints = QLabel("Number of points", self)
22         self.v11.addWidget(lNbPoints)
23
24         self.entryNbPoints = QLineEdit(self)
25         self.entryNbPoints.setValidator(intValidator)
26         self.entryNbPoints.setText("10")
27         self.v12.addWidget(self.entryNbPoints)
28         pass
29
30     def execApply(self):
31         name = self.name
32         nbPoints = int(self.nbPoints)
33         self.getController().createPolyline(name, nbPoints)
34         self.reInitializeDialog()
35         return
36
37     def retrieveUserEntries(self):
38         self.name = str(self.entryName.text())
39         self.nbPoints = str(self.entryNbPoints.text())
40         pass
41
42     def checkUserEntries(self):
43         if self.name == "" or self.nbPoints == "":
44             self.errMessage = "All attributes must be filled"
45             return False
46         if int(self.nbPoints) > 10:
47             self.errMessage = "The number of points must not exceed 10"
48             return False
49         return True
50
51     def reInitializeDialog(self):
52         nbPolylines = self.getController().getNbPolylines()
53         self.entryName.setText("polyline_" + str(nbPolylines + 1))
54         self.entryNbPoints.setText("10")
55         pass
56
57
58 pass