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'







沒有留言:

張貼留言

2026 作業3 RFID+ Telegram 練習

 2026 作業3  RFID+ Telegram  練習 (Wokwi 與 Telegram 二者溝通訊息反映比較慢 ) 歡迎 Alex 使用 RFID 控制系統 /on : 開啟 LED /off : 關閉 LED /flash : 閃爍模式 /timer : 開啟 5 秒 ...