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'







沒有留言:

張貼留言

2024產專班 作業2 (純模擬)

2024產專班 作業2  (純模擬) 1) LED ON,OFF,TIMER,FLASH 模擬 (switch 控制) 2)RFID卡號模擬 (buttom  模擬RFID UID(不從ESP32) Node-Red 程式 [{"id":"d8886...