Salome HOME
updated copyright message
[modules/gui.git] / tools / CurvePlot / src / python / pyqtside / QtGui.py
1 # Copyright (C) 2016-2023  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 from . import _use_pyqt
21 if _use_pyqt:
22   from PyQt5.QtGui import *
23
24   # Make QVariant invisible in PyQt5 since they don't exist in
25   # PySide ...
26 #  __original_itemData = QComboBox.itemData
27 #  def new_itemData(*args, **kargs):
28 #    from PyQt5.QtCore import QVariant
29 #    variant = __original_itemData(*args, **kargs)
30 #    funcS = lambda : (str(variant.toString()), True)
31 #    dico = {QVariant.Int: variant.toInt, QVariant.String: funcS,
32 #     QVariant.Bool: variant.toBool, QVariant.Double: variant.toDouble}
33 #    conv = dico.get(variant.type(), None)
34 #    if conv is None:
35 #      raise Exception("Unsupported variant type in pyqtside: '%s'!" % variant.typeName())
36 #    return conv()[0]
37 #
38 #  QComboBox.itemData = new_itemData 
39 else:
40   from PySide.QtGui import *
41
42   __original_ofn = QFileDialog.getOpenFileName
43   __original_sfn = QFileDialog.getSaveFileName
44
45   # In PySide, getOpenFileName and co returns 2 values, and only one in PyQt ...
46   def newOfn(cls,*args, **kargs):
47     tup = __original_ofn(*args, **kargs)
48     return tup[0]
49
50   def newSfn(cls,*args, **kargs):
51     tup = __original_sfn(*args, **kargs)
52     return tup[0]
53
54   QFileDialog.getOpenFileName = classmethod(newOfn)
55   QFileDialog.getSaveFileName = classmethod(newSfn)
56