【发布时间】:2019-10-05 15:00:53
【问题描述】:
我是 GUI 编程新手,最近开始使用 tKinter。
我的问题是程序不会显示我的图像,我怀疑是我的代码有问题,但是,我希望有人能准确地向我解释我如何使它工作......
这是我的代码:
from tkinter import * # Import the tkinter module (For the Graphical User Interface)
from PIL import ImageTk, Image
width = 1920
height = 1080
RootGeo = str(width) + "x" + str(height) # Make a def for RootGeo so the Root geometry isn't hardcoded
def MakeWindow():
# -----Root_Attributes-----
Root = Tk()
Root.geometry(RootGeo)
Root.state("zoomed")
# -----Root_Attributes, Root_Containers----- ### NOT WORKING ###
__DISPlAY__ = Image.open("Display.png")
__DISPLAY_RENDER__ = ImageTk.PhotoImage(__DISPlAY__)
Display_icon = Label(Root, image=__DISPLAY_RENDER__)
Display_icon.image = __DISPLAY_RENDER__
Display_icon.place(x=0, y=0)
# -----Root_Containers----- ### NOT WORKING ###
Root.mainloop()
MakeWindow()
我们将不胜感激任何和所有的帮助。
【问题讨论】:
-
不是重复的......
-
@BryanOakley 对不起,如果我弄错了,但是我不明白那个帖子,有人可以详细解释一下吗?
-
我错了。我删除了我之前的评论。
-
@BryanOakley 好的...但是你能解释一下出了什么问题吗?
标签: python python-3.x user-interface tkinter