From 7fe18b6ad3acca38b4ace73113219a6e8e42d58f Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Tue, 31 Jan 2012 01:20:48 +0000 Subject: add method to set block color --- (limited to 'TurtleArt/tablock.py') diff --git a/TurtleArt/tablock.py b/TurtleArt/tablock.py index a0c0c2e..4015029 100644 --- a/TurtleArt/tablock.py +++ b/TurtleArt/tablock.py @@ -128,6 +128,7 @@ class Block: self.shapes = [None, None] self.name = name self.colors = colors + self._custom_colors = False self.scale = scale self.docks = None self.connections = None @@ -281,6 +282,11 @@ class Block: self.refresh() self.spr.inval() + def set_colors(self, colors): + self.colors = colors[:] + self._custom_colors = True + self.refresh() + def refresh(self): if self.spr is None: return @@ -487,6 +493,9 @@ class Block: self.block_methods['basic-style'](svg) def _set_colors(self, svg): + if self._custom_colors: + self.svg.set_colors(self.colors) + return if self.name in BOX_COLORS: self.colors = BOX_COLORS[self.name] elif self.name in special_block_colors: -- cgit v0.9.1