本文整理汇总了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()
示例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)
示例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()
示例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()
示例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()
示例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()
示例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()
示例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