Salome HOME
Copyright update 2022
[tools/yacsgen.git] / Examples / pygui1 / pycomposGUI.py
index 40981c60c1c4ff32e94f8b50d098ea6dfa867c71..a689996882c24ca50b1b3c19e7282681a7fc81cc 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2009-2014  EDF R&D
+# Copyright (C) 2009-2022  EDF R&D
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 
 import os
 
-from PyQt4.QtCore import *
-from PyQt4.QtGui import *
-from PyQt4.QtWebKit import *
-from PyQt4 import QtCore, QtGui, uic
+from PyQt5.QtCore import *
+from PyQt5.QtWidgets import *
+from PyQt5 import QtCore, uic, QtWidgets
 
 import salome
 import pycompos_ORB
@@ -101,17 +100,17 @@ def getEngine():
 ###
 def CreateObject():
     global __objectid__
-    default_name = str( sgPyQt.stringSetting( "pycompos", "def_obj_name", "Object" ).trimmed() )
+    default_name = str( sgPyQt.stringSetting( "pycompos", "def_obj_name", "Object" ).lstrip().rstrip() )
     # generate object name
     __objectid__  = __objectid__ + 1
     name = "%s_%d" % ( default_name, __objectid__ )
     if not name: return
     getEngine().createObject( _getStudy(), name )
-    print getEngine().s1(4,5)
-    print getEngine().ComponentDataType()
+    print(getEngine().s1(4,5))
+    print(getEngine().ComponentDataType())
     sg.updateObjBrowser( True )
 
-class DemoImpl(QtGui.QDialog):
+class DemoImpl(QtWidgets.QDialog):
     def __init__(self, *args):
         super(DemoImpl, self).__init__(*args)
 
@@ -125,13 +124,11 @@ class DemoImpl(QtGui.QDialog):
 # called when GUI action is activated
 # action ID is passed as parameter
 def OnGUIEvent( commandID ):
-  print "pycompos.OnGUIEvent(): command = %d" % commandID
+  print("pycompos.OnGUIEvent(): command = %d" % commandID)
   if commandID==941:
     widget=QMainWindow(sgPyQt.getDesktop())
-    web = QWebView(widget)
-    page=os.path.join(os.environ["pycompos_ROOT_DIR"],"share","doc","salome","gui","pycompos","index.html")
-    web.load(QUrl(page))
-    widget.setCentralWidget(web)
+    mywidget = QLabel("Hello world!", widget)
+    widget.setCentralWidget(mywidget)
     widget.show()
 
   elif commandID==942: