本文整理汇总了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):
#.........这里部分代码省略.........