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


Python QtCompat.loadUi方法代码示例

本文整理汇总了Python中Qt.QtCompat.loadUi方法的典型用法代码示例。如果您正苦于以下问题:Python QtCompat.loadUi方法的具体用法?Python QtCompat.loadUi怎么用?Python QtCompat.loadUi使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Qt.QtCompat的用法示例。


在下文中一共展示了QtCompat.loadUi方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_load_ui_baseinstance

# 需要导入模块: from Qt import QtCompat [as 别名]
# 或者: from Qt.QtCompat import loadUi [as 别名]
def test_load_ui_baseinstance():
    """Tests to see if the baseinstance loading loads widgets on properly"""
    import sys
    from Qt import QtWidgets, QtCompat
    app = QtWidgets.QApplication(sys.argv)
    win = QtWidgets.QWidget()
    QtCompat.loadUi(self.ui_qwidget, win)
    assert hasattr(win, 'lineEdit'), "loadUi could not load instance to win"
    app.exit()
开发者ID:sonictk,项目名称:Qt.py,代码行数:11,代码来源:tests.py

示例2: LoadUI

# 需要导入模块: from Qt import QtCompat [as 别名]
# 或者: from Qt.QtCompat import loadUi [as 别名]
 def LoadUI(self, obj):
     path = inspect.getsourcefile(obj.__class__).replace('\\','/')
     relpath = path.split(self['CoreDirectory'],1)[-1].rsplit('.',1)[0]+'.ui'
     uipath = self.GetOverriddenPath(relpath)
     print('path', path)
     print('self[CoreDirectory]', self['CoreDirectory'])
     print('relpath', relpath)
     print('uipath', uipath)
     
     if os.path.exists(uipath):
         QtCompat.loadUi(uipath, baseinstance=obj)
开发者ID:ThomasMcVay,项目名称:MediaApp,代码行数:13,代码来源:Core.py

示例3: test_load_ui_signals

# 需要导入模块: from Qt import QtCompat [as 别名]
# 或者: from Qt.QtCompat import loadUi [as 别名]
def test_load_ui_signals():
    """Tests to see if the baseinstance loading loads widgets on properly"""
    import sys
    from Qt import QtWidgets, QtCompat
    app = QtWidgets.QApplication(sys.argv)
    win = QtWidgets.QWidget()
    QtCompat.loadUi(self.ui_qwidget, win)

    win.lineEdit.setText('Hello')
    assert str(win.label.text()) == 'Hello', "lineEdit signal did not fire"

    app.exit()
开发者ID:sonictk,项目名称:Qt.py,代码行数:14,代码来源:tests.py

示例4: test_load_ui_dockwidget

# 需要导入模块: from Qt import QtCompat [as 别名]
# 或者: from Qt.QtCompat import loadUi [as 别名]
def test_load_ui_dockwidget():
    """Tests to see if the baseinstance loading loads a QDockWidget properly"""
    import sys
    from Qt import QtWidgets, QtCompat

    app = QtWidgets.QApplication(sys.argv)
    win = QtWidgets.QDockWidget()

    QtCompat.loadUi(self.ui_qdockwidget, win)

    assert hasattr(win, 'lineEdit'), \
        "loadUi could not load instance to main window"

    app.exit()
开发者ID:mottosso,项目名称:Qt.py,代码行数:16,代码来源:tests.py

示例5: test_load_ui_existingLayoutOnWidget

# 需要导入模块: from Qt import QtCompat [as 别名]
# 或者: from Qt.QtCompat import loadUi [as 别名]
def test_load_ui_existingLayoutOnWidget():
    """Tests to see if loading a ui onto a layout in a Widget works"""
    import sys
    from Qt import QtWidgets, QtCompat

    msgs = 'QLayout: Attempting to add QLayout "" to QWidget ' \
        '"Form", which already has a layout'

    with ignoreQtMessageHandler([msgs]):
        app = QtWidgets.QApplication(sys.argv)
        win = QtWidgets.QWidget()
        QtWidgets.QComboBox(win)
        QtWidgets.QHBoxLayout(win)
        QtCompat.loadUi(self.ui_qwidget, win)
    app.exit()
开发者ID:mottosso,项目名称:Qt.py,代码行数:17,代码来源:tests.py

示例6: test_load_ui_returntype

# 需要导入模块: from Qt import QtCompat [as 别名]
# 或者: from Qt.QtCompat import loadUi [as 别名]
def test_load_ui_returntype():
    """load_ui returns an instance of QObject"""

    import sys
    from Qt import QtWidgets, QtCore, QtCompat
    app = QtWidgets.QApplication(sys.argv)
    obj = QtCompat.loadUi(self.ui_qwidget)
    assert isinstance(obj, QtCore.QObject)
    app.exit()
开发者ID:sonictk,项目名称:Qt.py,代码行数:11,代码来源:tests.py

示例7: test_load_ui_customwidget

# 需要导入模块: from Qt import QtCompat [as 别名]
# 或者: from Qt.QtCompat import loadUi [as 别名]
def test_load_ui_customwidget():
    """Tests to see if loadUi loads a custom widget properly"""
    import sys
    from Qt import QtWidgets, QtCompat

    app = QtWidgets.QApplication(sys.argv)
    win = QtWidgets.QMainWindow()

    QtCompat.loadUi(self.ui_qcustomwidget, win)

    # Ensure that the derived class was properly created
    # and not the base class (in case of failure)
    custom_class_name = getattr(win, "customwidget", None).__class__.__name__
    excepted_class_name = CustomWidget(win).__class__.__name__
    assert custom_class_name == excepted_class_name, \
        "loadUi could not load custom widget to main window"

    app.exit()
开发者ID:mottosso,项目名称:Qt.py,代码行数:20,代码来源:tests.py

示例8: setup_ui

# 需要导入模块: from Qt import QtCompat [as 别名]
# 或者: from Qt.QtCompat import loadUi [as 别名]
def setup_ui(uifile, base_instance=None):
    """Load a Qt Designer .ui file and returns an instance of the user interface

    Args:
        uifile (str): Absolute path to .ui file
        base_instance (QWidget): The widget into which UI widgets are loaded

    Returns:
        QWidget: the base instance

    """
    ui = QtCompat.loadUi(uifile)  # Qt.py mapped function
    if not base_instance:
        return ui
    else:
        for member in dir(ui):
            if not member.startswith('__') and \
               member is not 'staticMetaObject':
                setattr(base_instance, member, getattr(ui, member))
        return ui
开发者ID:fredrikaverpil,项目名称:Qt.py,代码行数:22,代码来源:baseinstance1.py


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