turtle example not working

74 views
Skip to first unread message

billy.earney

unread,
Jan 29, 2012, 7:23:12 PM1/29/12
to Skulpt
I've pulled the most recent changes to skulpt and tried to run the
turtletest example, as well as the unittests. Both don't seem to
work.

I've done a ./m browser to generate the browser-test.js file, but in
firefox and chrome, I get an error dealing with window.addevent not
being a valid function. So I changed this to:

window.onload=function() {

}

but I still get errors about goog.asserts not found..

I'd like to get this working so that I can wrap a lot of the closure
codes (and other javascript libraries), so we can translate a lot of
javascript examples (such as http://teebes.com/blog/19/playing-with-googles-closure-js-library),
and people can see just how cool (and easy) python is.

The window.onload change to the m script has been pushed to the
billyearney-skulpt clone. I've also added an example in which someone
can execute python code from a web page using <script type="text/
python">

Sphaerica

unread,
Jan 29, 2012, 7:29:02 PM1/29/12
to Skulpt
I had trouble, too. Let me look through my notes and see how I fixed
it. It was pretty simple.

On Jan 29, 7:23 pm, "billy.earney" <billy.ear...@gmail.com> wrote:
> I've pulled the most recent changes to skulpt and tried to run the
> turtletest example, as well as the unittests.  Both don't seem to
> work.
>
> I've done a ./m browser  to generate the browser-test.js file, but in
> firefox and chrome, I get an error dealing with window.addevent not
> being a valid function.  So I changed this to:
>
> window.onload=function() {
>
> }
>
> but I still get errors about goog.asserts not found..
>
> I'd like to get this working so that I can wrap a lot of the closure
> codes (and other javascript libraries), so we can translate a lot of
> javascript examples  (such ashttp://teebes.com/blog/19/playing-with-googles-closure-js-library),

Sphaerica

unread,
Jan 29, 2012, 7:39:04 PM1/29/12
to Skulpt
Try moving turtletest.html into the doc directory, and change the
following two lines (to direct it into static for skuplt.js and
buildin.js) and add the third line to pull in jquery:

<script src="static/skulpt.js" type="text/javascript"></script>
<script src="static/builtin.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/
jquery.min.js" type="text/javascript" ></script>

Sphaerica

unread,
Jan 29, 2012, 7:40:06 PM1/29/12
to Skulpt
And change the onload back to the way it was. The missing
window.addevent thing is handled by jQuery (which was missing).

-- Bob

On Jan 29, 7:29 pm, Sphaerica <blacat...@comcast.net> wrote:

billy.earney

unread,
Jan 29, 2012, 9:16:29 PM1/29/12
to Skulpt
Thanks.. that did the trick!

Brad Miller

unread,
Feb 4, 2012, 9:22:06 AM2/4/12
to sku...@googlegroups.com
Hi Guys,

I'm curious about what kind of error you got when you tried to use turtletest.html.  I just clone a clean copy of the repo and it worked right out of the box for me.

Brad

-- 
Brad Miller

Sphaerica

unread,
Feb 4, 2012, 10:17:43 AM2/4/12
to Skulpt
The only problem I found was that doc/static/turtletest.html needed

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/
jquery.min.js" type="text/javascript" >

to pull in jquery. Without that it comes up with a "ReferenceError: $
undefined".

[I also moved it up a directory, and changed the builtins.js and
skulpt.js javascript imports to properly reference static, but all
that wasn't necessary.]

I have no idea how you could be getting it to work without the jquery
code, but I can't find a reference to it on the page, so it must
actually be referenced in the turtle builtin!


On Feb 4, 9:22 am, Brad Miller <bonel...@gmail.com> wrote:
> Hi Guys,
>
> I'm curious about what kind of error you got when you tried to use turtletest.html.  I just clone a clean copy of the repo and it worked right out of the box for me.
>
> Brad
>
> --
> Brad Miller
>
>
>
>
>
>
>
> On Sunday, January 29, 2012 at 6:39 PM, Sphaerica wrote:
> > Try moving turtletest.html into the doc directory, and change the
> > following two lines (to direct it into static for skuplt.js and
> > buildin.js) and add the third line to pull in jquery:
>
> > <script src="static/skulpt.js" type="text/javascript"></script>
> > <script src="static/builtin.js" type="text/javascript"></script>
> > <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/
> > jquery.min.js" type="text/javascript" ></script>
>
> > On Jan 29, 7:29 pm, Sphaerica <blacat...@comcast.net (http://comcast.net)> wrote:
> > > I had trouble, too.  Let me look through my notes and see how I fixed
> > > it.  It was pretty simple.
>

Sphaerica

unread,
Feb 4, 2012, 10:25:01 AM2/4/12
to Skulpt
This line within turtle.js is a jquery call:

$(this.canvas).fadeIn();

You might replace it with a more direct
this.canvas.display='block' (although I'm not certain that works... it
may require opacity changes), but I think the reason for this may be a
bug that I also encountered, where some browsers (like Firefox) do not
properly refresh the canvas, and the hack is to change something to
get it to redraw (for instance, change opacity to 0.9, then back to
1.0), except it actually has to do the redraw (if you change opacity
to 0.9 and then right back to 1.0, the browser knows nothing really
changed and doesn't bother with the redraw), and one way to do that is
to use the jquery animation to make sure it happens.

Alternately, you'd need something like:

this.canvas.style.opacity = 0.9
setTimer(1,'this.canvas.style.opacity=1.0')

This forces the redraw on the first, and immediately does the second.

But... jquery also takes care of all of the variations on opacity
needed for different browers.

Me, I'm fine with the requirement that turtle needs jquery, because I
use it anyway for other stuff.

Brad Miller

unread,
Feb 4, 2012, 10:26:44 AM2/4/12
to sku...@googlegroups.com
It works for me because the version that I just cloned has the required link to jquery.

Brad

-- 
Brad Miller

Billy Earney

unread,
Feb 7, 2012, 8:54:11 AM2/7/12
to sku...@googlegroups.com
Brad,

For some reason, turtletest.html didn't have a link to jquery, when I pulled a copy.  Maybe I didn't pull it correctly (which is very likely), but once I added the link to jquery.  I worked fine.
Reply all
Reply to author
Forward
0 new messages