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


Python QUiLoader.registerCustomWidget方法代码示例

本文整理汇总了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())
开发者ID:Hasimir,项目名称:PySide,代码行数:11,代码来源:bug_392.py

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

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

示例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
开发者ID:SF-Zhou,项目名称:quite,代码行数:16,代码来源:load_ui.py

示例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()
开发者ID:XDATA-Year-2,项目名称:tangelo-wrapper,代码行数:18,代码来源:tangelo-wrapper.py

示例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()
开发者ID:XDATA-Year-2,项目名称:tangelo-wrapper,代码行数:19,代码来源:tangelo-wrapper.py

示例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
开发者ID:mlyko,项目名称:tadek-ui,代码行数:38,代码来源:utils.py


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