summaryrefslogtreecommitdiff
path: root/example.py
diff options
context:
space:
mode:
authorblob8108 <spaaam42@gmail.com>2014-04-16 19:12:46 +0100
committerblob8108 <spaaam42@gmail.com>2014-04-16 19:12:46 +0100
commitbea5d2c35de25466294cd78e9135062612b9ccb0 (patch)
treeed41840e12a079c942f2c74d8389dc06ee026ad6 /example.py
parent47cca8307ddb7d1c7749f4b8e8436b3c61fd113f (diff)
downloadblockext-bea5d2c35de25466294cd78e9135062612b9ccb0.tar.gz
blockext-bea5d2c35de25466294cd78e9135062612b9ccb0.zip
More interesting tests
Diffstat (limited to 'example.py')
-rw-r--r--example.py41
1 files changed, 39 insertions, 2 deletions
diff --git a/example.py b/example.py
index baff568..02c3896 100644
--- a/example.py
+++ b/example.py
@@ -1,3 +1,4 @@
+# coding=utf-8
import blockext
from blockext import *
@@ -20,20 +21,56 @@ def play_note(note):
print("DING {note}".format(note=note))
time.sleep(2)
-menu("pizza", ["tomato", "cheese", "hawaii"])
+menu("pizza", ["tomato", "cheese", "hawaii", "nothing",
+ "spinach and cauliflower", "empty return value",
+ "cheese and tomato", "fancy",
+ "ü",
+ "/",
+ ])
@reporter("colour of %m.pizza flavour pizza")
def pizza_colour(pizza="tomato"):
return {
"tomato": "red",
"cheese": "yellow",
- "hawaii": "orange",
+ "cheese and tomato": "YELLOW",
+ "hawaii": "orange AND BLUE",
+ "spinach and cauliflower": "GREEN ü",
+ "empty return value": "",
+ "nothing": "",
+ "/": "SLASH",
+ u"ü": "unicode",
+ u"fancy": "❤☀☆☂",
}[pizza]
+@reporter("spaaace")
+def getSpaaace():
+ return "space space space space space!"
+
@reporter("id %s")
def id(text):
+ """Tests strings can get passed from Snap! to Python and back."""
+ print(text)
return text
+@command("set number to %n% units")
+def percent(number=42):
+ print(number)
+
+foo = None
+
+@command("set foo to %s")
+def set_foo(value=''):
+ global foo
+ foo = value
+
+@reporter("foo")
+def get_foo():
+ return foo
+
+@command("ü")
+def x(): pass
+
@problem
def my_problem():
if time.time() % 8 > 4: