【发布时间】:2020-05-13 15:39:52
【问题描述】:
我正在制作一个使用 2 个不同图像的程序。我有加载页面,它只是一张名为“loading.png”的图片,效果很好。
当我尝试使用相同的方法将名为“table.png”的不同图像添加到不同的窗口时,它不会显示,但在介绍窗口中会显示我想要的图像。
这是加载屏幕代码
win=Tk()
win.title('PokerChamp')
win.geometry('400x200')
background_image = PhotoImage(file='loading.png')
background_label = Label(win, image=background_image)
background_label.place(x=0, y=0, relwidth=1, relheight=1)
这工作正常,但是当我添加此代码时,它显示错误的图像并且主窗口的图像不显示。
root=Tk()
root.withdraw()
root.config(bg='#1b800b')
root.title('PokerChamp')
image = PhotoImage(file='table.ppm')
label = Label(win, image=image)
label.place(x=0, y=0)
有什么想法吗?
【问题讨论】:
-
为什么要在歌曲中添加歌词?
-
有两个
TK的实例是错误的,请检查这个effbot.org/tag/Tkinter.Toplevel。很抱歉最初的附件。
标签: python-3.x tkinter photoimage