Python3 turtle how to wait until keypress
Question:
I have a simple game written in Python3 turtle
When game finished I want to show message ‘Continue? (y/n)’ and wait until user press a button on the keyboard. Any ideas how can implement a wait feature?
Answers:
Check out the textinput
method:
def textinput(self, title, prompt):
"""Pop up a dialog window for input of a string.
Arguments: title is the title of the dialog window,
prompt is a text mostly describing what information to input.
Return the string input
If the dialog is canceled, return None.
Example (for a TurtleScreen instance named screen):
>>> screen.textinput("NIM", "Name of first player:")
"""
return simpledialog.askstring(title, prompt)
I have a simple game written in Python3 turtle
When game finished I want to show message ‘Continue? (y/n)’ and wait until user press a button on the keyboard. Any ideas how can implement a wait feature?
Check out the textinput
method:
def textinput(self, title, prompt):
"""Pop up a dialog window for input of a string.
Arguments: title is the title of the dialog window,
prompt is a text mostly describing what information to input.
Return the string input
If the dialog is canceled, return None.
Example (for a TurtleScreen instance named screen):
>>> screen.textinput("NIM", "Name of first player:")
"""
return simpledialog.askstring(title, prompt)