本文整理汇总了Python中PyQt4.QtCore.QByteArray.decode方法的典型用法代码示例。如果您正苦于以下问题:Python QByteArray.decode方法的具体用法?Python QByteArray.decode怎么用?Python QByteArray.decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QByteArray
的用法示例。
在下文中一共展示了QByteArray.decode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: buildXmlTree
# 需要导入模块: from PyQt4.QtCore import QByteArray [as 别名]
# 或者: from PyQt4.QtCore.QByteArray import decode [as 别名]
#.........这里部分代码省略.........
derangements = etree.SubElement(root, "derangements")
for item in self.__character.derangements.items():
if item[1]:
etree.SubElement(derangements, "derangement", morality=str(item[0])).text = item[1]
## Eigenschaften
traits = etree.SubElement(root, "Traits")
for item in self.__character.traits:
traitTypeExists = False
traitType = None
for subitem in self.__character.traits[item]:
traitCategoryExists = False
traitCategory = None
for subsubitem in self.__character.traits[item][subitem].values():
## Eigenschaften müssen nur dann gespeichert werden, wenn ihr Wert != 0 ist und sie für die aktuell gewählte Spezies zur Verfügung stehen.
if ( subsubitem.value != 0 and (not subsubitem.species or subsubitem.species == self.__character.species) ):
if not traitTypeExists:
traitType = etree.SubElement(traits, "Type", name=item)
traitTypeExists = True
if not traitCategoryExists:
traitCategory = etree.SubElement(traitType, "Category", name=subitem)
traitCategoryExists = True
trait = etree.SubElement(traitCategory, "trait",
name=subsubitem.name,
value=str(subsubitem.value),
)
# Zusatztext
if item != "Subpower" and subsubitem.custom:
trait.attrib["customText"] = str( subsubitem.customText )
# Spezialisierungen
if subsubitem.specialties:
etree.SubElement(trait, "specialties").text = Config.XML_SEPARATION_SYMBOL.join( str(n) for n in subsubitem.specialties )
## Gegenstände
items = etree.SubElement(root, "Items")
if self.__character.weapons:
weapons = etree.SubElement(items, "Weapons")
for category in self.__character.weapons:
weaponCategory = etree.SubElement(weapons, "Category", name=category)
for weapon in self.__character.weapons[category]:
etree.SubElement(weaponCategory, "weapon").text = weapon
if self.__character.armor:
etree.SubElement(items, "armor", dedicated=str(self.__character.armor["dedicated"])).text = self.__character.armor["name"]
if self.__character.equipment or self.__character.magicalTool:
equipment = etree.SubElement(items, "Equipment")
for item in self.__character.equipment:
etree.SubElement(equipment, "equipment").text = item
if self.__character.magicalTool:
etree.SubElement(equipment, "magicalTool").text = self.__character.magicalTool
if self.__character.automobiles:
automobiles = etree.SubElement(items, "Automobiles")
for typ in self.__character.automobiles:
itemType = etree.SubElement(automobiles, "Type", name=typ)
for automobile in self.__character.automobiles[typ]:
etree.SubElement(itemType, "item").text = automobile
if self.__character.extraordinaryItems:
extraordinaries = etree.SubElement(items, "ExtraordinaryItems")
for typ in self.__character.extraordinaryItems:
itemType = etree.SubElement(extraordinaries, "Type", name=typ)
for extraordinaryItem in self.__character.extraordinaryItems[typ]:
etree.SubElement(itemType, "item").text = extraordinaryItem
## Spezialseigenschaften der Spezies
if self.__character.nimbus:
etree.SubElement(root, "nimbus").text = self.__character.nimbus
if self.__character.paradoxMarks:
etree.SubElement(root, "paradoxMarks").text = self.__character.paradoxMarks
if any((x.name and x.value > 0) for x in self.__character.vinculi):
vinculi = etree.SubElement(root, "vinculi")
for item in self.__character.vinculi:
if item.name and item.value > 0:
etree.SubElement(vinculi, "vinculum", value=str(item.value)).text = item.name
companion = etree.SubElement(
root,
"companion",
name = self.__character.companionName,
power = str(self.__character.companionPower),
finesse = str(self.__character.companionFinesse),
resistance = str(self.__character.companionResistance),
size = str(self.__character.companionSize),
speedFactor = str(self.__character.companionSpeedFactor),
)
for item in self.__character.companionNumina:
etree.SubElement(companion, "numen").text = item
for item in self.__character.companionInfluences:
if item.name and item.value > 0:
etree.SubElement(companion, "influence", value=str(item.value)).text = item.name
if self.__character.companionBan:
etree.SubElement(companion, "ban").text = self.__character.companionBan
if self.__character.picture:
imageData = QByteArray()
imageBuffer = QBuffer(imageData)
imageBuffer.open(QIODevice.WriteOnly)
self.__character.picture.save(imageBuffer, Config.CHARACTER_PIC_FORMAT) # Schreibt das Bild in ein QByteArray im angegebenen Bildformat.
imageData = imageData.toBase64().data()
etree.SubElement(root, "picture").text = imageData.decode("UTF-8")
return root