Giter VIP home page Giter VIP logo

scratch2python's Introduction

Scratch2Python

GitHub GitHub issues GitHub pull requests GitHub milestones GitHub forks GitHub all releases

All Contributors

Scratch2Python is a Scratch project interpreter that runs Scratch projects in Python, using pygame to render your sprites. Go to #23 if you want to change the name.

Unlike others, Scratch2Python can actually display your projects, not only process the variables, control flow, math and logic in the project, and simply print speech bubble blocks.

It's not finished though. It only supports a few blocks, but it supports them well. The goal is to support almost everything (save for online services like text-to-speech) when we'll declare it as done. (Of course we'll still update things like the GUI.)

Scratch2Python is not yet a transpiler.

πŸ“ Requirements and installation

πŸ“₯ Visit the website to easily download Scratch2Python

Then install from requirements.txt using:

pip install -r requirements.txt

Scratch2Python also needs Python 3.8 or newer. Click here to download Python for Windows and Mac. On recent GNU/Linux distros (Ubuntu 20.04+, Debian 11+, Linux Mint 20+, Fedora 32+, updated rolling-release distros), Python 3 is preinstalled or downloadable from the repositories. Check your distro's documentation for more info.

Getting errors on Windows?

On Windows, Scratch2Python needs to be installed in a non-protected folder. By default, the β€œDocuments” folder is protected. Installing it anywhere else will work.

To unprotect the β€œDocuments” folder, go to its Properties and uncheck the β€œRead-only” checkbox.

▢️ Setting the project

Now that you have downloaded Scratch2Python, let's run a project.

Using test mode

For now Scratch2Python is in test mode by default. That means it will always run the project defined in the projectFileName variable in config.py. The variable can be a path, which will load the project there, or a Scratch ID / URL, which will download and cache the specified online project. No support for downloading unshared projects is provided! (The Scratch Team will implement access control, and it won't be possible anyway soon too.)

GUI (experimental)

Change the testMode variable to False so Scratch2Python will open a GUI when started. For now this is a basic filechooser, but we'll implement a proper full GUI soon.

πŸ“– Wiki

Our GitHub Wiki may have some outdated information and it is short, but still useful.

πŸ§‘β€πŸ’» Contributors

Thanks to the people listed here for contributing to Scratch2Python! (emoji key):


Secret-chest

πŸ’» πŸ“† 🎨 πŸ“– πŸ› 🌍 πŸ–‹

tigercoding56

πŸ“– πŸ€”

superscratch444tre

πŸ’» πŸ› ⚠️

Melt

πŸ› ⚠️

This project follows the all-contributors specification. Contributions of any kind welcome! Add your name here: #29

scratch2python's People

Contributors

allcontributors[bot] avatar secret-chest avatar superscratch444tre avatar tigercoding56 avatar win-ini avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

scratch2python's Issues

Make a GUI

Make a GUI.

I'm going to use GTK+ 3 and bundle it on Windows (with an aproppiate theme).

image

(Glade mockup)

Traceback

Error:

Scratch2Python M13 (development version) running on linux
Loading project
DEBUG: New position (0, 0) set for sprite Stage
DEBUG: New position (240, 0) set for sprite test4
DEBUG: New position (0, 195.5) set for sprite test3
Extracting project
Traceback (most recent call last):
  File "main.py", line 156, in <module>
    class SizeDialog(tkinter.simpledialog.Dialog):
  File "main.py", line 160, in SizeDialog
    def body(self, master) -> tuple[str, str]:
TypeError: 'type' object is not subscriptable

I don't what else to say, but my config file uses the default options.

Cannot have multiple event handlers for one key

What did you expect to happen?

Two hat blocks with the same key selected to simultaneously run

What did actually happen?

Scratch2Python crashed

How did you make that happen?

Trying to have two hat blocks with the same key selected and pressing the key

Python errors

not now

Latest version

  • I am running the latest version

Block support

Support Scratch blocks. More will be added when these are about to be finished.

Note: Rotation is rendered but blocks using it are not supported, so no linked issue.

  • when flag clicked
  • set x/y
  • change x/y
  • go to x, y
  • x position (nneds #5)
  • y position (needs #5)
  • point in direction
  • point towards mouse
  • point towards sprite
  • turn left
  • turn right
  • direction (needs #5)
  • go to mouse
  • mouse x (needs #5)
  • mouse y (needs #5)
  • wait seconds
  • wait until
  • go to sprite
  • when key pressed (needs #7)
  • key pressed? (needs #7, #5)
  • if then
  • if then else
  • repeat until
  • repeat
  • forever
  • set size
  • change size
  • variable (needs #5, #6)
  • set variable (needs #6)
  • change variable (needs #6)
  • touching? (needs #5)
  • touching color? (needs #5)
  • equals (needs #5)
  • greater than (needs #5)
  • less than (needs #5)
  • + (needs #5)
  • - (needs #5)
  • * (needs #5)
  • / (needs #5)
  • mod (needs #5)
  • random (needs #5)
  • go to random

Uniform page size for all sprite images

Place the sprite images (costumes) on a transparent image the size of the stage. This should allow easier rotation centre handling. Additionally, images should be optionally scaled to allow for better resolution.

scratch-render-fonts fonts

Scratch2Python should render these fonts in SVGs. Note that they have generic names in the Scratch project editor and in the SVGs (Noto Sans Medium is "Sans Serif", Source Serif Pro is "Serif", Knewave is "Marker", Grand9K-Pixel is "Pixel", Handlee is "Handwriting" and Griffy is "Curly".

The Scratch font won't be added due to licensing issues.

Some SVGs don't show up correctly

Describe the bug
Some SVGs show up in the wrong position

To Reproduce
Sample project Cake.sb3

Expected behavior
The background should be centered

Screenshots
image

Additional context

Modular blocks

Blocks should be modularised and split into separate plugins.

Milestone 12 errors

Screenshots
image

Additional context
These errors did not appear in Milestone 11.

Bug report

What did you expect to happen?

Last login: Fri Oct 6 21:36:57 on console
zain@Kholoods-MacBook-Pro ~ % alias python=python3

zain@Kholoods-MacBook-Pro ~ % alias pip=pip3

zain@Kholoods-MacBook-Pro ~ % git clone https://github.com/Secret-chest/scratch2python.git
Cloning into 'scratch2python'...
remote: Enumerating objects: 1582, done.
remote: Counting objects: 100% (376/376), done.
remote: Compressing objects: 100% (202/202), done.
remote: Total 1582 (delta 264), reused 240 (delta 163), pack-reused 1206
Receiving objects: 100% (1582/1582), 21.78 MiB | 12.06 MiB/s, done.
Resolving deltas: 100% (961/961), done.
zain@Kholoods-MacBook-Pro ~ % cd scratch2python
zain@Kholoods-MacBook-Pro scratch2python % pip install -r requirements.txt
Defaulting to user installation because normal site-packages is not writeable
ERROR: Ignored the following versions that require a different python version: 1.21.2 Requires-Python >=3.7,<3.11; 1.21.3 Requires-Python >=3.7,<3.11; 1.21.4 Requires-Python >=3.7,<3.11; 1.21.5 Requires-Python >=3.7,<3.11; 1.21.6 Requires-Python >=3.7,<3.11
ERROR: Could not find a version that satisfies the requirement numpy~=1.21.2 (from versions: 1.3.0, 1.4.1, 1.5.0, 1.5.1, 1.6.0, 1.6.1, 1.6.2, 1.7.0, 1.7.1, 1.7.2, 1.8.0, 1.8.1, 1.8.2, 1.9.0, 1.9.1, 1.9.2, 1.9.3, 1.10.0.post2, 1.10.1, 1.10.2, 1.10.4, 1.11.0, 1.11.1, 1.11.2, 1.11.3, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 1.13.3, 1.14.0, 1.14.1, 1.14.2, 1.14.3, 1.14.4, 1.14.5, 1.14.6, 1.15.0, 1.15.1, 1.15.2, 1.15.3, 1.15.4, 1.16.0, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5, 1.16.6, 1.17.0, 1.17.1, 1.17.2, 1.17.3, 1.17.4, 1.17.5, 1.18.0, 1.18.1, 1.18.2, 1.18.3, 1.18.4, 1.18.5, 1.19.0, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.19.5, 1.20.0, 1.20.1, 1.20.2, 1.20.3, 1.21.0, 1.21.1, 1.22.0, 1.22.1, 1.22.2, 1.22.3, 1.22.4, 1.23.0rc1, 1.23.0rc2, 1.23.0rc3, 1.23.0, 1.23.1, 1.23.2, 1.23.3, 1.23.4, 1.23.5, 1.24.0rc1, 1.24.0rc2, 1.24.0, 1.24.1, 1.24.2, 1.24.3, 1.24.4, 1.25.0rc1, 1.25.0, 1.25.1, 1.25.2, 1.26.0b1, 1.26.0rc1, 1.26.0)
ERROR: No matching distribution found for numpy~=1.21.2
zain@Kholoods-MacBook-Pro scratch2python %

What did actually happen?

Last login: Fri Oct 6 21:36:57 on console
zain@Kholoods-MacBook-Pro ~ % alias python=python3

zain@Kholoods-MacBook-Pro ~ % alias pip=pip3

zain@Kholoods-MacBook-Pro ~ % git clone https://github.com/Secret-chest/scratch2python.git
Cloning into 'scratch2python'...
remote: Enumerating objects: 1582, done.
remote: Counting objects: 100% (376/376), done.
remote: Compressing objects: 100% (202/202), done.
remote: Total 1582 (delta 264), reused 240 (delta 163), pack-reused 1206
Receiving objects: 100% (1582/1582), 21.78 MiB | 12.06 MiB/s, done.
Resolving deltas: 100% (961/961), done.
zain@Kholoods-MacBook-Pro ~ % cd scratch2python
zain@Kholoods-MacBook-Pro scratch2python % pip install -r requirements.txt
Defaulting to user installation because normal site-packages is not writeable
ERROR: Ignored the following versions that require a different python version: 1.21.2 Requires-Python >=3.7,<3.11; 1.21.3 Requires-Python >=3.7,<3.11; 1.21.4 Requires-Python >=3.7,<3.11; 1.21.5 Requires-Python >=3.7,<3.11; 1.21.6 Requires-Python >=3.7,<3.11
ERROR: Could not find a version that satisfies the requirement numpy~=1.21.2 (from versions: 1.3.0, 1.4.1, 1.5.0, 1.5.1, 1.6.0, 1.6.1, 1.6.2, 1.7.0, 1.7.1, 1.7.2, 1.8.0, 1.8.1, 1.8.2, 1.9.0, 1.9.1, 1.9.2, 1.9.3, 1.10.0.post2, 1.10.1, 1.10.2, 1.10.4, 1.11.0, 1.11.1, 1.11.2, 1.11.3, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 1.13.3, 1.14.0, 1.14.1, 1.14.2, 1.14.3, 1.14.4, 1.14.5, 1.14.6, 1.15.0, 1.15.1, 1.15.2, 1.15.3, 1.15.4, 1.16.0, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5, 1.16.6, 1.17.0, 1.17.1, 1.17.2, 1.17.3, 1.17.4, 1.17.5, 1.18.0, 1.18.1, 1.18.2, 1.18.3, 1.18.4, 1.18.5, 1.19.0, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.19.5, 1.20.0, 1.20.1, 1.20.2, 1.20.3, 1.21.0, 1.21.1, 1.22.0, 1.22.1, 1.22.2, 1.22.3, 1.22.4, 1.23.0rc1, 1.23.0rc2, 1.23.0rc3, 1.23.0, 1.23.1, 1.23.2, 1.23.3, 1.23.4, 1.23.5, 1.24.0rc1, 1.24.0rc2, 1.24.0, 1.24.1, 1.24.2, 1.24.3, 1.24.4, 1.25.0rc1, 1.25.0, 1.25.1, 1.25.2, 1.26.0b1, 1.26.0rc1, 1.26.0)
ERROR: No matching distribution found for numpy~=1.21.2
zain@Kholoods-MacBook-Pro scratch2python %

How did you make that happen?

Last login: Fri Oct 6 21:36:57 on console
zain@Kholoods-MacBook-Pro ~ % alias python=python3

zain@Kholoods-MacBook-Pro ~ % alias pip=pip3

zain@Kholoods-MacBook-Pro ~ % git clone https://github.com/Secret-chest/scratch2python.git
Cloning into 'scratch2python'...
remote: Enumerating objects: 1582, done.
remote: Counting objects: 100% (376/376), done.
remote: Compressing objects: 100% (202/202), done.
remote: Total 1582 (delta 264), reused 240 (delta 163), pack-reused 1206
Receiving objects: 100% (1582/1582), 21.78 MiB | 12.06 MiB/s, done.
Resolving deltas: 100% (961/961), done.
zain@Kholoods-MacBook-Pro ~ % cd scratch2python
zain@Kholoods-MacBook-Pro scratch2python % pip install -r requirements.txt
Defaulting to user installation because normal site-packages is not writeable
ERROR: Ignored the following versions that require a different python version: 1.21.2 Requires-Python >=3.7,<3.11; 1.21.3 Requires-Python >=3.7,<3.11; 1.21.4 Requires-Python >=3.7,<3.11; 1.21.5 Requires-Python >=3.7,<3.11; 1.21.6 Requires-Python >=3.7,<3.11
ERROR: Could not find a version that satisfies the requirement numpy~=1.21.2 (from versions: 1.3.0, 1.4.1, 1.5.0, 1.5.1, 1.6.0, 1.6.1, 1.6.2, 1.7.0, 1.7.1, 1.7.2, 1.8.0, 1.8.1, 1.8.2, 1.9.0, 1.9.1, 1.9.2, 1.9.3, 1.10.0.post2, 1.10.1, 1.10.2, 1.10.4, 1.11.0, 1.11.1, 1.11.2, 1.11.3, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 1.13.3, 1.14.0, 1.14.1, 1.14.2, 1.14.3, 1.14.4, 1.14.5, 1.14.6, 1.15.0, 1.15.1, 1.15.2, 1.15.3, 1.15.4, 1.16.0, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5, 1.16.6, 1.17.0, 1.17.1, 1.17.2, 1.17.3, 1.17.4, 1.17.5, 1.18.0, 1.18.1, 1.18.2, 1.18.3, 1.18.4, 1.18.5, 1.19.0, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.19.5, 1.20.0, 1.20.1, 1.20.2, 1.20.3, 1.21.0, 1.21.1, 1.22.0, 1.22.1, 1.22.2, 1.22.3, 1.22.4, 1.23.0rc1, 1.23.0rc2, 1.23.0rc3, 1.23.0, 1.23.1, 1.23.2, 1.23.3, 1.23.4, 1.23.5, 1.24.0rc1, 1.24.0rc2, 1.24.0, 1.24.1, 1.24.2, 1.24.3, 1.24.4, 1.25.0rc1, 1.25.0, 1.25.1, 1.25.2, 1.26.0b1, 1.26.0rc1, 1.26.0)
ERROR: No matching distribution found for numpy~=1.21.2
zain@Kholoods-MacBook-Pro scratch2python %

Python errors

Last login: Fri Oct  6 21:36:57 on console
zain@Kholoods-MacBook-Pro ~ % alias python=python3


zain@Kholoods-MacBook-Pro ~ % alias pip=pip3      


zain@Kholoods-MacBook-Pro ~ % git clone https://github.com/Secret-chest/scratch2python.git
Cloning into 'scratch2python'...
remote: Enumerating objects: 1582, done.
remote: Counting objects: 100% (376/376), done.
remote: Compressing objects: 100% (202/202), done.
remote: Total 1582 (delta 264), reused 240 (delta 163), pack-reused 1206
Receiving objects: 100% (1582/1582), 21.78 MiB | 12.06 MiB/s, done.
Resolving deltas: 100% (961/961), done.
zain@Kholoods-MacBook-Pro ~ % cd scratch2python
zain@Kholoods-MacBook-Pro scratch2python % pip install -r requirements.txt
Defaulting to user installation because normal site-packages is not writeable
ERROR: Ignored the following versions that require a different python version: 1.21.2 Requires-Python >=3.7,<3.11; 1.21.3 Requires-Python >=3.7,<3.11; 1.21.4 Requires-Python >=3.7,<3.11; 1.21.5 Requires-Python >=3.7,<3.11; 1.21.6 Requires-Python >=3.7,<3.11
ERROR: Could not find a version that satisfies the requirement numpy~=1.21.2 (from versions: 1.3.0, 1.4.1, 1.5.0, 1.5.1, 1.6.0, 1.6.1, 1.6.2, 1.7.0, 1.7.1, 1.7.2, 1.8.0, 1.8.1, 1.8.2, 1.9.0, 1.9.1, 1.9.2, 1.9.3, 1.10.0.post2, 1.10.1, 1.10.2, 1.10.4, 1.11.0, 1.11.1, 1.11.2, 1.11.3, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 1.13.3, 1.14.0, 1.14.1, 1.14.2, 1.14.3, 1.14.4, 1.14.5, 1.14.6, 1.15.0, 1.15.1, 1.15.2, 1.15.3, 1.15.4, 1.16.0, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5, 1.16.6, 1.17.0, 1.17.1, 1.17.2, 1.17.3, 1.17.4, 1.17.5, 1.18.0, 1.18.1, 1.18.2, 1.18.3, 1.18.4, 1.18.5, 1.19.0, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.19.5, 1.20.0, 1.20.1, 1.20.2, 1.20.3, 1.21.0, 1.21.1, 1.22.0, 1.22.1, 1.22.2, 1.22.3, 1.22.4, 1.23.0rc1, 1.23.0rc2, 1.23.0rc3, 1.23.0, 1.23.1, 1.23.2, 1.23.3, 1.23.4, 1.23.5, 1.24.0rc1, 1.24.0rc2, 1.24.0, 1.24.1, 1.24.2, 1.24.3, 1.24.4, 1.25.0rc1, 1.25.0, 1.25.1, 1.25.2, 1.26.0b1, 1.26.0rc1, 1.26.0)
ERROR: No matching distribution found for numpy~=1.21.2
zain@Kholoods-MacBook-Pro scratch2python %

Latest version

  • I am running the latest version

Variable support

Support variables and variable reporters and make classes for them. Needs #7

Contributors list! :sparkles: Powered by all-contributors

Comment here to get added to the contributors list.

The comment should be similar to this:

@all-contributors add @yourself for <contributions>

For <contributions>, you will most likely use one of these: (separate with commas if there are more)

  • a11y
  • bug
  • code
  • data
  • design
  • doc
  • ideas
  • infra
  • maintenance
  • plugin
  • projectManagement
  • question
  • review
  • security
  • test
  • tool
  • translation
  • tutorial

The full list is here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.