Salome HOME
updated copyright message
[modules/gui.git] / src / GUI_PY / mytestdialog.py
index 24d0576406655b91b949402167ed3fd7408ad4fa..d7ee0804f42be13832eed3638bd1e15e6aaacc0a 100644 (file)
@@ -1,5 +1,5 @@
 # -*- coding: iso-8859-1 -*-
-# Copyright (C) 2010-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2010-2023  CEA, EDF, OPEN CASCADE
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-__author__="gboulant"
-__date__ ="$31 mars 2010 17:09:53$"
+from qtsalome import *
+from salome.gui.genericdialog import GenericDialog
+from salome.gui.mytestdialog_ui import Ui_MyTestDialog
 
-from mytestdialog_ui import Ui_MyTestDialog
-from genericdialog import GenericDialog
 
 class MyTestDialog(GenericDialog):
     """
@@ -71,13 +70,15 @@ class MyTestDialog(GenericDialog):
         return name
 
 
-from PyQt4.QtCore import SIGNAL
 class MyTestDialogWithSignals(MyTestDialog):
     """
     This class is to illustrate the usage of the GenericDialog in the
     case where the dialog windows is not modal. In such a case, the
     controller must be warn of close events using Qt signals.
     """
+
+    inputValidated = pyqtSignal()
+
     def __init__(self, parent=None, name="MyTestDialogWithSignals"):
         MyTestDialog.__init__(self, parent, name)
 
@@ -92,7 +93,7 @@ class MyTestDialogWithSignals(MyTestDialog):
         # has been validated so that it can process the event
         MyTestDialog.accept(self)
         if self.wasOk():
-            self.emit(SIGNAL('inputValidated()'))
+            self.inputValidated.emit()
 
 
 
@@ -104,32 +105,29 @@ class MyTestDialogWithSignals(MyTestDialog):
 
 def TEST_MyTestDialog_modal():
     import sys
-    from PyQt4.QtCore import QObject, SIGNAL, SLOT
-    from PyQt4.QtGui import QApplication
+    from qtsalome import QApplication
     app = QApplication(sys.argv)
-    QObject.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
+    app.lastWindowClosed.connect(app.quit)
 
     dlg=MyTestDialog()
     dlg.setData("A default name")
     dlg.displayAndWait()
     if dlg.wasOk():
         name = dlg.getData()
-        print "The name has been modified to",name
+        print("The name has been modified to",name)
 
 
 class DialogListener:
     def onProcessEvent(self):
-        print "onProcessEvent(): OK has been pressed"
+        print("onProcessEvent(): OK has been pressed")
         import sys
         sys.exit(0)
         
 
 def TEST_MyTestDialog_non_modal():
     import sys
-    from PyQt4.QtCore import QObject, SIGNAL, SLOT
-    from PyQt4.QtGui import QApplication
     app = QApplication(sys.argv)
-    QObject.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
+    app.lastWindowClosed.connect(app.quit)
 
     dlg=MyTestDialogWithSignals()
     # This dialog window will emit a inputValidated() signal when the
@@ -137,7 +135,7 @@ def TEST_MyTestDialog_non_modal():
     # connect this signal to a local slot so that the event can be
     # processed.
     dlgListener = DialogListener()
-    app.connect(dlg, SIGNAL('inputValidated()'), dlgListener.onProcessEvent)
+    dlg.inputValidated.connect(dlgListener.onProcessEvent)
     # This connect instruction means that the signal inputValidated()
     # emited by the dlg Qt object will raise a call to the slot
     # dlgListener.onProcessEvent