Python Forum
[Turtle] numinput and textinput do not work
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Turtle] numinput and textinput do not work
#1
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
Reply
#2
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to read text in kivy textinput or Label jadel440 1 5,182 Dec-29-2020, 10:47 AM
Last Post: joe_momma
  Turtle / turtle question DPaul 2 2,129 Oct-04-2020, 09:23 AM
Last Post: DPaul
  [Kivy] How to clear a TextInput field gio123 2 11,784 Mar-12-2018, 05:11 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020