问题
import turtle
screen = turtle.Screen()
global answer
answer = screen.textinput("Welcome to the game", "What's your name?")
Here is a screenshot of what comes up. I can't seem to find anything describing a way to edit the box at all. I'm also looking for ways to edit the overall appearance of the box, as it's intended purpose is for dialogue in the game I'm working on.
回答1:
The window with the input is made with tkinter. You can make your own function that makes it.
Here is a sample of your code:
import turtle
from tkinter import *
screen = turtle.Screen()
global answer
def textinput(title, question):
message = Tk()
message.title(str(title))
message.geometry("350x200")
l = Label(message, text = str(question))
l.pack()#you can place it wherever you want
e = Entry(message)#customize all you want
e.pack()
def submit(event = "<Return>"):
global answer
answer = e.get()
message.destroy()
b = Button(message, text = "submit", command = submit)
b.pack()
b.bind_all("<Return>", submit)
message.mainloop()
answer = textinput("Welcome to the game", "What's your name?")
You can customize this window in any way. Like changing the button color, entry color, position, etc.
Hope this helps!!
来源:https://stackoverflow.com/questions/61175289/is-there-a-way-to-change-the-location-of-a-text-box-in-turtle-it-always-shows-u