Devdit
 

Python สร้าง CheckBox ยังไง tkinter

814

Python สร้าง CheckBox ยังไง tkinter บทความนี้สอนใช้คำสั่ง Checkbutton เพื่อสร้าง CheckBox ด้วย tkinter module ร่วมกับภาษา Python โดย CheckBox คือตัวเลือกที่สามารถเลือกได้มากกว่า 1 พร้อมกัน สามารถเขียนโปรแกรมได้ดังนี้

 

ตัวอย่าง Python สร้าง CheckBox ยังไง tkinter

from tkinter import *   

app = Tk()
app.geometry('400x200')

red = Checkbutton( app , text="Red", font=('Tahoma', 18) ).grid(row=0, sticky=W)
green = Checkbutton( app , text="Green", font=('Tahoma', 18) ).grid(row=1, sticky=W)
blue = Checkbutton( app , text="Blue", font=('Tahoma', 18) ).grid(row=2, sticky=W)

app.mainloop()

คำอธิบาย

Python สร้าง CheckBox จากตัวอย่างใช้คำสั่ง Checkbutton สร้าง CheckBox ทั้งหมด 3 อัน คือ Red, Green, Blue ขนาดตัวอักษร 18 Tahoma พร้อมแสดงผลลัพธ์ออกสู่หน้าจอด้วยคำสั่ง mainloop

เขียน 1 ปีที่แล้ว
ชอบ
ลิ้งก์
แชร์
Devdit มีช่อง YouTube แล้ว
เราสร้างวิดีโอเกี่ยวกับเทคโนโลยี ทำตามง่ายๆ