与mit scratch 1.3+接口的python(不是2.x)

scratch的Python项目详细描述


这个包支持python和scratch 1.3+之间的通信(不是2.x) 使用远程传感器的scratch功能。

记住要启用远程传感器!为此:

  1. 转到传感
  2. 右键单击“传感器值”
  3. 选择“启用遥感器连接”

示例用法:

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

初始版本

1.0.0

首次发布-模块从0.0.1a保持不变

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
用Java学习Eclipse可视化编辑器Swing   eclipse如何找到运行Java程序所需的时间?   JAVA用于在Tomcat 8上运行Jena API的lang.UnsupportedClassVersionError   java在Main中调用字符串方法   javascript“子进程”。exec无法运行Java函数   java如何使用Gmail API获取电子邮件正文内容   java为什么客户端看不到服务器发送的第一条消息?   java无法在安卓 WebView中滚动到顶部   从服务器运行web服务时,java代码中的日期为空   从子任务返回后执行后台任务时发生java错误   java无法一致地处理弹出窗口   java(Android)通过蓝牙向µ控制器发送字节   java无法在emulator中启动AVD?安卓工作室   Android Java应用程序正在冻结,没有返回错误消息   java如何使用TestNg记录测试历史?