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


Python Color.init_hex方法代码示例

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


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

示例1: fillRecdFromNode

# 需要导入模块: from color import Color [as 别名]
# 或者: from color.Color import init_hex [as 别名]
def fillRecdFromNode( recd, el ):
    if (el.getAttributeNode(Constants.recdType) != None):
        typeInt = int(el.getAttribute(Constants.recdType))
        recd.type = typeInt

    if (el.getAttributeNode(Constants.recdTitle) != None):
        recd.title = el.getAttribute(Constants.recdTitle)

    if (el.getAttributeNode(Constants.recdTime) != None):
        timeInt = int(el.getAttribute(Constants.recdTime))
        recd.time = timeInt

    if (el.getAttributeNode(Constants.recdRecorderName) != None):
        recd.recorderName = el.getAttribute(Constants.recdRecorderName)

    if (el.getAttributeNode(Constants.recdTags) != None):
        recd.tags = el.getAttribute(Constants.recdTags)
    else:
        recd.tags = ""

    if (el.getAttributeNode(Constants.recdRecorderHash) != None):
        recd.recorderHash = el.getAttribute(Constants.recdRecorderHash)

    if (el.getAttributeNode(Constants.recdColorStroke) != None):
        try:
            colorStrokeHex = el.getAttribute(Constants.recdColorStroke)
            colorStroke = Color()
            colorStroke.init_hex(colorStrokeHex)
            recd.colorStroke = colorStroke
        except:
            record.Record.log.error("unable to load recd colorStroke")

    if (el.getAttributeNode(Constants.recdColorFill) != None):
        try:
            colorFillHex = el.getAttribute(Constants.recdColorFill)
            colorFill = Color()
            colorFill.init_hex( colorFillHex )
            recd.colorFill = colorFill
        except:
            record.Record.log.error("unable to load recd colorFill")

    if (el.getAttributeNode(Constants.recdBuddy) != None):
        recd.buddy = (el.getAttribute(Constants.recdBuddy) == "True")

    if (el.getAttributeNode(Constants.recdMediaMd5) != None):
        recd.mediaMd5 = el.getAttribute(Constants.recdMediaMd5)

    if (el.getAttributeNode(Constants.recdThumbMd5) != None):
        recd.thumbMd5 = el.getAttribute(Constants.recdThumbMd5)

    if (el.getAttributeNode(Constants.recdMediaBytes) != None):
        recd.mediaBytes = el.getAttribute(Constants.recdMediaBytes)

    if (el.getAttributeNode(Constants.recdThumbBytes) != None):
        recd.thumbBytes = el.getAttribute(Constants.recdThumbBytes)

    bt = el.getAttributeNode(Constants.recdBase64Thumb)
    if (bt != None):
        try:
            thumbPath = os.path.join(Instance.instancePath, "datastoreThumb.jpg")
            thumbPath = utils.getUniqueFilepath( thumbPath, 0 )
            thumbImg = utils.getPixbufFromString( bt.nodeValue )
            thumbImg.save(thumbPath, "jpeg", {"quality":"85"} )
            recd.thumbFilename = os.path.basename(thumbPath)
            record.Record.log.debug("saved thumbFilename")
        except:
            record.Record.log.error("unable to getRecdBase64Thumb")

    ai = el.getAttributeNode(Constants.recdAudioImage)
    if (not ai == None):
        try:
            audioImagePath = os.path.join(Instance.instancePath, "audioImage.png")
            audioImagePath = utils.getUniqueFilepath( audioImagePath, 0 )
            audioImage = utils.getPixbufFromString( ai.nodeValue )
            audioImage.save(audioImagePath, "png", {} )
            recd.audioImageFilename = os.path.basename(audioImagePath)
            record.Record.log.debug("loaded audio image and set audioImageFilename")
        except:
            record.Record.log.error("unable to load audio image")

    datastoreNode = el.getAttributeNode(Constants.recdDatastoreId)
    if (datastoreNode != None):
        recd.datastoreId = datastoreNode.nodeValue

    return recd
开发者ID:linux4kix,项目名称:Record.activity,代码行数:87,代码来源:serialize.py


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