本文整理汇总了Python中properties.Properties.set_base_dir方法的典型用法代码示例。如果您正苦于以下问题:Python Properties.set_base_dir方法的具体用法?Python Properties.set_base_dir怎么用?Python Properties.set_base_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类properties.Properties
的用法示例。
在下文中一共展示了Properties.set_base_dir方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UIParser
# 需要导入模块: from properties import Properties [as 别名]
# 或者: from properties.Properties import set_base_dir [as 别名]
#.........这里部分代码省略.........
loc = include.attrib.get("location")
# Assume our convention for naming the Python files generated by
# pyrcc4.
if loc and loc.endswith('.qrc'):
self.resources.append(os.path.basename(loc[:-4] + '_rc'))
def createConnections(self, elem):
def name2object(obj):
if obj == self.uiname:
return self.toplevelWidget
else:
return getattr(self.toplevelWidget, obj)
for conn in iter(elem):
QtCore.QObject.connect(name2object(conn.findtext("sender")),
QtCore.SIGNAL(conn.findtext("signal")),
self.factory.getSlot(name2object(conn.findtext("receiver")),
conn.findtext("slot").split("(")[0]))
QtCore.QMetaObject.connectSlotsByName(self.toplevelWidget)
def customWidgets(self, elem):
def header2module(header):
"""header2module(header) -> string
Convert paths to C++ header files to according Python modules
>>> header2module("foo/bar/baz.h")
'foo.bar.baz'
"""
if header.endswith(".h"):
header = header[:-2]
mpath = []
for part in header.split('/'):
# Ignore any empty parts or those that refer to the current
# directory.
if part not in ('', '.'):
if part == '..':
# We should allow this for Python3.
raise SyntaxError("custom widget header file name may not contain '..'.")
mpath.append(part)
return '.'.join(mpath)
for custom_widget in iter(elem):
classname = custom_widget.findtext("class")
if classname.startswith("Q3"):
raise NoSuchWidgetError(classname)
self.factory.addCustomWidget(classname,
custom_widget.findtext("extends") or "QWidget",
header2module(custom_widget.findtext("header")))
def createToplevelWidget(self, classname, widgetname):
raise NotImplementedError
# finalize will be called after the whole tree has been parsed and can be
# overridden.
def finalize(self):
pass
def parse(self, filename, base_dir=''):
self.wprops.set_base_dir(base_dir)
# The order in which the different branches are handled is important.
# The widget tree handler relies on all custom widgets being known, and
# in order to create the connections, all widgets have to be populated.
branchHandlers = (
("layoutdefault", self.readDefaults),
("class", self.classname),
("customwidgets", self.customWidgets),
("widget", self.createUserInterface),
("connections", self.createConnections),
("tabstops", self.setTaborder),
("resources", self.readResources),
)
document = parse(filename)
version = document.getroot().attrib["version"]
DEBUG("UI version is %s" % (version,))
# Right now, only version 4.0 is supported.
assert version in ("4.0",)
for tagname, actor in branchHandlers:
elem = document.find(tagname)
if elem is not None:
actor(elem)
self.finalize()
w = self.toplevelWidget
self.reset()
return w
@staticmethod
def _form_layout_role(grid_position):
if grid_position[3] > 1:
role = QtGui.QFormLayout.SpanningRole
elif grid_position[1] == 1:
role = QtGui.QFormLayout.FieldRole
else:
role = QtGui.QFormLayout.LabelRole
return role