Package: pystage
PyStageScratch-like Python programming.PyStage bridges the gap betweenScratchand Python. This module implements all code blocks
as available in scratch. With the PyStage command line converter Scratch projects can be easily
transferred to Python executable Code. To run your game in Python, PyStage usesPyGame.DemoConsider the following code. It defines a stage and a sprite on the stage. The functions are code blocks that are associated with events (i.e. connected to a hat block in Scratch) via the corresponding methods.frompystage.enimportStagestage=Stage()stage.add_backdrop("grid")zombie=stage.add_a_sprite()defdoit(zombie):zombie.say("Hello pyStage!")foriinrange(4):zombie.move(10)zombie.wait(1)zombie.think("This is awesome!")zombie.turn_left(90)zombie.wait(1)zombie.think("")zombie.say("Move me around with WASD.")zombie.when_program_starts(doit)defright(zombie):zombie.change_x_by(10)defleft(zombie):zombie.change_x_by(-10)defup(zombie):zombie.change_y_by(10)defdown(zombie):zombie.change_y_by(-10)zombie.when_key_pressed("d",right)zombie.when_key_pressed("a",left)zombie.when_key_pressed("w",up)zombie.when_key_pressed("s",down)stage.play()And here is the result:GoalsExport your Scratch project to real executable Python code!Helping coding beginners to learn Python "by Scratch".Implementation of scratch blocks in several languages (ideal for kids). As of now en and de.See our quick intro to PyStage for ScratchCon 2021Installationpip install pystageGetting startedIf you are interested in PyStage and want to get in touch, feel free to join us on ourDiscord Server.Currently, only the English API is fully translated, the German API is automatically generated. All other languages will be added when PyStage gets more stable. Get in touch if you want to help maintain a translation.For the English API, you can start with the following example code:frompystage.enimportSprite,Stagestage=Stage()zombie=stage.add_a_sprite()defdoit(zombie:Sprite):foriinrange(4):zombie.move(10)zombie.turn_left(90)zombie.wait(1)zombie.when_program_starts(doit)stage.play()Use the autocompletion of your editor to see what methods are available. There are methods for all Scratch blocks bound to your stage and sprite instances. Not all of them work. Motion and Looks is mostly implemented (besides graphics effects), the Pen extension works and most of Sensing should work as well. If you want to know the details, just check the files undersrc/pystge/core.The documentation is here:https://pystage.readthedocs.io/en/latest/pystage.en.htmlNOTEPlease note this is a pre alpha version. Not all things may work as expected. If so, please contact us or open an issue. Documentation is automatically generated but especially the user-facing block API is still mostly empty.Import your Scratch projectsConverting a Scratch project to Python code:Export your Scratch project on the Scratch page. You will get an .sb3 file.Use our command line converter. Yes, it's unhandy, we will work on it to make things easier.The base usage ispython -m pystage.convert.sb3 <SB3 File> -l en -d <DIRECTORY>The parameters are:-llanguage of generated python "scratch blocks". In the moment of writing,enanddeare available.-dthe output directory, defaults to current directory-iprint intermediate code representation-sprint sb3 project.json-pprint python code-vverbose-vvdebug modeContributorsKai Eckert, Stuttgart Media UniversityFlorian Rupp, Stuttgart Media University