Py学习  »  Python

python 3 tkinter飞溅屏幕

Kitsune Makoto • 5 年前 • 1246 次点击  

我一直想在主程序出现之前添加一个显示为启动屏幕的图像,但是我无法让它工作。

我希望图像在监视器中居中,只显示图像而不显示其他内容。

我的代码是:

root = tk.Tk()
root.overrideredirect(True)
width = root.winfo_screenwidth()
height = root.winfo_screenheight()
root.geometry('%dx%d+%d+%d' % (width*0.8, height*0.8, width*0.1, 
height*0.1))
image_file = "Flexbase.png"
image = tk.PhotoImage(file=image_file)
canvas = tk.Canvas(root, height=height*0.8, width=width*0.8, bg="brown")
canvas.create_image(width*0.8/2, height*0.8/2, image=image)
canvas.pack()
root.after(5000, root.destroy)
root.mainloop()

我做错什么了?有人能给我解释一下如何显示图像吗?

备注:如果这些信息有帮助的话,图片本身是640x160,没有任何透明的东西。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/44914
 
1246 次点击  
文章 [ 1 ]  |  最新文章 5 年前