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