onkey and onkeypress generated errors in pythonista.
'TurtleView' object has no attribute 'onkeypress ' 'onkey'
This code works in other python IDE environments verbatim (such as PyCharm / Replit).
window = turtle.Screen()
fred = turtle.Turtle()
for _ in range(4):
JonB last edited by
@ramorez In pythonista, turtle doesn't run via tkinter, but the pythonista UI environment. So you can't use all of the same features. You would need to add your own functionality via pythonista UI module.
@JonB hi! thank you. no idea about that so will have a look.
cvp last edited by
@ramorez try this quick and dirty script to understand that ui allows you to intercept touch and turtle do draw in another tab, at console side
import turtle import ui fred = turtle.Turtle() def draw_square(): for _ in range(4): fred.forward(100) fred.left(90) class MyView(ui.View): def __init__(self,*args, **kwargs): ui.View.__init__(self,*args,**kwargs) self.background_color = 'white' self.name = 'tap anywhere under this titlebar to start turtle' def touch_began(self, sender): draw_square() self.close() v = MyView() v.present('fullscreen')
@cvp thank you. I will check it out.