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
| #! /usr/bin/python3
# -*- coding: utf-8 -*-
# Python 3 PyQt5
import sys, os
from PyQt5 import (QtWidgets, QtCore)
# lancement de la bibliothèque Qt5
app = QtWidgets.QApplication(sys.argv)
# trouve le répertoire d'exécution du présent programme
repbase = os.path.abspath(os.path.dirname(__file__))
# lit les variables d'environnement
envir = QtCore.QProcessEnvironment().systemEnvironment()
# enregistre dans PYTHONPATH le répertoire des fichiers des widgets
envir.insert('PYTHONPATH', os.path.join(repbase, 'biblio', 'customwidgets', 'widgets'))
# enregistre dans PYQTDESIGNERPATH le répertoire des fichiers des plugins
envir.insert('PYQTDESIGNERPATH', os.path.join(repbase, 'biblio', 'customwidgets', 'plugins'))
# trouve l'adresse du Designer à lancer
designer = QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.BinariesPath)
if sys.platform == 'win32':
designer += r'\designer.exe' # Windows
elif sys.platform == 'linux':
designer += '/designer' # Linux
elif sys.platform == 'darwin':
designern += '/Designer.app/Contents/MacOS/Designer' # Mac OS X
else:
pass # autre cas à traiter
# lance Designer dans un nouveau processus avec les variables d'environnement
proc = QtCore.QProcess()
proc.setProcessEnvironment(envir)
proc.start(designer)
proc.waitForFinished(-1)
sys.exit(proc.exitCode()) |
Partager