当前位置: 首页>>代码示例>>Python>>正文


Python uic.loadUiType方法代码示例

本文整理汇总了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 
开发者ID:nngogol,项目名称:PySimpleGUIDesigner,代码行数:25,代码来源:unittestes.py

示例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 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:35,代码来源:Qt.py

示例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 
开发者ID:autokey,项目名称:autokey,代码行数:14,代码来源:common.py


注:本文中的PyQt5.uic.loadUiType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。