乌龟开始和结束屏幕的想法

2024-04-19 14:01:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我有点纠结于如何合并一个开始屏幕与游戏信息,结束屏幕与游戏结果和一个选项重新开始游戏?在

我试图写下文本,然后重新启动屏幕,但文本没有显示。我不知道我是否可以创建多个屏幕实例,或者我遗漏了什么?在


Tags: 实例文本信息游戏屏幕选项遗漏
2条回答

如果使用python3,一个简单的接口是添加到turtle的textinput()(和numinput())命令:

textinput(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:
    >>> textinput("NIM", "Name of first player:")

这既可以宣布游戏结果,也可以询问用户是否想再次玩。不是很复杂,但当你重新启动游戏的逻辑时,可能会充当替身。在

enter image description here

使用turtle.write(text)然后可以使用tkinter将按钮放在turtle屏幕上。或者,Python有一个非常简单的GUI,称为EasyGUI。在

安装使用:

pip install easygui

用法:

^{pr2}$

相关问题 更多 >