Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » SKIP: a Python Scratch Interpreter based on Kurt
- blob8108
-
Scratcher
1000+ posts
SKIP: a Python Scratch Interpreter based on Kurt
Since the Barcelona Scratch conference a week ago, I've been working on a Scratch interpreter (ie. a player for Scratch projects) in Python, based on my Kurt package. (See the slides from my talk on Kurt.)
SKIP is still experimental/in-progress, but I've pushed the source to Github in case anyone wants to have a look.
It requires:
* Pygame
* the development version of Kurt 2.0, from the kurt2 branch
Progress
Most of the 1.4 blocks are implemented, except for:
* text-related: “say”, “ask”, variable/list watchers
* sounds & instruments
* graphic effects other than “ghost”
All of the graphics-related stuff is in a separate file, pygame_screen.py, so it should be possible to implement the interpreter for other graphics libraries (e.g. wxPython).
Usage
Run it from Terminal, passsing the path to a Scratch file:
A graphics window will open showing the stage. You can type scripts into the terminal window to execute them while the project is running.
It also includes a simple console interface. Example usage:
SKIP is still experimental/in-progress, but I've pushed the source to Github in case anyone wants to have a look.
It requires:
* Pygame
* the development version of Kurt 2.0, from the kurt2 branch
Progress
Most of the 1.4 blocks are implemented, except for:
* text-related: “say”, “ask”, variable/list watchers
* sounds & instruments
* graphic effects other than “ghost”
All of the graphics-related stuff is in a separate file, pygame_screen.py, so it should be possible to implement the interpreter for other graphics libraries (e.g. wxPython).
Usage
Run it from Terminal, passsing the path to a Scratch file:
$ python skip/pygame_screen.py game.sb
It also includes a simple console interface. Example usage:
$ python skip/console_screen.py
Ctrl+D or `;` to evaluate input
Extra commands: start, stop
=>Sprite1
-----
ask "What's your name?" and wait
say join "Hello, " join answer "!"
;
...
Sprite1 asks: What's your name?
? blob
Sprite1: say u'Hello, blob!'
-----
Last edited by blob8108 (Aug. 3, 2013 15:29:22)
- technoboy10
-
Scratcher
1000+ posts
SKIP: a Python Scratch Interpreter based on Kurt
Traceback (most recent call last):
File “pygame_screen.py”, line 307, in <module>
main(project)
File “pygame_screen.py”, line 215, in main
screen.tick()
File “pygame_screen.py”, line 112, in tick
self.draw_sprite(self.project.stage, self.surface)
File “pygame_screen.py”, line 122, in draw_sprite
surface = self.surfaces
AttributeError: ‘NoneType’ object has no attribute ‘image’
File “pygame_screen.py”, line 307, in <module>
main(project)
File “pygame_screen.py”, line 215, in main
screen.tick()
File “pygame_screen.py”, line 112, in tick
self.draw_sprite(self.project.stage, self.surface)
File “pygame_screen.py”, line 122, in draw_sprite
surface = self.surfaces
AttributeError: ‘NoneType’ object has no attribute ‘image’
- blob8108
-
Scratcher
1000+ posts
SKIP: a Python Scratch Interpreter based on Kurt
AttributeError: ‘NoneType’ object has no attribute ‘image’Are you using the wrong version of kurt? Can you send me the project file?
- technoboy10
-
Scratcher
1000+ posts
SKIP: a Python Scratch Interpreter based on Kurt
I was trying to run the pygame_screen.py file. How is it supposed to be run?
- blob8108
-
Scratcher
1000+ posts
SKIP: a Python Scratch Interpreter based on Kurt
Oh, right. You need to pass it the path to a Scratch file:
$ python skip/pygame_screen.py game.sb
$ python skip/pygame_screen.py game.sb
- technoboy10
-
Scratcher
1000+ posts
SKIP: a Python Scratch Interpreter based on Kurt
Ctrl+D or `;` to evaluate input
Extra commands: start, stop
=>Sprite1
—–
Traceback (most recent call last):
File “pygame_screen.py”, line 307, in <module>
main(project)
File “pygame_screen.py”, line 229, in main
screen.tick()
File “pygame_screen.py”, line 102, in tick
for event in self.interpreter.tick(events):
File “/home/tiberiusgeek/kurt2/skip/__init__.py”, line 172, in tick
for event in thread.tick():
File “/home/tiberiusgeek/kurt2/skip/__init__.py”, line 37, in tick
event = self.generator.next()
File “/home/tiberiusgeek/kurt2/skip/__init__.py”, line 206, in run_script
for x in self.evaluate(s, block):
File “/home/tiberiusgeek/kurt2/skip/__init__.py”, line 238, in evaluate
in zip(list(value.args), value.type.inserts)]
File “/home/tiberiusgeek/kurt2/skip/__init__.py”, line 219, in evaluate
if insert and insert.unevaluated:
AttributeError: ‘Insert’ object has no attribute ‘unevaluated’
Extra commands: start, stop
=>Sprite1
—–
Traceback (most recent call last):
File “pygame_screen.py”, line 307, in <module>
main(project)
File “pygame_screen.py”, line 229, in main
screen.tick()
File “pygame_screen.py”, line 102, in tick
for event in self.interpreter.tick(events):
File “/home/tiberiusgeek/kurt2/skip/__init__.py”, line 172, in tick
for event in thread.tick():
File “/home/tiberiusgeek/kurt2/skip/__init__.py”, line 37, in tick
event = self.generator.next()
File “/home/tiberiusgeek/kurt2/skip/__init__.py”, line 206, in run_script
for x in self.evaluate(s, block):
File “/home/tiberiusgeek/kurt2/skip/__init__.py”, line 238, in evaluate
in zip(list(value.args), value.type.inserts)]
File “/home/tiberiusgeek/kurt2/skip/__init__.py”, line 219, in evaluate
if insert and insert.unevaluated:
AttributeError: ‘Insert’ object has no attribute ‘unevaluated’
- blob8108
-
Scratcher
1000+ posts
SKIP: a Python Scratch Interpreter based on Kurt
AttributeError: ‘Insert’ object has no attribute ‘unevaluated’Oh, sorry – the interpreter depends on some local changes to Kurt that I haven't pushed yet. I'll go fix that…
- davidkt
-
Scratcher
1000+ posts
SKIP: a Python Scratch Interpreter based on Kurt
Oh, right. You need to pass it the path to a Scratch file:Why don't you have it check the sys.argv variable to see if it has a second argument in the form "****.sb[2]“ (that's what regexes are for!) so that it says ”Usage: …" instead of an ugly error message that will have no meaning to non-Python programmers.
$ python skip/pygame_screen.py game.sb
- technoboy10
-
Scratcher
1000+ posts
SKIP: a Python Scratch Interpreter based on Kurt
Wow, this is so cool!
I couldn't get pen blocks working, are they implemented?
I couldn't get pen blocks working, are they implemented?Last edited by technoboy10 (Aug. 3, 2013 02:25:00)
- technoboy10
-
Scratcher
1000+ posts
SKIP: a Python Scratch Interpreter based on Kurt
Comments don't play nice.
- blob8108
-
Scratcher
1000+ posts
SKIP: a Python Scratch Interpreter based on Kurt
@tb Thanks! Stamping works, but that's it. I need to add pen to the list.
Comments? Oh, darn, I forgot to check for those. I should really just add `blocks = ` to Comment and be done with them.
@davidkt The ugly error message is fixed now: it's supposed to load a default project, but didn't because of a bug.
Comments? Oh, darn, I forgot to check for those. I should really just add `blocks = ` to Comment and be done with them.
@davidkt The ugly error message is fixed now: it's supposed to load a default project, but didn't because of a bug.
- BigBlueBlock
-
Scratcher
500+ posts
SKIP: a Python Scratch Interpreter based on Kurt
How did you get Pygame working?
I didn't succeed using the installer.
I didn't succeed using the installer.
Last edited by BigBlueBlock (Aug. 3, 2013 07:51:27)
- blob8108
-
Scratcher
1000+ posts
SKIP: a Python Scratch Interpreter based on Kurt
How did you get Pygame working?Which platform?
I didn't succeed using the installer.
- BigBlueBlock
-
Scratcher
500+ posts
SKIP: a Python Scratch Interpreter based on Kurt
Windows 8 64-bit.Python 3.30How did you get Pygame working?Which platform?
I didn't succeed using the installer.
- blob8108
-
Scratcher
1000+ posts
SKIP: a Python Scratch Interpreter based on Kurt
Ah, you need to use Python 2.7. A lot of packages don't fully support Python 3 yet (and I don't think my code will, either).Windows 8 64-bit.Python 3.30How did you get Pygame working?Which platform?
I didn't succeed using the installer.
You should be able to use the installer on the download page. Make sure you use 32-bit Python 2.7, with the corresponding version of Pygame.
Alternatively (I haven't tested these) you could try the Pygame installers from this page.
- technoboy10
-
Scratcher
1000+ posts
SKIP: a Python Scratch Interpreter based on Kurt
@blob Check the GH issues list. Got a couple more bugs for ya. 
Also, graphic effects aren't implemented yet, right?

Also, graphic effects aren't implemented yet, right?
- BigBlueBlock
-
Scratcher
500+ posts
SKIP: a Python Scratch Interpreter based on Kurt
I don't get an error when I import Pygame into Python3.3.Ah, you need to use Python 2.7. A lot of packages don't fully support Python 3 yet (and I don't think my code will, either).Windows 8 64-bit.Python 3.30How did you get Pygame working?Which platform?
I didn't succeed using the installer.
You should be able to use the installer on the download page. Make sure you use 32-bit Python 2.7, with the corresponding version of Pygame.
Alternatively (I haven't tested these) you could try the Pygame installers from this page.
- blob8108
-
Scratcher
1000+ posts
SKIP: a Python Scratch Interpreter based on Kurt
graphic effects aren't implemented yet, right?Other than ghost, no. *adds to list*
- Discussion Forums
- » Advanced Topics
-
» SKIP: a Python Scratch Interpreter based on Kurt





