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

แชร์ความรู้ภาษา Python ไพทอน การเขียนโปรแกรมภาษาไพทอน

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
Jom07
PHP Super Hero Member
PHP Super Hero Member
โพสต์: 514
ลงทะเบียนเมื่อ: 08/01/2018 9:56 am

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

โพสต์ที่ยังไม่ได้อ่าน โดย Jom07 »

การใช้งาน 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()
ผลรัน
รูปภาพ

ทำให้เราจัดข้อความได้ง่ายมากขึ้น
รูปภาพ
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 107