本文整理汇总了Python中palette.Palette.new_from_simple_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Palette.new_from_simple_dict方法的具体用法?Python Palette.new_from_simple_dict怎么用?Python Palette.new_from_simple_dict使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类palette.Palette
的用法示例。
在下文中一共展示了Palette.new_from_simple_dict方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from palette import Palette [as 别名]
# 或者: from palette.Palette import new_from_simple_dict [as 别名]
def __init__(self, prefs, datapath):
"""Initialises with default colors and an empty adjuster list.
:param prefs: Prefs dict for saving settings.
:param datapath: Base path for saving palettes and masks.
"""
gobject.GObject.__init__(self)
# Defaults
self._color = None #: Currently edited color, a UIColor object
self._hist = [] #: List of previous colors, most recent last
self._palette = None #: Current working palette
self._adjusters = weakref.WeakSet() #: The set of registered adjusters
self._picker_cursor = gdk.Cursor(gdk.CROSSHAIR) #: Cursor for pickers
self._datapath = datapath #: Base path for saving palettes and masks
self._hue_distorts = None #: Hue-remapping table for color wheels
self._prefs = prefs #: Shared preferences dictionary
# Build the history. Last item is most recent.
hist_hex = list(prefs.get(PREFS_KEY_COLOR_HISTORY, []))
hist_hex = self._DEFAULT_HIST + hist_hex
self._hist = [RGBColor.new_from_hex_str(s) for s in hist_hex]
self._trim_hist()
# Restore current color, or use the most recent color.
col_hex = prefs.get(PREFS_KEY_CURRENT_COLOR, None)
if col_hex is None:
col_hex = hist_hex[-1]
self._color = RGBColor.new_from_hex_str(col_hex)
# Initialize angle distort table
wheel_type = prefs.get(PREFS_KEY_WHEEL_TYPE, self._DEFAULT_WHEEL_TYPE)
distorts_table = self._HUE_DISTORTION_TABLES[wheel_type]
self._hue_distorts = distorts_table
# Initialize working palette
palette_dict = prefs.get(PREFS_PALETTE_DICT_KEY, None)
if palette_dict is not None:
palette = Palette.new_from_simple_dict(palette_dict)
else:
datapath = self.get_data_path()
palettes_dir = os.path.join(datapath, DATAPATH_PALETTES_SUBDIR)
default = os.path.join(palettes_dir, DEFAULT_PALETTE_FILE)
palette = Palette(filename=default)
self._palette = palette
# Capture updates to the working palette
palette.info_changed += self._palette_changed_cb
palette.match_changed += self._palette_changed_cb
palette.sequence_changed += self._palette_changed_cb
palette.color_changed += self._palette_changed_cb