eric7/Project/UicLoadUi6.py

branch
eric7
changeset 9017
ab708b168534
parent 8881
54e42bc2437a
equal deleted inserted replaced
9016:6f079c524e99 9017:ab708b168534
12 import json 12 import json
13 import xml.etree.ElementTree # secok 13 import xml.etree.ElementTree # secok
14 import contextlib 14 import contextlib
15 15
16 try: 16 try:
17 from PyQt6.QtCore import QMetaMethod, QByteArray 17 from PyQt6.QtCore import QByteArray, QMetaMethod
18 from PyQt6.QtGui import QAction 18 from PyQt6.QtGui import QAction
19 from PyQt6.QtWidgets import QWidget, QApplication 19 from PyQt6.QtWidgets import QApplication, QWidget
20 from PyQt6 import uic 20 from PyQt6 import uic
21 except ImportError: 21 except ModuleNotFoundError:
22 print("PyQt6 could not be found.") 22 print("PyQt6 could not be found.")
23 sys.exit(1) 23 sys.exit(1)
24 except ImportError as err:
25 print("PyQt6 could not be imported. Issue: {0}".format(str(err)))
26 sys.exit(1)
24 27
25 with contextlib.suppress(ImportError): 28 with contextlib.suppress(ImportError):
26 from PyQt6 import QtWebEngineWidgets # __IGNORE_WARNING__ 29 from PyQt6 import QtWebEngineWidgets # __IGNORE_WARNING__
27 30
28 sys.path.append(os.path.dirname(os.path.dirname(__file__))) 31 sys.path.append(os.path.dirname(os.path.dirname(__file__)))
36 @param formFile file name of the form 39 @param formFile file name of the form
37 @type str 40 @type str
38 @param projectPath directory name of the project 41 @param projectPath directory name of the project
39 @type str 42 @type str
40 """ 43 """
44 sys.path.append(projectPath)
45
41 app = QApplication([]) # __IGNORE_WARNING__ 46 app = QApplication([]) # __IGNORE_WARNING__
42 try: 47 try:
43 dlg = uic.loadUi(formFile, package=projectPath) 48 dlg = uic.loadUi(formFile, package=projectPath)
44 print(dlg.objectName()) 49 print(dlg.objectName())
45 sys.exit(0) 50 sys.exit(0)
56 @param formFile file name of the form 61 @param formFile file name of the form
57 @type str 62 @type str
58 @param projectPath directory name of the project 63 @param projectPath directory name of the project
59 @type str 64 @type str
60 """ 65 """
66 sys.path.append(projectPath)
67
61 app = QApplication([]) # __IGNORE_WARNING__ 68 app = QApplication([]) # __IGNORE_WARNING__
62 try: 69 try:
63 dlg = uic.loadUi(formFile, package=projectPath) 70 dlg = uic.loadUi(formFile, package=projectPath)
64 print(dlg.metaObject().className()) 71 print(dlg.metaObject().className())
65 sys.exit(0) 72 sys.exit(0)
107 @param formFile file name of the form 114 @param formFile file name of the form
108 @type str 115 @type str
109 @param projectPath directory name of the project 116 @param projectPath directory name of the project
110 @type str 117 @type str
111 """ 118 """
119 sys.path.append(projectPath)
120
112 objectsList = [] 121 objectsList = []
113 122
114 app = QApplication([]) # __IGNORE_WARNING__ 123 app = QApplication([]) # __IGNORE_WARNING__
115 try: 124 try:
116 dlg = uic.loadUi(formFile, package=projectPath) 125 dlg = uic.loadUi(formFile, package=projectPath)

eric ide

mercurial