This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-05-01 00:19:33

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Scratra ~ a framework for Python to Scratch

scratra
python-scratch is no longer a pain
scratra.tk

Scratra is a framework, inspired by Sinatra, that makes connecting python with Scratch super simple. After you've downloaded(right click, save as...) it, you write this:

Code:

from scratra import *

@broadcast('hi')
def hi(scratch):
    print 'Hello, world!'

run()

Enable remote sensor connections, run, broadcast 'hi', and ... BAM!

View the nearly finished help resource.

http://i.imgur.com/V5Ohz.png

Use this thread for discussions, ideas, suggestions, etc. Anything about it.  big_smile  I'm excited to hear your thoughts, sentiments, and opinions.

Last edited by Greatdane (2012-05-04 22:27:03)


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#2 2012-05-01 02:09:21

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Scratra ~ a framework for Python to Scratch

Oooh, I like the use of decorators... That's very clever  big_smile

Presumably it supports messages with multiple values, and everything? I still can't get Construct to parse them properly...  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#3 2012-05-01 10:55:42

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: Scratra ~ a framework for Python to Scratch

blob8108 wrote:

Oooh, I like the use of decorators... That's very clever  big_smile

Presumably it supports messages with multiple values, and everything? I still can't get Construct to parse them properly...  tongue

Indeed it does..  big_smile
I take a substring of the message starting at 4(removing the first four unecessary chars) then .split(), then if the first item of the list is 'sensor-update', parse the other things. You can check it on github.


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#4 2012-05-01 11:17:40

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Scratra ~ a framework for Python to Scratch

Greatdane wrote:

blob8108 wrote:

Oooh, I like the use of decorators... That's very clever  big_smile

Presumably it supports messages with multiple values, and everything? I still can't get Construct to parse them properly...  tongue

Indeed it does..  big_smile
I take a substring of the message starting at 4(removing the first four unecessary chars) then .split(), then if the first item of the list is 'sensor-update', parse the other things. You can check it on github.

What if the message is split up into multiple packets, such that you need multiple calls to socket.recv() to get it all?

Although I suppose that's unlikely to happen, given it's a local connection on the same machine...


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#5 2012-05-01 14:11:00

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Scratra ~ a framework for Python to Scratch

Wow, this sounds really awesome!  smile


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#6 2012-05-01 18:14:18

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: Scratra ~ a framework for Python to Scratch

blob8108 wrote:

Greatdane wrote:

blob8108 wrote:

Oooh, I like the use of decorators... That's very clever  big_smile

Presumably it supports messages with multiple values, and everything? I still can't get Construct to parse them properly...  tongue

Indeed it does..  big_smile
I take a substring of the message starting at 4(removing the first four unecessary chars) then .split(), then if the first item of the list is 'sensor-update', parse the other things. You can check it on github.

What if the message is split up into multiple packets, such that you need multiple calls to socket.recv() to get it all?

Although I suppose that's unlikely to happen, given it's a local connection on the same machine...

I'm not sure the message is split up into multiple packets very often, as that only happens when it's too long(occurring when multiple sensor updates happen at one time, very rarely). It's not too much of a problem to worry about.


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#7 2012-05-04 01:14:36

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

Re: Scratra ~ a framework for Python to Scratch

Sounds cool!  big_smile


I don't know why you say goodbye, I say hello!  big_smile

Offline

 

#8 2012-05-12 08:36:34

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: Scratra ~ a framework for Python to Scratch

Just to ask, can you broadcast from Scratra to Scratch?


I'm back.
Maybe.

Offline

 

#9 2012-05-12 15:41:27

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: Scratra ~ a framework for Python to Scratch

DigiTechs wrote:

Just to ask, can you broadcast from Scratra to Scratch?

Yeah, but my documentation was somehow deleted, and I don't want to write it again. In your function, do

Code:

def myFunc(scratch):
     scratch.broadcast('message')

The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#10 2012-05-14 16:26:35

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: Scratra ~ a framework for Python to Scratch

Greatdane wrote:

DigiTechs wrote:

Just to ask, can you broadcast from Scratra to Scratch?

Yeah, but my documentation was somehow deleted, and I don't want to write it again. In your function, do

Code:

def myFunc(scratch):
     scratch.broadcast('message')

Thanks.


I'm back.
Maybe.

Offline

 

#11 2012-06-22 03:53:29

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Scratra ~ a framework for Python to Scratch

scratra.tk: "This website was set to be removed for inactivity by www.000webhost.com. If you own this website, click here to protect it."

Just thought you should know...


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

Board footer