2022年11月16日 星期三

Python GUI 標籤 Label ---- EX2.10 , 2.19-1

 # ch2_19.py

from tkinter import *

root = Tk()

root.title("ch2_19")

html_gif = PhotoImage(file="cartoon_birds.gif")

label=Label(root,image=html_gif)

label.pack()

root.mainloop()



# ch2_19_1.py

from tkinter import *

from PIL import Image, ImageTk


root = Tk()

root.title("ch2_19_1")

root.geometry("680x400")


image = Image.open("yellowstone.jpg")

yellowstone = ImageTk.PhotoImage(image)

label = Label(root,image=yellowstone)

label.pack()


root.mainloop()


THONNY -->工具 --> 管理外掛模組-->Pillow

安裝後執行還是會發生錯誤

>>> %Run ch2_19_1.py

Traceback (most recent call last):

  File "D:\PythonGUI_20190513\ch2\ch2_19_1.py", line 3, in <module>

    from PIL import Image, ImageTk

ModuleNotFoundError: No module named 'PIL'







沒有留言:

張貼留言

MQTT WS HMI 與 Wokwi ESP32 連線的資訊透過HiveMQ

MQTT WS HMI 與 Wokwi ESP32 連線的資訊透過HiveMQ     https://console.hivemq.cloud/clusters 當您進入 HiveMQ Cloud Console 的 Clusters 頁面時,您的目標是取得能讓 MQTT W...