2022年11月16日 星期三

Python GUI 標籤 Label ---- EX2.1 , 2.2 , 2.2.1

 # ch2_1.py

from tkinter import *


root = Tk()

root.title("ch2_1")

label=Label(root,text="I like tkinter")

label.pack()        # 包裝與定位元件

print(type(label))  # 傳回Label物件

root.mainloop()




# ch2_2.py

from tkinter import *


root = Tk()

root.title("ch2_2")

label=Label(root,text="I like tkinter").pack()

print(type(label))  # 傳回Label物件

root.mainloop()







>>> %Run ch2_2.py

<class 'NoneType'>



# ch2_2_1.py

from tkinter import *


root = Tk()

root.title("ch2_2_1")

Label(root,text="I like tkinter").pack()  


root.mainloop()



沒有留言:

張貼留言

Telegram +ESP32自動發報機

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