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

#176 2012-09-30 07:34:08

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: kurt — Scratch file format Python library

you can reproduce it easily with

Code:

file.stage = kurt.Stage()
file.stage.backgrounds[0].get_image()

Offline

 

#177 2012-09-30 07:47:55

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

Re: kurt — Scratch file format Python library

Well, it seems to work now, anyhow  smile

Pushed v1.4.2 to GitHub/PyPI.

Update using:

    sudo pip install --upgrade kurt

Let me know if it works for you!


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

Offline

 

#178 2012-09-30 07:50:44

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

Re: kurt — Scratch file format Python library

I also added a little GUI wrapper for the compiler, which you can try out using:

    kurtgui.py

http://imgur.com/FftfY.png

(Untested on Windows yet, just FYI)

Last edited by blob8108 (2012-09-30 07:52:48)


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

Offline

 

#179 2012-09-30 07:57:22

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: kurt — Scratch file format Python library

works great  smile

how do you get x&y positions? something with bounds?

tkinter. bah.

Last edited by roijac (2012-09-30 08:02:05)

Offline

 

#180 2012-09-30 08:38:13

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

Re: kurt — Scratch file format Python library

roijac wrote:

works great  smile

Awesome!  smile

how do you get x&y positions? something with bounds?

Yeah, I think so -- unless you can find another, more obvious field on BaseMorph. From memory, bounds is:
    x, y, width, height

tkinter. bah.

tongue  Well, it does come with Python...


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

Offline

 

#181 2012-09-30 09:32:30

LiquidMetal
Scratcher
Registered: 2011-06-15
Posts: 500+

Re: kurt — Scratch file format Python library

blob8108 wrote:

LiquidMetal wrote:

Any chance you could set up a PPA for this?  It would make it much simpler for Ubuntu.

Honestly, Ubuntu already has the easiest install procedure:

    sudo apt-get install python-pip python-imaging
    sudo pip install kurt

...and you're done!

vs windows, which takes about six steps and involves editing environment variables...  tongue

So I probably won't make that, no. Thanks for suggesting it, though!  smile

EDIT: I have made a GUI, though, so I've done half of what you asked! Could you please try it out, and let me know what you think? Thanks!

Will that for Ubuntu update it automatically?  Or will I need to install it again? I don't have administrator privileges, so each time i need to get an administrator to do it.  Also, I'll be able to run it without administrator privileges, right?

You need to make a windows NSIS installer that checks for each dependency and installs if not there (and you can't browse to it).  You probably could make one that wouldn't require to many changes if you wanted to repackage it with a new version of kurt. (I use windows, mainly) P.S. I might attempt to do this for you but don't count on my being successful  tongue  (this is not a binding promise)

I'll try to get it installed on Ubuntu Tuesday night or Wednesday, and I'll try it out then.

Last edited by LiquidMetal (2012-09-30 09:34:12)

Offline

 

#182 2012-09-30 09:42:22

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

Re: kurt — Scratch file format Python library

LiquidMetal wrote:

blob8108 wrote:

LiquidMetal wrote:

Any chance you could set up a PPA for this?  It would make it much simpler for Ubuntu.

Honestly, Ubuntu already has the easiest install procedure:

    sudo apt-get install python-pip python-imaging
    sudo pip install kurt

...and you're done!

vs windows, which takes about six steps and involves editing environment variables...  tongue

So I probably won't make that, no. Thanks for suggesting it, though!  smile

EDIT: I have made a GUI, though, so I've done half of what you asked! Could you please try it out, and let me know what you think? Thanks!

Will that for Ubuntu update it automatically?  Or will I need to install it again?

You can update it by simply using:

    sudo pip install --upgrade kurt

I don't have administrator privileges, so each time i need to get an administrator to do it.  Also, I'll be able to run it without administrator privileges, right?

Yup!

You need to make a windows NSIS installer that checks for each dependency and installs if not there (and you can't browse to it).  You probably could make one that wouldn't require to many changes if you wanted to repackage it with a new version of kurt. (I use windows, mainly) P.S. I might attempt to do this for you but don't count on my being successful  tongue

If you say so. The hard part is setting up pip so you can install Python packages. I'm not sure about the licenses for redistributing everything else (eg. the Python Imaging Library). I could perhaps make an installer that included kurt and setup the environment vars correctly; you'd still have to run Python/PIL installers yourself, I think. If you could make one, that'd be awesome!  smile

I'll try to get it installed on Ubuntu Tuesday night or Wednesday, and I'll try it out then.

Let me know how it goes  smile


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

Offline

 

#183 2012-09-30 09:42:58

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: kurt — Scratch file format Python library

blob8108 wrote:

how do you get x&y positions? something with bounds?

Yeah, I think so -- unless you can find another, more obvious field on BaseMorph. From memory, bounds is:
    x, y, width, height

[removed by moderator]

the real solution is

Code:

x = (sprite.bounds.value[0] + sprite.costume.rotationCenter.value[0] - 240,
y = (sprite.bounds.value[1] * -1) - sprite.costume.rotationCenter.value[1] + 180)

now THAT was long debugging  tongue

Last edited by Paddle2See (2012-10-02 20:48:35)

Offline

 

#184 2012-09-30 09:43:54

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

Re: kurt — Scratch file format Python library

roijac wrote:

blob8108 wrote:

how do you get x&y positions? something with bounds?

Yeah, I think so -- unless you can find another, more obvious field on BaseMorph. From memory, bounds is:
    x, y, width, height

[removed by moderator]

the real solution is

Code:

(sprite.bounds.value[0] + sprite.costume.rotationCenter.value[0] - 240,
(sprite.bounds.value[1] * -1) - sprite.costume.rotationCenter.value[1] + 180)

now THAT was long debugging  tongue

Oh! You wanted Scratch-style co-ordinates... that didn't even occur to me  tongue

I might add those as Kurt properties, if you don't mind  smile

Last edited by Paddle2See (2012-10-02 20:48:48)


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

Offline

 

#185 2012-09-30 09:49:52

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: kurt — Scratch file format Python library

blob8108 wrote:

Oh! You wanted Scratch-style co-ordinates... that didn't even occur to me  tongue

I might add those as Kurt properties, if you don't mind  smile

no problem  smile

Offline

 

#186 2012-09-30 09:51:50

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

Re: kurt — Scratch file format Python library

roijac wrote:

Code:

x = (sprite.bounds.value[0] + sprite.costume.rotationCenter.value[0] - 240,
y = (sprite.bounds.value[1] * -1) - sprite.costume.rotationCenter.value[1] + 180)

Isn't that better written as:

Code:

(x, y, w, h) = sprite.bounds
(rx, ry) = sprite.costume.rotationCenter
x = x + rx - 240
y = 180 - y - ry

smile


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

Offline

 

#187 2012-10-02 22:56:54

LiquidMetal
Scratcher
Registered: 2011-06-15
Posts: 500+

Re: kurt — Scratch file format Python library

If a background or sprite has text in it, will kurt save that? It looks to me like it just saved the background as an image.

Offline

 

#188 2012-10-02 23:43:52

LiquidMetal
Scratcher
Registered: 2011-06-15
Posts: 500+

Re: kurt — Scratch file format Python library

I suppose the installer(s) would be made with NSIS.  It would need to...

Check for Python 2.6 or 2.7 in directory C:/Python26 or 27
If no python found,
give options to browse or
download and
install* python 2.7.
Save the path to the python directory in a variable ($String1?).

Check for setuptools in the default path (which is what? is it based on the python path?)
if not found, give option to
browse or
download and
install* the appropriate version**.
Save the path to the python directory in a variable ($String2?)

Add $String1 and $String2 to your PATH (Path to what?) (I don't really understand the instructions here, but however NSIS does it would be different anyway.)

Check for PIL.
If not found, give options to
browse or
download and
install* the appropriate version**.

run "easy_install kurt" in a shell and wait until done.

Trouble is, I don't really know how to do anything with NSIS.

* If the installers are simply downloaded and run including the option to change the default install location, then how will the NSIS installer know where it is put? Maybe it will know somehow, or maybe a files only install with as little user input as possible would be better?
** 32 bit, 64 bit options, or just go with 32? Or I make separate installers for that?

Last edited by LiquidMetal (2012-10-03 00:18:41)

Offline

 

#189 2012-10-03 02:05:51

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: kurt — Scratch file format Python library

LiquidMetal wrote:

I suppose the installer(s) would be made with NSIS.  It would need to...

Check for Python 2.6 or 2.7 in directory C:/Python26 or 27
If no python found,
give options to browse or
download and
install* python 2.7.
Save the path to the python directory in a variable ($String1?).

Check for setuptools in the default path (which is what? is it based on the python path?)
if not found, give option to
browse or
download and
install* the appropriate version**.
Save the path to the python directory in a variable ($String2?)

Add $String1 and $String2 to your PATH (Path to what?) (I don't really understand the instructions here, but however NSIS does it would be different anyway.)

Check for PIL.
If not found, give options to
browse or
download and
install* the appropriate version**.

run "easy_install kurt" in a shell and wait until done.

Trouble is, I don't really know how to do anything with NSIS.

* If the installers are simply downloaded and run including the option to change the default install location, then how will the NSIS installer know where it is put? Maybe it will know somehow, or maybe a files only install with as little user input as possible would be better?
** 32 bit, 64 bit options, or just go with 32? Or I make separate installers for that?

best would be to just include the installers with it and run them if needed

Offline

 

#190 2012-10-03 02:30:32

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

Re: kurt — Scratch file format Python library

LiquidMetal wrote:

If a background or sprite has text in it, will kurt save that? It looks to me like it just saved the background as an image.

Yeah, that's exactly what it does. What would you rather have it do?


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

Offline

 

#191 2012-10-03 08:31:21

LiquidMetal
Scratcher
Registered: 2011-06-15
Posts: 500+

Re: kurt — Scratch file format Python library

roijac wrote:

best would be to just include the installers with it and run them if needed

That would be the easiest method, but is there a way to make one of those installers return the path that it installed in when done?  Would it be problematic if any of the requirements were installed in a separate location by the included installer?  Or after installation, maybe the program should check for the installation, and if not found, ask to browse/install again?

Can you explain the PATH thing?

blob8108 wrote:

LiquidMetal wrote:

If a background or sprite has text in it, will kurt save that? It looks to me like it just saved the background as an image.

Yeah, that's exactly what it does. What would you rather have it do?

If the sprite has text that can be edited from within Scratch, then kurt should save the position, font, and size of that text separately from the image.  That way, the text could still be editable when it re-compiles the project.

Last edited by LiquidMetal (2012-10-03 08:36:36)

Offline

 

#192 2012-10-03 12:00:16

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

Re: kurt — Scratch file format Python library

LiquidMetal wrote:

blob8108 wrote:

LiquidMetal wrote:

If a background or sprite has text in it, will kurt save that? It looks to me like it just saved the background as an image.

Yeah, that's exactly what it does. What would you rather have it do?

If the sprite has text that can be edited from within Scratch, then kurt should save the position, font, and size of that text separately from the image.  That way, the text could still be editable when it re-compiles the project.

I thought about doing that.  hmm  I decided that having the image with the text was more useful, as re-creating the exact font/size/position in an external editor can be quite difficult.

I might add an option to the decompiler to specify the behaviour you'd prefer. Ideally it'd do both: but that becomes quite hard to resolve. How can Kurt tell which one you've edited? And if you edit both, which one should it prefer? Hopefully you see the issue...

Last edited by blob8108 (2012-10-03 12:00:32)


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

Offline

 

#193 2012-10-03 12:47:10

LiquidMetal
Scratcher
Registered: 2011-06-15
Posts: 500+

Re: kurt — Scratch file format Python library

If you save the background as an image, and the text in the sprite/background costume as a text file, then editing either would not effect the other.

Offline

 

#194 2012-10-03 13:21:58

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

Re: kurt — Scratch file format Python library

LiquidMetal wrote:

If you save the background as an image, and the text in the sprite/background costume as a text file, then editing either would not effect the other.

Yes, of course. But the point is I want to have the existing behaviour at the same time, so it saves two copies of the image: one with and one without the text.


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

Offline

 

#195 2012-10-03 15:49:57

LiquidMetal
Scratcher
Registered: 2011-06-15
Posts: 500+

Re: kurt — Scratch file format Python library

But that would just create extra problems, as you mentioned.  The only good way to do that would be to manage it through an even more complex gui.

Offline

 

#196 2012-10-03 16:13:22

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

Re: kurt — Scratch file format Python library

LiquidMetal wrote:

But that would just create extra problems, as you mentioned.  The only good way to do that would be to manage it through an even more complex gui.

...this is why I chose to just use the images with text  tongue  I'll add an option to the decompiler, I think.


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

Offline

 

#197 2012-10-05 04:22:46

Gravitation
New Scratcher
Registered: 2012-09-26
Posts: 500+

Re: kurt — Scratch file format Python library

Hey blob8108, when I try to install using option 2 I get "ImportError: No module named setuptools". Is it because I'm using cmd?  tongue

Offline

 

#198 2012-10-05 06:50:37

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

Re: kurt — Scratch file format Python library

Are you using Windows? It's a little tricky... Try installing setuptools  smile  I can give more detailed instructions if you want!


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

Offline

 

#199 2012-10-05 09:40:48

Gravitation
New Scratcher
Registered: 2012-09-26
Posts: 500+

Re: kurt — Scratch file format Python library

blob8108 wrote:

Are you using Windows? It's a little tricky... Try installing setuptools  smile  I can give more detailed instructions if you want!

Wow *brainfart* I never had setuptools installed. XD I just installed it, I'll give it another go.  smile

Offline

 

#200 2012-10-15 05:28:55

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: kurt — Scratch file format Python library

why do I get Containers on some vars when opening a project in kurt? I got Container({'length': 4, 'data': [106, 134, 95, 169]}) instead of 2841609834 and Container({'length': 5, 'data': [212, 248, 93, 150, 2]}) instead of 11112675540  hmm
maybe some precision number saving?

Offline

 

Board footer