我正在参加一个非常简单的编码课程,获得额外学分并让工作变得有趣的方法之一是通过海龟添加图像。我可以显示图像,但我真的希望图像位于正在运行的其他应用程序之上,而不是仅在后台打开或位于底层。这是用于使图像正常工作的代码部分,我将省略其余部分。
from turtle import *
#I'm importing turtle so I can display an image later.
Image = ("Darth.gif")
#I'm assigning the image I want to display to the value Image
addshape(Image)
#I'm adding a shape and assigning it the value of the variable Image
shape(Image)
#This will display the shape in the variable Image.
我在网上找到的大部分内容都使用导入海龟和命令,这些命令似乎不适用于我正在使用的这个版本的海龟。教授并不要求它出现在最上面,这只是我想要发生的事情。该代码“有效”是因为图像出现在正在运行的任何内容后面。预先感谢您的帮助。
您的代码似乎运行并很快消失,为了防止这种行为,您可以使用屏幕模块。使用屏幕模块,您可以自定义屏幕尺寸、颜色...甚至屏幕终止事件。 有代码。
from turtle import *
//from turtle import Screen
screen = Screen()
screen.setup(width=600, height=600)
Image = ("ab.gif")
addshape(Image)
shape(Image)
screen.exitonclick()
现在点击它时屏幕会消失。