Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Python中使用tkinter显示图像?_Python_User Interface_Tkinter - Fatal编程技术网

如何在Python中使用tkinter显示图像?

如何在Python中使用tkinter显示图像?,python,user-interface,tkinter,Python,User Interface,Tkinter,您应该使用读取这些复杂的图像格式,并将它们作为可理解的对象传递给tkinter: from tkinter import * from PIL import ImageTk, Image top = Tk() file ='flame2.jpg' filename = PhotoImage(file) panel=PanedWindow() panel = Label(top, image = filename) panel

您应该使用读取这些复杂的图像格式,并将它们作为可理解的对象传递给tkinter:

    from tkinter import *
    from PIL import ImageTk, Image

    top = Tk()

    file ='flame2.jpg'
    filename = PhotoImage(file)

    panel=PanedWindow()
    panel = Label(top, image = filename)

    panel.pack(side = "bottom", fill = "both", expand= "yes")
    top.mainloop()
您应该使用读取这些复杂的图像格式,并将它们作为可理解的对象传递给tkinter:

    from tkinter import *
    from PIL import ImageTk, Image

    top = Tk()

    file ='flame2.jpg'
    filename = PhotoImage(file)

    panel=PanedWindow()
    panel = Label(top, image = filename)

    panel.pack(side = "bottom", fill = "both", expand= "yes")
    top.mainloop()

my_image=image.open(“flame2.jpg”)属性错误:类型对象“image”在编译您发送的代码后没有属性“open”,这是发生的错误。请尝试
import PIL.image
而不是
from PIL import image
错误保持不变。my_image=image.open(“flame2.jpg”)AttributeError:type对象“Image”在编译您发送的代码后没有属性“open”,这是发生的错误。请尝试导入PIL。Image而不是从PIL导入Image错误保持不变。