pythontkinter图片背景_python – 在Tkinter中将图像导入为背景

我已经搜索了许多人在这里问过的一些其他问题,关于如何从Tkinter导入图像作为背景,我必须说我没有多少帮助.

让我向你解释我的问题.我已经下载了一个图像,将其转换为gif并将其保存到我的桌面.但是,Tkinter窗口打开后它不会导入图像.

这是我的代码:

import Tkinter as Tk

root = Tk.Tk()

background_image=Tk.PhotoImage("C:/Desktop/logo.gif")

background_label = Tk.Label(root, image=background_image)

background_label.place(x=0, y=0, relwidth=1, relheight=1)

root.wm_geometry("600x400+20+40")

root.title('Menu')

playButton = Tk.Button(root, text='Play', command=root.destroy)

playButton.pack()

root.mainloop()

你能帮帮我吗?

解决方法:

你应该以这种方式使用PhotoImage.

background_image=Tk.PhotoImage(file="C:/Desktop/logo.gif")

标签:python,import,image,tkinter,pygame

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值