]> SALOME platform Git repositories - tools/sat.git/blob - data/templates/PythonComponent/src/Dialog/DialogEdit.py
Salome HOME
Debian/Trixie: sat generate a lot of warnings: https://github.com/SalomePlatform...
[tools/sat.git] / data / templates / PythonComponent / src / Dialog / DialogEdit.py
1 from qtsalome import *
2
3 class DialogEdit( 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        #Setting buttons
44        self.bOk = QPushButton( "OK", self )
45        self.h2.addWidget( self.bOk )
46        self.bCancel = QPushButton( "Cancel", self )
47        self.h2.addWidget( self.bCancel )
48        self.bHelp = QPushButton( "Help", self )
49        self.h2.addWidget( self.bHelp )
50        pass
51
52    def addSpecialWidgets( self ) :
53        print('Virtual method')
54        pass
55
56    def connectSlots( self ) :
57        self.bOk.clicked.connect(self.apply)
58        self.bHelp.clicked.connect(self.help)
59        self.bCancel.clicked.connect(self.close)
60        pass
61
62    def apply( self ) :
63        self.retrieveUserEntries()
64        if not self.checkUserEntries() :
65           QMessageBox.warning( self, 'information faillure', self.errMessage )
66           return
67        self.execApply()
68        self.close()
69        return
70
71    def retrieveUserEntries( self ) :
72        print('Virtual method')
73        pass
74
75    def checkUserEntries( self ) :
76        print('Virtual method')
77        return True
78
79    def execApply( self ) :
80        print('Virtual method')
81        pass
82
83    def help( self ) :
84        import os
85        os.system( 'firefox ' + self._helpFile + '&' )
86        pass
87
88    def close( self ) :
89        self._widgetDialogBox.close()
90        pass
91
92 pass