]> SALOME platform Git repositories - tools/sat.git/blob - data/templates/PythonComponent/src/Dialog/DialogEdit.py
Salome HOME
add the template command
[tools/sat.git] / data / templates / PythonComponent / src / Dialog / DialogEdit.py
1 from PyQt4.QtGui import *
2 from PyQt4.QtCore import *
3
4 class DialogEdit( QDialog ) :
5
6    def __init__( self, helpFile, controller, widgetDialogBox ) :
7        """Constructor"""
8
9        # Initializing parent widget
10        QDialog.__init__( self )
11
12        # Setting attributes
13        self.setObjectName( "Dialog" )
14        self.setWindowTitle( "Dialog data" )
15        self._helpFile = helpFile
16        self._controller = controller
17        self._widgetDialogBox = widgetDialogBox
18
19        # Setting layouts
20        self.mainLayout = QVBoxLayout( self )
21        self.h1 = QHBoxLayout( self )
22        self.h2 = QHBoxLayout( self )
23        self.mainLayout.addLayout( self.h1 )
24        self.mainLayout.addLayout( self.h2 )
25        self.v11 = QVBoxLayout( self)
26        self.v12 = QVBoxLayout( self )
27        self.h1.addLayout( self.v11 )
28        self.h1.addLayout( self.v12 )
29
30        # Filling layouts with standard widgets( common to all childre )
31        self.fillStandardWidgets()
32        # Adding special widgets to layouts( special to each child )
33        self.addSpecialWidgets()
34
35        # Connecting widgets to slots
36        self.connectSlots()
37        pass
38
39    def getController( self ) :
40        return self._controller
41
42    def fillStandardWidgets( self ) :
43
44        #Setting buttons
45        self.bOk = QPushButton( "OK", self )
46        self.h2.addWidget( self.bOk )
47        self.bCancel = QPushButton( "Cancel", self )
48        self.h2.addWidget( self.bCancel )
49        self.bHelp = QPushButton( "Help", self )
50        self.h2.addWidget( self.bHelp )
51        pass
52
53    def addSpecialWidgets( self ) :
54        print 'Virtual method'
55        pass
56
57    def connectSlots( self ) :
58        self.connect( self.bOk, SIGNAL( 'clicked()' ), self.apply )
59        self.connect( self.bHelp, SIGNAL( 'clicked()' ), self.help )
60        self.connect( self.bCancel, SIGNAL( 'clicked()' ), self.close )
61        pass
62
63    def apply( self ) :
64        self.retrieveUserEntries()
65        if not self.checkUserEntries() :
66           QMessageBox.warning( self, 'information faillure', self.errMessage )
67           return
68        self.execApply()
69        self.close()
70        return
71
72    def retrieveUserEntries( self ) :
73        print 'Virtual method'
74        pass
75
76    def checkUserEntries( self ) :
77        print 'Virtual method'
78        return True
79
80    def execApply( self ) :
81        print 'Virtual method'
82        pass
83
84    def help( self ) :
85        import os
86        os.system( 'firefox ' + self._helpFile + '&' )
87        pass
88
89    def close( self ) :
90        self._widgetDialogBox.close()
91        pass
92
93 pass