當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。