Py学习  »  Python

在python中创建一个简单的图像

Ron Zhang • 7 年前 • 2070 次点击  

我不知道如何在Python中显示来自不同目的地的图像。我需要知道如何使图像显示在我的程序上。我尝试使用以下代码,但它不会在python程序中显示gif文件。我的文件名为“giftest.gif”,它与程序位于同一文件夹中,但它仍然不会显示,而是会弹出一个错误。

from tkinter import *

root = Tk()

canvas = Canvas(root, width=500, height=500)
canvas.pack()

imagetest = Image("giftest.gif")
canvas.create_image(250, 250, image=imagetest)

root.mainloop()
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/38834
文章 [ 1 ]  |  最新文章 7 年前