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


Python Properties.setProperties方法代码示例

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


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

示例1: UIParser

# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import setProperties [as 别名]
class UIParser(object):
    def __init__(self, QtCoreModule, QtGuiModule, creatorPolicy):
        self.factory = QObjectCreator(creatorPolicy)
        self.wprops = Properties(self.factory, QtCoreModule, QtGuiModule)

        global QtCore, QtGui
        QtCore = QtCoreModule
        QtGui = QtGuiModule

        self.reset()

    def uniqueName(self, name):
        """UIParser.uniqueName(string) -> string

        Create a unique name from a string.
        >>> p = UIParser(QtCore, QtGui)
        >>> p.uniqueName("foo")
        'foo'
        >>> p.uniqueName("foo")
        'foo1'
        """
        try:
            suffix = self.name_suffixes[name]
        except KeyError:
            self.name_suffixes[name] = 0
            return name

        suffix += 1
        self.name_suffixes[name] = suffix

        return "%s%i" % (name, suffix)

    def reset(self):
        try: self.wprops.reset()
        except AttributeError: pass
        self.toplevelWidget = None
        self.stack = WidgetStack()
        self.name_suffixes = {}
        self.defaults = {"spacing": 6, "margin": 0}
        self.actions = []
        self.currentActionGroup = None
        self.resources = []
        self.button_groups = []
        self.layout_widget = False

    def setupObject(self, clsname, parent, branch, is_attribute = True):
        name = self.uniqueName(branch.attrib.get("name") or clsname[1:].lower())
        if parent is None:
            args = ()
        else:
            args = (parent, )
        obj =  self.factory.createQObject(clsname, name, args, is_attribute)
        self.wprops.setProperties(obj, branch)
        obj.setObjectName(name)
        if is_attribute:
            setattr(self.toplevelWidget, name, obj)
        return obj

    def createWidget(self, elem):
        self.column_counter = 0
        self.row_counter = 0
        self.item_nr = 0
        self.itemstack = []
        self.sorting_enabled = None

        widget_class = elem.attrib['class'].replace('::', '.')
        if widget_class == 'Line':
            widget_class = 'QFrame'

        # Ignore the parent if it is a container
        parent = self.stack.topwidget

        # if is a Menubar on MacOS
        macMenu = (sys.platform == 'darwin') and (widget_class == 'QMenuBar')

        if isinstance(parent, (QtGui.QDockWidget, QtGui.QMdiArea,
                               QtGui.QScrollArea, QtGui.QStackedWidget,
                               QtGui.QToolBox, QtGui.QTabWidget,
                               QtGui.QWizard)) or macMenu:
            parent = None


        # See if this is a layout widget.
        if widget_class == 'QWidget':
            if parent is not None:
                if not isinstance(parent, QtGui.QMainWindow):
                    self.layout_widget = True

        self.stack.push(self.setupObject(widget_class, parent, elem))

        if isinstance(self.stack.topwidget, QtGui.QTableWidget):
            self.stack.topwidget.setColumnCount(len(elem.findall("column")))
            self.stack.topwidget.setRowCount(len(elem.findall("row")))

        self.traverseWidgetTree(elem)
        widget = self.stack.popWidget()

        self.layout_widget = False

        if isinstance(widget, QtGui.QTreeView):
#.........这里部分代码省略.........
开发者ID:willerdavis,项目名称:Tools,代码行数:103,代码来源:uiparser.py


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