Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2010-10-20 00:09:19 (GMT)
committer Walter Bender <walter@sugarlabs.org>2010-10-20 00:09:19 (GMT)
commit25320dff083ef6dfeadf416956353bc42cd7d54c (patch)
tree36202132a0204e97428d46a3a038926a956b81d5
parent28eb1393e56dc0bceee44a5fa05c7296028a5b66 (diff)
only allow one start, hat1, or hat2 block per project
-rw-r--r--TurtleArt/tablock.py6
-rw-r--r--TurtleArt/tawindow.py5
2 files changed, 11 insertions, 0 deletions
diff --git a/TurtleArt/tablock.py b/TurtleArt/tablock.py
index 344f2da..865e8e9 100644
--- a/TurtleArt/tablock.py
+++ b/TurtleArt/tablock.py
@@ -113,6 +113,12 @@ class Blocks:
i += 1
return None
+ def get_block_of_same_type_and_name(self, type, name):
+ for block in self.list:
+ if block.type == type and block.name == name:
+ return block
+ return None
+
class Block:
""" A class for the individual blocks """
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index 1bc7ab8..2853bbd 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -782,6 +782,11 @@ class TurtleArtWindow():
elif blk.name in MACROS:
self._new_macro(blk.name, x + 20, y + 20)
else:
+ # You can only have one instance of some blocks
+ if blk.name in ['start', 'hat1', 'hat2']:
+ if self.block_list.get_block_of_same_type_and_name(
+ 'block', blk.name) is not None:
+ return True
blk.highlight()
self._new_block(blk.name, x, y)
blk.unhighlight()