本文整理汇总了Python中PySide.QtUiTools.QUiLoader.registerCustomWidget方法的典型用法代码示例。如果您正苦于以下问题:Python QUiLoader.registerCustomWidget方法的具体用法?Python QUiLoader.registerCustomWidget怎么用?Python QUiLoader.registerCustomWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtUiTools.QUiLoader
的用法示例。
在下文中一共展示了QUiLoader.registerCustomWidget方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testPythonCustomWidgets
# 需要导入模块: from PySide.QtUiTools import QUiLoader [as 别名]
# 或者: from PySide.QtUiTools.QUiLoader import registerCustomWidget [as 别名]
def testPythonCustomWidgets(self):
w = QtGui.QWidget()
loader = QUiLoader()
loader.registerCustomWidget(MyWidget)
filePath = os.path.join(os.path.dirname(__file__), 'pycustomwidget.ui')
result = loader.load(filePath, w)
self.assert_(isinstance(result.custom, MyWidget))
self.assert_(result.custom.isPython())
示例2: _load_ui_pyside
# 需要导入模块: from PySide.QtUiTools import QUiLoader [as 别名]
# 或者: from PySide.QtUiTools.QUiLoader import registerCustomWidget [as 别名]
def _load_ui_pyside(path, parent):
from PySide.QtUiTools import QUiLoader
loader = QUiLoader()
# must register custom widgets referenced in .ui files
for w in _custom_widgets():
loader.registerCustomWidget(w)
widget = loader.load(path, parent)
return widget
示例3: _load_ui_pyside
# 需要导入模块: from PySide.QtUiTools import QUiLoader [as 别名]
# 或者: from PySide.QtUiTools.QUiLoader import registerCustomWidget [as 别名]
def _load_ui_pyside(path, parent, custom_widgets=None):
from PySide.QtUiTools import QUiLoader
loader = QUiLoader()
# must register custom widgets referenced in .ui files
if custom_widgets is not None:
for w in custom_widgets:
loader.registerCustomWidget(w)
widget = loader.load(path, parent)
return widget
示例4: __init__
# 需要导入模块: from PySide.QtUiTools import QUiLoader [as 别名]
# 或者: from PySide.QtUiTools.QUiLoader import registerCustomWidget [as 别名]
class UiLoader:
def __init__(self):
self.loader = QUiLoader()
for cls in ext_classes:
self.loader.registerCustomWidget(cls)
def load(self, text, parent=None):
byte_array = QByteArray(text.encode())
buffer = QBuffer(byte_array)
buffer.open(QIODevice.ReadWrite)
ui = self.loader.load(buffer, parent)
buffer.close()
return ui
示例5: createManager
# 需要导入模块: from PySide.QtUiTools import QUiLoader [as 别名]
# 或者: from PySide.QtUiTools.QUiLoader import registerCustomWidget [as 别名]
def createManager(self):
if self.manager != None:
self.updateManager()
self.manager.show()
else:
# Create the window
infile = QFile('ui/process_manager.ui')
infile.open(QFile.ReadOnly)
loader = QUiLoader()
#TODO: This isn't working:
loader.registerCustomWidget(ManagerHelper)
self.manager = loader.load(infile, Globals.mainWindow.window)
infile.close()
self.updateManager(True)
self.manager.show()
示例6: __init__
# 需要导入模块: from PySide.QtUiTools import QUiLoader [as 别名]
# 或者: from PySide.QtUiTools.QUiLoader import registerCustomWidget [as 别名]
def __init__(self):
# Load UI files
infile = QFile("ui/overview.ui")
infile.open(QFile.ReadOnly)
loader = QUiLoader()
#TODO: this isn't working:
loader.registerCustomWidget(MainHelper)
self.window = loader.load(infile, None)
infile.close()
self.processes = {}
self.deadProcesses = {}
# Events
self.window.refreshButton.clicked.connect(self.refresh)
self.window.startButton.clicked.connect(self.findOrSaveConfig)
self.window.show()
示例7: loadUi
# 需要导入模块: from PySide.QtUiTools import QUiLoader [as 别名]
# 或者: from PySide.QtUiTools.QUiLoader import registerCustomWidget [as 别名]
def loadUi(file, dir=None, parent=None):
'''
Loads the given ui file and returns a dictionary containing all UI elements.
'''
elements = {}
if dir:
file = os.path.join(dir, file)
try:
loader = QUiLoader()
path = getDataPath("designer", file)
f = None
try:
f = open(path)
content = f.read()
m = re.search("\"py_(.+?)\"", content)
if m:
name = content[m.start()+1: m.end()-1]
if name and name not in _customWidgets:
baseName = name[3:]
cls = type(name, (getattr(QtGui, baseName),), {})
loader.registerCustomWidget(cls)
_customWidgets.append(name)
finally:
if f is not None:
f.close()
widget = loader.load(path)
widget.setParent(parent, widget.windowFlags())
elements[widget.objectName()] = widget
for child in widget.findChildren(QtCore.QObject, None):
name = child.objectName()
if not name or name.startswith("_") or name.startswith("qt_"):
continue
elements[name] = child
except:
log.exception("UI resource file '%s' couldn't be loaded" % file)
return elements