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'







沒有留言:

張貼留言

Telegram +ESP32自動發報機

  Telegram   +ESP32自動發報機 這套系統是一個典型的 IoT(物聯網)架構 ,結合了遠端配置(Python)、通訊中介(MQTT)與硬體執行(ESP32)。 以下我為您拆解這兩支程式的核心運作原理: 一、 系統架構流程 Python 端 (控制台) :使用者輸入...