Python Forum
[Turtle] numinput and textinput do not work - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [Turtle] numinput and textinput do not work (/thread-26335.html)



[Turtle] numinput and textinput do not work - fgarciamoran - Apr-28-2020

import random
import time
import sys
from turtle import *
from turtle import textinput
setup()
t1= Turtle()
t1.left(180)
t1.penup()
t1.forward(200)



#Create the list of possible shots

lista = [ 'push drive', 'push back', 'long push drive', 'long push back', 'top spin drive', 'top spin back', 'open up drive', 'open up back' , 'flip drive', 'flip back']

#input data

#count = int(input("How many random numbers do you want to generate? "))
#segundos = int( input ("segundos de espera?: "))
count=int(t1.textinput("Repeticiones", "Repeticiones: "))
Segundos=int(t1.textinput("Intervalo", "Segundos: "))


t1.write("COMENZAMOS.....", font=("arial",40, "normal"))
time.sleep(5)
#Iterate

rmax = len (lista) - 1
for r in range(count):
time.sleep(segundos)
num=random.randint(1, rmax)
t1.clear()
t1.write(lista [num].upper(), font=("arial",40, "normal"))

Error message

Traceback (most recent call last):
File "/Users/fgm/Downloads/Random Numbers.py", line 16, in <module>
count=int(t1.textinput("Repeticiones", "Repeticiones: "))
AttributeError: 'Turtle' object has no attribute 'textinput'

Running dir([turtle]) gives all the methods and they are not on the list


RE: [Turtle] numinput and textinput do not work - deanhystad - Apr-28-2020

As the message says, textinput is not an attribute of Turtle. It is an attribute of Screen.

count= int(Screen().textinput("Repeticiones", "Repeticiones: "))

This changed with Python 3