本文整理汇总了Python中PyQt5.uic.loadUiType方法的典型用法代码示例。如果您正苦于以下问题:Python uic.loadUiType方法的具体用法?Python uic.loadUiType怎么用?Python uic.loadUiType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.uic
的用法示例。
在下文中一共展示了uic.loadUiType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from PyQt5 import uic [as 别名]
# 或者: from PyQt5.uic import loadUiType [as 别名]
def setUp(self):
# # make mini "qt app"
# self.form, self.base = loadUiType('untitled.ui')
# self.w, self.ui = self.base(), self.form()
# self.ui.setupUi(self.w)
# self.qt = self.ui.ui
# ============
# ============
# ============
# self.qt_app = QtWidgets.QApplication(sys.argv);
# self.qt_ = MyWin()
# myqapp.close()
# ============
# ============
# ============
self.qt_app = QtWidgets.QApplication(sys.argv)
self.qt_ = QtTemplateWindow()
self.qt = self.qt_.ui
示例2: loadUiType
# 需要导入模块: from PyQt5 import uic [as 别名]
# 或者: from PyQt5.uic import loadUiType [as 别名]
def loadUiType(uiFile):
"""
Pyside "loadUiType" command like PyQt4 has one, so we have to convert
the ui file to py code in-memory first and then execute it in a
special frame to retrieve the form_class.
from stackoverflow: http://stackoverflow.com/a/14195313/3781327
seems like this might also be a legitimate solution, but I'm not sure
how to make PyQt4 and pyside look the same...
http://stackoverflow.com/a/8717832
"""
import pysideuic
import xml.etree.ElementTree as xml
#from io import StringIO
parsed = xml.parse(uiFile)
widget_class = parsed.find('widget').get('class')
form_class = parsed.find('class').text
with open(uiFile, 'r') as f:
o = StringIO()
frame = {}
pysideuic.compileUi(f, o, indent=0)
pyc = compile(o.getvalue(), '<string>', 'exec')
exec(pyc, frame)
#Fetch the base_class and form class based on their type in the xml from designer
form_class = frame['Ui_%s'%form_class]
base_class = eval('QtGui.%s'%widget_class)
return form_class, base_class
示例3: load_ui_from_file
# 需要导入模块: from PyQt5 import uic [as 别名]
# 或者: from PyQt5.uic import loadUiType [as 别名]
def load_ui_from_file(name: str):
"""
Returns a tuple from uic.loadUiType(), loading the ui file with the given name.
:param name:
:return:
"""
ui_file = _get_ui_qfile(name)
try:
base_type = uic.loadUiType(ui_file, from_imports=True)
finally:
ui_file.close()
return base_type