Salome HOME
Copyright update 2022
[modules/gui.git] / tools / CurvePlot / src / python / pyqtside / __init__.py
index 1cba014b11df652d919d305268ad076f34e42b49..8afde8c5f5c9d0899ac45d2abb713ddaa3573998 100644 (file)
@@ -1,29 +1,51 @@
+# Copyright (C) 2016-2022  CEA/DEN, 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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
 """
-Group under one hat PySide and PyQt4. PyQt4 is tried first.
+Group under one hat PySide and PyQt5. PyQt5 is tried first.
 """
 
 try:
   import os
   if os.getenv("CURVEPLOT_FORCE_PYSIDE") is not None:
     raise Exception
-  import PyQt4
+  import PyQt5
   _use_pyqt = True
-  print("Using PyQt4 run-time ...")
+  print("Using PyQt5 run-time ...")
 except:
   try:
     import PySide
     _use_pyqt = False
     print("Using PySide run-time ...")
   except:
-    raise Exception("Neither PyQt4 nor PySide could be imported!")
+    raise Exception("Neither PyQt5 nor PySide could be imported!")
 
 # Matplotlib has to be handled very early, otherwise it will switch to whatever it
 # finds first on the machine
 try: 
   import matplotlib
-  if _use_pyqt:  back = 'PyQt4'
+  if _use_pyqt:  back = 'PyQt5'
   else:          back = 'PySide'
-  matplotlib.rcParams['backend.qt4'] = back
+  # As advised by MatPlotlib:
+  #   "The backend.qt5 rcParam was deprecated in version 2.2.  In order to force the use of a specific Qt binding, either import that binding first, or set the QT_API environment variable.
+  #   mplDeprecation)"
+  from matplotlib.backends import backend_qt5agg
   print("Matplotlib found - Set matplotlib backend to '%s'!" % back) 
 except:
   # No matplotlib, silently discard err message.