本文整理汇总了Python中color.Color.from_string方法的典型用法代码示例。如果您正苦于以下问题:Python Color.from_string方法的具体用法?Python Color.from_string怎么用?Python Color.from_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类color.Color
的用法示例。
在下文中一共展示了Color.from_string方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from color import Color [as 别名]
# 或者: from color.Color import from_string [as 别名]
def __init__(self,
groups = [],
title = "",
description = "",
default_color = "black",
alphabet = seq.generic_alphabet) :
""" """
self.title= title
self.description = description
self.default_color = Color.from_string(default_color)
self.groups = groups
self.alphabet = alphabet
color = {}
if alphabet in [seq.codon_dna_alphabet, seq.codon_rna_alphabet]:
for cg in groups :
color[cg.symbols] = cg.color
if cg.symbols not in alphabet :
raise KeyError("Colored symbol does not exist in alphabet.")
else:
for cg in groups :
for s in cg.symbols :
color[s] = cg.color
if s not in alphabet :
raise KeyError("Colored symbol does not exist in alphabet.")
self._color = color
示例2: __init__
# 需要导入模块: from color import Color [as 别名]
# 或者: from color.Color import from_string [as 别名]
def __init__(self, symbols, color, description=None) :
self.symbols = symbols
self.color = Color.from_string(color)
self.description = description