eric6/Utilities/PySideImporter.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8043
0acf98cd089a
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

1142
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7911
diff changeset
3 # Copyright (c) 2011 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
1142
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
7911
4621c9082a43 Added support for PySide6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7908
diff changeset
7 Module to check for the presence of PySide2/PySide6 by importing it.
1142
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import sys
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 if __name__ == "__main__":
6291
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
13 pySideVariant = "2"
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
14 if len(sys.argv) == 2:
7908
33afc8e96e19 Fixed a bug introduced with the recent changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
15 pySideVariant = sys.argv[1].replace("--variant=", "")
6291
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
16
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
17 if pySideVariant == "1":
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
18 # no PySide support anymore
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
19 ret = 1
6291
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
20
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
21 elif pySideVariant == "2":
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
22 try:
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
23 import PySide2 # __IGNORE_EXCEPTION__ __IGNORE_WARNING__
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
24 ret = 0
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
25 except ImportError:
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
26 ret = 1
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
27
7911
4621c9082a43 Added support for PySide6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7908
diff changeset
28 elif pySideVariant == "6":
4621c9082a43 Added support for PySide6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7908
diff changeset
29 try:
4621c9082a43 Added support for PySide6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7908
diff changeset
30 import PySide6 # __IGNORE_EXCEPTION__ __IGNORE_WARNING__
4621c9082a43 Added support for PySide6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7908
diff changeset
31 ret = 0
4621c9082a43 Added support for PySide6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7908
diff changeset
32 except ImportError:
4621c9082a43 Added support for PySide6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7908
diff changeset
33 ret = 1
4621c9082a43 Added support for PySide6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7908
diff changeset
34
6291
94e0e688dcad PySide2 support: started to implement support for PySide2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
35 else:
1142
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 ret = 1
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
01ae8e2946d3 Improved the code to detect PySide.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 sys.exit(ret)

eric ide

mercurial