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


Python QByteArray.toBase64方法代码示例

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


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

示例1: queryExit

# 需要导入模块: from PyQt4.QtCore import QByteArray [as 别名]
# 或者: from PyQt4.QtCore.QByteArray import toBase64 [as 别名]
    def queryExit(self):
        """
        save config data before exiting
        """
        self.emit(SIGNAL("writeSettings()"))

        if self.miniMode:
            self.miniModeWindowSize = self.size()
        else:
            self.defaultWindowSize = self.size()

        GeneralConfig.writeEntry("Width", str(self.defaultWindowSize.width()))
        GeneralConfig.writeEntry("Height", str(self.defaultWindowSize.height()))
        GeneralConfig.writeEntry("LastX", str(self.x()))
        GeneralConfig.writeEntry("LastY", str(self.y()))
        GeneralConfig.writeEntry("Mini-mode Width",
            str(self.miniModeWindowSize.width()))
        GeneralConfig.writeEntry("Mini-mode Height",
            str(self.miniModeWindowSize.height()))

        GeneralConfig.writeEntry("Show installer on startup", 'False')
        GeneralConfig.writeEntry("Url History",
            self.characterCombo.historyItems()[:self.historyLength])
        GeneralConfig.writeEntry("Splitter",
            QByteArray.toBase64(self.splitterFrame.saveState()))

        GeneralConfig.writeEntry("Auto-Lookup clipboard", str(self.autoLookup))
        GeneralConfig.writeEntry("Auto-Lookup only Chinese characters",
            str(self.onlyAutoLookupCJKCharacters))

        # toolbox
        if self.characterChooser.isVisible():
            self.splitterSizes = self.splitterFrame.sizes()
        GeneralConfig.writeEntry("Splitter sizes", ",".join(
            [str(i) for i in self.splitterSizes]))

        if not self.miniMode:
            self.toolbarOriginalState = self.saveState(0)
        GeneralConfig.writeEntry("Toolbar original state",
            QByteArray.toBase64(self.toolbarOriginalState))

        GeneralConfig.writeEntry("Toolbox current",
            str(self.characterChooser.currentIndex()))
        GeneralConfig.writeEntry("Toolbox visibile",
            str(self.characterChooserOriginalVisibility))

        return True
开发者ID:cburgmer,项目名称:eclectus,代码行数:49,代码来源:main.py

示例2: writeSettings

# 需要导入模块: from PyQt4.QtCore import QByteArray [as 别名]
# 或者: from PyQt4.QtCore.QByteArray import toBase64 [as 别名]
 def writeSettings(self):
     if self.pluginConfig:
         self.pluginConfig.writeEntry("Component splitter",
             QByteArray.toBase64(self.componentSplitter.saveState()))
         self.pluginConfig.writeEntry("Component include similar",
             str(self.includeSimilar))
         self.pluginConfig.writeEntry("Component include variants",
             str(self.includeVariants))
开发者ID:cburgmer,项目名称:eclectus,代码行数:10,代码来源:componentpage.py

示例3: pasted

# 需要导入模块: from PyQt4.QtCore import QByteArray [as 别名]
# 或者: from PyQt4.QtCore.QByteArray import toBase64 [as 别名]
 def pasted(self, checked):
     clipboard = QApplication.clipboard()
     mime = clipboard.mimeData()
     if mime.hasImage():
         pixmap = clipboard.pixmap()
         byteArray = QByteArray()
         buffer = QBuffer(byteArray)
         pixmap.save(buffer, "PNG")
         self.call("setClipboard", str(byteArray.toBase64(), sys.stdout.encoding))
开发者ID:iddqdidkfa,项目名称:scudcloud,代码行数:11,代码来源:wrapper.py

示例4: get_html_img

# 需要导入模块: from PyQt4.QtCore import QByteArray [as 别名]
# 或者: from PyQt4.QtCore.QByteArray import toBase64 [as 别名]
def get_html_img(scene):
    """
    Create HTML img element with base64-encoded image from the scene
    """
    byte_array = QByteArray()
    filename = QBuffer(byte_array)
    filename.open(QIODevice.WriteOnly)
    PngFormat.write(filename, scene)
    img_encoded = byte_array.toBase64().data().decode("utf-8")
    return "<img src='data:image/png;base64,%s'/>" % img_encoded
开发者ID:JingqinGao,项目名称:orange3,代码行数:12,代码来源:report.py

示例5: editImage

# 需要导入模块: from PyQt4.QtCore import QByteArray [as 别名]
# 或者: from PyQt4.QtCore.QByteArray import toBase64 [as 别名]
    def editImage(self):
        global jpeg_dirname

        fileName = QFileDialog.getOpenFileName(self, _("JPEG-Filename"),
                                               jpeg_dirname,
                                               _("JPEG-Files (*.jpg)"))
        if fileName != "":
            fileName = str(fileName)
            (jpeg_dirname, ramsch) = os.path.split(fileName)
            if self.image is None:
                self.result.append((jpegPhoto, [""], False))
                self.image = ""
            for key, text, is_editable in self.result:
                if key == jpegPhoto:
                    string = open(fileName,"r").read()
                    byarr  = QByteArray(string)
                    by64   = byarr.toBase64()
                    text[0] = str(by64)
                    self.iconLabel.setPixmap(QPixmap.fromImage(
                      QImage.fromData(byarr, "JPG")))
                    self.iconButton.setText(_("Change picture"))
开发者ID:jedamus,项目名称:vim-python,代码行数:23,代码来源:edit_ldap_vim.py

示例6: base64image

# 需要导入模块: from PyQt4.QtCore import QByteArray [as 别名]
# 或者: from PyQt4.QtCore.QByteArray import toBase64 [as 别名]
def base64image(image):
  ba = QByteArray()
  buffer = QBuffer(ba)
  buffer.open(QIODevice.WriteOnly)
  image.save(buffer, "PNG")
  return "data:image/png;base64," + ba.toBase64().data()
开发者ID:biapar,项目名称:Qgis2threejs,代码行数:8,代码来源:qgis2threejstools.py

示例7: buildXmlTree

# 需要导入模块: from PyQt4.QtCore import QByteArray [as 别名]
# 或者: from PyQt4.QtCore.QByteArray import toBase64 [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
开发者ID:GoliathLeviathan,项目名称:SoulCreator,代码行数:104,代码来源:WriteXmlCharacter.py


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