Salome HOME
47f1974672d3bde82851c2e52e756c35c747ddac
[tools/sat.git] / data / templates / PythonComponent / src / Dialog / Dialog.py
1 from qtsalome import *
2
3 class Dialog( QDialog ) :
4
5    def __init__( self, helpFile, controller, widgetDialogBox ) :
6        """Constructor"""
7
8        # Initializing parent widget
9        QDialog.__init__( self )
10
11        # Setting attributes
12        self.setObjectName( "Dialog" )
13        self.setWindowTitle( "Dialog data" )
14        self._helpFile = helpFile
15        self._controller = controller
16        self._widgetDialogBox = widgetDialogBox
17
18        # Setting layouts
19        self.mainLayout = QVBoxLayout( self )
20        self.h1 = QHBoxLayout( self )
21        self.h2 = QHBoxLayout( self )
22        self.mainLayout.addLayout( self.h1 )
23        self.mainLayout.addLayout( self.h2 )
24        self.v11 = QVBoxLayout( self)
25        self.v12 = QVBoxLayout( self )
26        self.h1.addLayout( self.v11 )
27        self.h1.addLayout( self.v12 )
28
29        # Filling layouts with standard widgets( common to all childre )
30        self.fillStandardWidgets()
31        # Adding special widgets to layouts( special to each child )
32        self.addSpecialWidgets()
33
34        # Connecting widgets to slots
35        self.connectSlots()
36        pass
37
38    def getController( self ) :
39        return self._controller
40
41    def fillStandardWidgets( self ) :
42
43        lName = QLabel( "Name", self )
44        self.v11.addWidget( lName )
45
46        self.entryName = QLineEdit( self )
47        self.v12.addWidget( self.entryName )
48
49        #Setting buttons
50        self.bApply = QPushButton( "Apply", self )
51        self.h2.addWidget( self.bApply )
52        self.bClose = QPushButton( "Close", self )
53        self.h2.addWidget( self.bClose )
54        self.bHelp = QPushButton( "Help", self )
55        self.h2.addWidget( self.bHelp )
56        pass
57
58    def addSpecialWidgets( self ) :
59        print('Virtual method')
60        pass
61
62    def connectSlots( self ) :
63        self.bApply.clicked.connect(self.apply)
64        self.bHelp.clicked.connect(self.help)
65        self.bClose.clicked.connect(self.close)
66        pass
67
68    def apply( self ) :
69
70        self.retrieveUserEntries()
71        if not self.checkUserEntries() :
72           QMessageBox.warning( self, 'information faillure', self.errMessage )
73           return
74        self.execApply()
75        return
76
77    def retrieveUserEntries( self ) :
78        self.name = str( self.entryName.text() )
79        pass
80
81    def checkUserEntries( self ) :
82        if self.name == "" :
83           self.errMessage = 'All attributes must be filled'
84           return False
85        return True
86
87    def execApply( self ) :
88        print('Virtual method')
89        pass
90
91    def reInitializeDialog( self ) :
92        print('Virtual method')
93        pass
94
95    def help( self ) :
96        import os
97        os.system( 'firefox ' + self._helpFile + '&' )
98        pass
99
100    def close( self ) :
101        self._widgetDialogBox.close()
102        pass
103
104 pass