Skip to main content

Interface Python with MIT Scratch

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

This package enables communication between Python and Scratch using the remote sensors feature of Scratch.

Remember to enable remote sensors in Scratch! To do this:

  1. Go to Sensing

  2. Right-click on a ‘sensor value’

  3. Select ‘enable remote sensor connections’

Example usage:

import scratch
s = scratch.Scratch()

# to make a broadcast to scratch
s.broadcast("from python")

# to receive an update from scratch
message = s.receive()
# blocks until an update is received
# message returned as  {'broadcast': [], 'sensor-update': {'scratchvar': '64'}}
#                  or  {'broadcast': ['from scratch'], 'sensor-update': {}}
# where scratchvar is the name of a variable in scratch
# and 'from scratch' is the name of a scratch broadcast

# send sensor updates to scratch
data = {}
data['pyvar'] = 123
for data['pycounter'] in range(60):
    s.sensorupdate(data)

0.0.1a

Initial version

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scratch-0.0.1a.tar.gz (8.7 kB view details)

Uploaded Source

File details

Details for the file scratch-0.0.1a.tar.gz.

File metadata

  • Download URL: scratch-0.0.1a.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for scratch-0.0.1a.tar.gz
Algorithm Hash digest
SHA256 298d8474e6a02d625e3b077bdd19f79023b986767232294eb268bad784382730
MD5 053bf71c4050dfd6f69f5a316519f797
BLAKE2b-256 1782700506db84d2c9defb1ed6297a1be5af8c09e1a87b91508a4e0b085c4bcb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page