1 from Dialog import Dialog
5 class CreatePolylineDialog(Dialog):
6 def __init__(self, helpFile, controller, widgetDialogBox):
9 # Initializing parent widget
10 Dialog.__init__(self, helpFile, controller, widgetDialogBox)
12 # Setting default name
13 nbPolylines = controller.getNbPolylines()
14 self.entryName.setText("polyline_" + str(nbPolylines + 1))
17 def addSpecialWidgets(self):
19 intValidator = QIntValidator(self)
21 lNbPoints = QLabel("Number of points", self)
22 self.v11.addWidget(lNbPoints)
24 self.entryNbPoints = QLineEdit(self)
25 self.entryNbPoints.setValidator(intValidator)
26 self.entryNbPoints.setText("10")
27 self.v12.addWidget(self.entryNbPoints)
32 nbPoints = int(self.nbPoints)
33 self.getController().createPolyline(name, nbPoints)
34 self.reInitializeDialog()
37 def retrieveUserEntries(self):
38 self.name = str(self.entryName.text())
39 self.nbPoints = str(self.entryNbPoints.text())
42 def checkUserEntries(self):
43 if self.name == "" or self.nbPoints == "":
44 self.errMessage = "All attributes must be filled"
46 if int(self.nbPoints) > 10:
47 self.errMessage = "The number of points must not exceed 10"
51 def reInitializeDialog(self):
52 nbPolylines = self.getController().getNbPolylines()
53 self.entryName.setText("polyline_" + str(nbPolylines + 1))
54 self.entryNbPoints.setText("10")