การใช้งาน Python GUI (Tkinter) :Label widget (วิดเจ็ตป้ายกำกับ)

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: การใช้งาน Python GUI (Tkinter) :Label widget (วิดเจ็ตป้ายกำกับ)

การใช้งาน Python GUI (Tkinter) :Label widget (วิดเจ็ตป้ายกำกับ)

โดย Jom07 » 21/02/2018 5:35 pm

การใช้งาน Python GUI (Tkinter) :Label widget (วิดเจ็ตป้ายกำกับ) เป็นการสร้างหน้าต่าง กำหนดข้อความ และ การจัดข้อความต่างๆ เช่น จัดให้อยู่ ซ้าย หรือขวา
ตัวอย่าง
โค้ด

โค้ด: เลือกทั้งหมด

from tkinter import *

root = Tk()
root.option_add("*Font", "consolas 10")
Label(root, text="Mind", bg="light green").pack(anchor=W)
Label(root, text="mindphp", bg="blue").pack(fill=X)
Label(root, text="aaaaaaaaaa\na", bg="gold").pack(anchor=E)
Label(root, text="b\nb", bg="orange", wraplength=10, justify=RIGHT).pack(fill=X)
Label(root, text="c\nc", bg="deep sky blue", wraplength=10, justify=LEFT).pack(fill=X)
Label(root, text="d\nd", bg="hot pink", wraplength=10).pack(fill=X)
root.mainloop()
ผลรัน
รูปภาพ

ทำให้เราจัดข้อความได้ง่ายมากขึ้น

ข้างบน