-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathPySideWrapper.py
More file actions
49 lines (45 loc) · 2.43 KB
/
PySideWrapper.py
File metadata and controls
49 lines (45 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# SPDX-License-Identifier: LGPL-2.1-or-later
# SPDX-FileCopyrightText: 2025 FreeCAD Project Association
# SPDX-FileNotice: Part of the AddonManager.
################################################################################
# #
# This addon 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 addon 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 addon. If not, see https://www.gnu.org/licenses #
# #
################################################################################
"""Wrap PySide so the same import can use either PySide6 or PySide2. Also support using the
FreeCAD wrapper, if that is available."""
try:
from PySide import QtCore, QtGui, QtNetwork, QtSvg, QtWidgets
except ImportError:
try:
from PySide6 import QtCore, QtGui, QtNetwork, QtSvg, QtWidgets
except ImportError:
try:
from PySide2 import QtCore, QtGui, QtNetwork, QtSvg, QtWidgets
except ImportError:
raise ImportError(
"No viable version of PySide was found (tried the FreeCAD PySide wrapper, PySide6 and PySide2)"
)
# Dummy usage so the linter doesn't complain about the unused imports (since the whole point here is
# that the imports aren't used in this file, they are just wrapped here)
if hasattr(QtCore, "silence_the_linter"):
pass
if hasattr(QtGui, "silence_the_linter"):
pass
if hasattr(QtNetwork, "silence_the_linter"):
pass
if hasattr(QtSvg, "silence_the_linter"):
pass
if hasattr(QtWidgets, "silence_the_linter"):
pass