-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Hello,
Thanks again for working on this library! We are considering using turtle graphics as a supplement to traditional text-based I/O instruction. We don't need to base an entire course around turtle graphics in a web browser, but we're thinking that mixing in some graphical turtle examples - alongside traditional console I/O - for things like sequencing, decision-making, and loops will be fun for the students.
After experimenting with turtle-pyscript for a few days, I wanted to share some overall goals we'd have as potential users who are trying to teach beginning students introductory Python. The big advantage to using an online, web-based solution like this is that you don't have to install Python on a local device, which is often not possible in a school setting (especially with Chromebooks). However, we want to be careful to avoid teaching - wherever possible - syntax, patterns, or concepts just to make the online coding environment work and that would not be relevant or portable to a standalone Python script running on a desktop environment. We want our students to be able to code outside of our online environment after the course ends.
While I am sure it's not realistic, ideally, any standard Python turtle code that would run on a desktop and produce a specific effect would work exactly the same way in an online emulator or vice-versa, subject naturally to certain complex features not being supported online (either by turtle-pyscript or pyscript itself). Put another way, having a reduced feature set online is acceptable, while having to code things differently online vs. desktop is undesirable. Here are some things we encountered:
-
Having to "import turtleps" instead of "import turtle" (though "import turtleps as turtle" is a reasonable workaround)
-
Support for multiple Python source files (e.g. one main file and supporting classes or functions in other files) in the online environment - not sure if this is possible?
-
Interactive code (e.g. detecting and processing mouse and keyboard clicks) seems to be very different online vs. desktop. Possibly this is still a work-in progress, but things like turtle.onclick() are not yet supported, so based on the rocket example, we have to import the document library and engage with HTML/JavaScript-related concepts like this...
def key_down(event):
keys_pressed.add(event.key)
def key_up(event):
if event.key in keys_pressed:
keys_pressed.remove(event.key)
main logic
keys_pressed = set()
document.onkeydown = key_down
document.onkeyup = key_up
while True:
if "ArrowUp" in keys_pressed:
turtle.forward(4)
if "ArrowLeft" in keys_pressed:
turtle.left(5)
...whereas in desktop turtle we'd do this instead:
def arrow_up():
turtle.forward(4)
def arrow_left():
turtle.left(5)
def arrow_right():
turtle.right(5)
screen.onkeypress(arrow_up,"Up")
screen.onkeypress(arrow_left,"Left")
screen.onkeypress(arrow_right,"Right")
screen.listen()
screen.mainloop()
-
As beginners, our students will have no concept of threading and concurrency, just trying to learn basic sequencing, decision making, and loops. We would avoid all types of "async" and "await" decorations completely if possible, as they wouldn't be understood and wouldn't port into a desktop python script. I respect your architectural direction is to lean heavily on these concepts as they are appropriate for the web browser, but I wouldn't teach them to beginning students learning Python on a desktop.
-
Timing differences - and I know this will run into hard browser limitations - but things can be drawn at certain speeds in desktop turtle, while the same code run online produces instant results.
-
Lastly, I'll mention that we would want the ability to redirect all console I/O to a designated panel or <textarea> so the student could see text output (including syntax errors, exceptions, and print() output). Currently, those outputs go to console.log(), though perhaps there is a way to redirect that I didn't find.
Thanks for your consideration!