Easy Web Environment to post pupils Python Creations
Dear Colleagues, My Y6 pupils (10-11 year olds) have been creating some simple text based linear adventures using Python. Does anyone know of a way we can play their adventures online? They are not very complicated. You can see the planning here. https://sites.google.com/site/pythoncodecouk/python-adventure Also as a new person to your forum does anyone know of an easy way to search you archives just in case someone has already answered this question. Thanks in advance for any help Phil Bagge -- Primary ICT Advanced Skills Teacher HCC Teacher & IT Manager http://code-it.co.uk
http://www.skulpt.org/ or http://www.brython.info/ ? They are made on javascript - so if you don't need to save stuff serverside - might be good enough. On Wed, Jan 16, 2013 at 11:55 AM, Philip Bagge <baggiepr@gmail.com> wrote:
Dear Colleagues,
My Y6 pupils (10-11 year olds) have been creating some simple text based linear adventures using Python. Does anyone know of a way we can play their adventures online? They are not very complicated. You can see the planning here. https://sites.google.com/site/pythoncodecouk/python-adventure
Also as a new person to your forum does anyone know of an easy way to search you archives just in case someone has already answered this question.
Thanks in advance for any help
Phil Bagge
-- Primary ICT Advanced Skills Teacher HCC Teacher & IT Manager http://code-it.co.uk
_______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig
-- Jurgis Pralgauskis tel: 8-616 77613; Don't worry, be happy and make things better ;) http://galvosukykla.lt
On Fri, Jan 18, 2013 at 7:21 PM, Jurgis Pralgauskis <jurgis.pralgauskis@gmail.com> wrote:
http://www.skulpt.org/ or http://www.brython.info/ ? They are made on javascript - so if you don't need to save stuff serverside - might be good enough.
I didn't have time to comment on this earlier, but as a follow up on this Brython will allow you to directly save client side using HTML5 local storage. You can also save through an ajax call, so you could create a small write() function (in Python) to wrap an ajax call (req = ajax() and then req.open in synchronous mode and req.send) to post the data to your server, but it does require some infrastructure. Regarding the original question, about putting text adventures on the web, it's a funny thing, because that's what I've had on my mind since I heard about Brython. Initially it didn't even have print(), and to me that was a basic requirement. so I created a webprint for brython ( http://raspberry-python.blogspot.com/2012/12/brython-browser-python.html ), but then Pierre (the author) added print(). The next piece of the puzzle was the raw_input() (or in this case input() since Brython is Python 3.x ). Pierre, Andre (Roberge, fellow edu-sig member) and I went through various discussions on how this could work. In the end, I had to go back to my original thought of having input() bringing up a web browser prompt (javascript prompt) so the call would be blocking, to flow just like a Python script. To test this, I grabbed a simple python text adventure from a blog ( http://livingcode.org/entries/2008-02-22_simple-text-adventure/ ) and plugged it in the web page, with minimum change, namely to convert it to Python 3.x syntax. The purpose of getting code I didn't write to test the idea, was that I knew how to code around the limitations of a web browser (event driven vs the linear approach of a typical Python script), so if my code ran ok, it wouldn't prove the suitability of the solution. So the code from the blog ran, but it's not 100% what one would expect. You can check it out for yourselves here (it's my Brython playground, on free hosting so it's not particularly fast to answer): http://brython.heliohost.org/demos/simpleadventure.html A more proper way of doing this does require eliminating the while True: loop and replacing it with a function, and moving the input to the end of the function: http://brython.heliohost.org/demos/simpleadventure1.html Still, it is close to a solution. Francois -- www.pyptug.org - raspberry-python.blogspot.com - @f_dion
On Tue, Jan 29, 2013 at 4:43 PM, Francois Dion <francois.dion@gmail.com>wrote:
On Fri, Jan 18, 2013 at 7:21 PM, Jurgis Pralgauskis <jurgis.pralgauskis@gmail.com> wrote:
http://www.skulpt.org/ or http://www.brython.info/ ? They are made on javascript - so if you don't need to save stuff serverside - might be good enough.
Regarding the original question, about putting text adventures on the web, it's a funny thing, because that's what I've had on my mind since I heard about Brython. Initially it didn't even have print(), and to me that was a basic requirement. so I created a webprint for brython ( http://raspberry-python.blogspot.com/2012/12/brython-browser-python.html ), but then Pierre (the author) added print(). The next piece of the puzzle was the raw_input() (or in this case input() since Brython is Python 3.x ). Pierre, Andre (Roberge, fellow edu-sig member) and I went through various discussions on how this could work. In the end, I had to go back to my original thought of having input() bringing up a web browser prompt (javascript prompt) so the call would be blocking, to flow just like a Python script.
To test this, I grabbed a simple python text adventure from a blog ( http://livingcode.org/entries/2008-02-22_simple-text-adventure/ ) and plugged it in the web page, with minimum change, namely to convert it to Python 3.x syntax. The purpose of getting code I didn't write to test the idea, was that I knew how to code around the limitations of a web browser (event driven vs the linear approach of a typical Python script), so if my code ran ok, it wouldn't prove the suitability of the solution. So the code from the blog ran, but it's not 100% what one would expect. You can check it out for yourselves here (it's my Brython playground, on free hosting so it's not particularly fast to answer):
Having just tried it, I noticed a problem with it that I had not anticipated when thinking of using prompt for input. the information written in the textarea (?) needs to be scrolled up; however, the prompt prevents a user from doing so. .
A more proper way of doing this does require eliminating the while True: loop and replacing it with a function, and moving the input to the end of the function:
http://brython.heliohost.org/demos/simpleadventure1.html
This works much better. The way I would describe, without looking at the
code, would be like a state machine. The "world" is stored as an object; when the user enters a command, a single function call is issue [ "update(user_input)"] and some feedback is given. Impressive. André
Still, it is close to a solution.
Francois
-- www.pyptug.org - raspberry-python.blogspot.com - @f_dion _______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig
On Tue, Jan 29, 2013 at 4:13 PM, Andre Roberge <andre.roberge@gmail.com> wrote:
On Tue, Jan 29, 2013 at 4:43 PM, Francois Dion <francois.dion@gmail.com> wrote:
To test this, I grabbed a simple python text adventure from a blog ( http://livingcode.org/entries/2008-02-22_simple-text-adventure/ ) and plugged it in the web page, with minimum change, namely to convert it to Python 3.x syntax. The purpose of getting code I didn't write to test the idea, was that I knew how to code around the limitations of a web browser (event driven vs the linear approach of a typical Python script), so if my code ran ok, it wouldn't prove the suitability of the solution. So the code from the blog ran, but it's not 100% what one would expect. You can check it out for yourselves here (it's my Brython playground, on free hosting so it's not particularly fast to answer):
Having just tried it, I noticed a problem with it that I had not anticipated when thinking of using prompt for input. the information written in the textarea (?) needs to be scrolled up; however, the prompt prevents a user from doing so.
Easily solved using: cs = doc["console"] cs.scrollTop = cs.scrollHeight - cs.clientHeight I did a quick live edit on the file, if you refresh, should work. The text area will scroll as output is printed. So once that is integrated to the console output class, and combining that with the separate file for python, You could reuse the same html / brython template for all the various adventures that students write. If anybody is interested in that, I'll post the template.
A more proper way of doing this does require eliminating the while True: loop and replacing it with a function, and moving the input to the end of the function:
This works much better. The way I would describe, without looking at the code, would be like a state machine. The "world" is stored as an object; when the user enters a command, a single function call is issue [ "update(user_input)"] and some feedback is given. Impressive.
André
But it uses an onchange event. Although Brython introduces events as native to "Python", I'm still hoping to find an even better solution. Or at least wrap the code automatically. Francois -- www.pyptug.org - raspberry-python.blogspot.com - @f_dion
By the way, I stumbled upon PythonJS -- which proposes some nice tools: Flowchart from code generation realtime http://pyppet.blogspot.com/2014/02/code-visualization.html - Ability to export to Android (which attracs youth's attention ;) http://pyppet.blogspot.com/2014/02/pypubjs-exports-to-android.html On Tue, Jan 29, 2013 at 11:13 PM, Andre Roberge <andre.roberge@gmail.com>wrote:
On Tue, Jan 29, 2013 at 4:43 PM, Francois Dion <francois.dion@gmail.com>wrote:
On Fri, Jan 18, 2013 at 7:21 PM, Jurgis Pralgauskis <jurgis.pralgauskis@gmail.com> wrote:
http://www.skulpt.org/ or http://www.brython.info/ ? They are made on javascript - so if you don't need to save stuff serverside - might be good enough.
Regarding the original question, about putting text adventures on the web, it's a funny thing, because that's what I've had on my mind since I heard about Brython. Initially it didn't even have print(), and to me that was a basic requirement. so I created a webprint for brython ( http://raspberry-python.blogspot.com/2012/12/brython-browser-python.html ), but then Pierre (the author) added print(). The next piece of the puzzle was the raw_input() (or in this case input() since Brython is Python 3.x ). Pierre, Andre (Roberge, fellow edu-sig member) and I went through various discussions on how this could work. In the end, I had to go back to my original thought of having input() bringing up a web browser prompt (javascript prompt) so the call would be blocking, to flow just like a Python script.
To test this, I grabbed a simple python text adventure from a blog ( http://livingcode.org/entries/2008-02-22_simple-text-adventure/ ) and plugged it in the web page, with minimum change, namely to convert it to Python 3.x syntax. The purpose of getting code I didn't write to test the idea, was that I knew how to code around the limitations of a web browser (event driven vs the linear approach of a typical Python script), so if my code ran ok, it wouldn't prove the suitability of the solution. So the code from the blog ran, but it's not 100% what one would expect. You can check it out for yourselves here (it's my Brython playground, on free hosting so it's not particularly fast to answer):
Having just tried it, I noticed a problem with it that I had not anticipated when thinking of using prompt for input. the information written in the textarea (?) needs to be scrolled up; however, the prompt prevents a user from doing so. .
A more proper way of doing this does require eliminating the while True: loop and replacing it with a function, and moving the input to the end of the function:
http://brython.heliohost.org/demos/simpleadventure1.html
This works much better. The way I would describe, without looking at the
code, would be like a state machine. The "world" is stored as an object; when the user enters a command, a single function call is issue [ "update(user_input)"] and some feedback is given. Impressive.
André
Still, it is close to a solution.
Francois
-- www.pyptug.org - raspberry-python.blogspot.com - @f_dion _______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig
_______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig
-- Jurgis Pralgauskis tel: 8-616 77613; Don't worry, be happy and make things better ;) http://galvosukykla.lt
participants (4)
-
Andre Roberge
-
Francois Dion
-
Jurgis Pralgauskis
-
Philip Bagge