【问题标题】:Show image in Tkinter for python 3.2在 Tkinter for python 3.2 中显示图像
【发布时间】:2012-06-07 18:02:24
【问题描述】:

如何使用 Tkinter 在 Python 3.2 中显示图像? PIL 不工作所以不使用它的东西。

【问题讨论】:

    标签: image python-3.x tkinter


    【解决方案1】:

    使用 Tkinter PhotoImage 类创建一个图像对象,然后将该对象分配给 Label 小部件的 image 属性。

    欲了解更多信息,请参阅http://effbot.org/tkinterbook/photoimage.htm

    【讨论】:

    • 你能给我举个例子吗?我只需要一个带有基本图像和标签的窗口。该图像位于同一目录中,名为 image.gif 。谢谢
    【解决方案2】:

    很简单:

    photo = PhotoImage(file="C:\pictures\pic1.gif")
    label = Label(image=photo)
    label.pack()
    

    【讨论】:

      【解决方案3】:

      试试这个(对于 python 3)

      from tkinter import PhotoImage
      
      
      
      
      photo = PhotoImage(file="/home/pi/pile.gif")
      lb=tkinter.Label(root,image = photo)
      lb.grid(row=4, column=1)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-04-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-08-04
        相关资源
        最近更新 更多