Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pysamples
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2012-07-18 21:08:22 (GMT)
committer Walter Bender <walter.bender@gmail.com>2012-07-18 21:08:22 (GMT)
commitd833da820c3b553b6309709396a6446a31ca6636 (patch)
treeb55331922fb76ec01979f3fc55288e80ca87eed4 /pysamples
parentd2871214f611d95529c5d15828584bdddf83e3f0 (diff)
load a palette from a block
Diffstat (limited to 'pysamples')
-rw-r--r--pysamples/load_palette.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/pysamples/load_palette.py b/pysamples/load_palette.py
new file mode 100644
index 0000000..85e4910
--- /dev/null
+++ b/pysamples/load_palette.py
@@ -0,0 +1,24 @@
+#Copyright (c) 2012, Walter Bender
+
+# This procedure is invoked when the user-definable block on the
+# "extras" palette is selected.
+
+# Usage: Import this code into a Python (user-definable) block; when
+# it is run, the selected palette is loaded
+
+
+def myblock(tw, arg):
+ ''' Select a palette '''
+
+ from TurtleArt.tapalette import make_palette, palette_name_to_index
+ from TurtleArt.talogo import primitive_dictionary
+ from gettext import gettext as _
+
+ # Select the palette, which will now include the new block.
+ if type(arg) == int:
+ tw.show_toolbar_palette(arg)
+ else:
+ if type(arg) == unicode:
+ arg = arg.encode('ascii', 'replace')
+ tw.show_toolbar_palette(palette_name_to_index(arg))
+