หน้า 1 จากทั้งหมด 1

การใช้ปุ่ม Button ชนิดต่างๆ ใน Python GUI (Tkinter)

โพสต์แล้ว: 21/02/2018 5:07 pm
โดย Jom07
การใช้ปุ่ม Button ชนืดต่างๆ ใน Python GUI (Tkinter) เป็นการสร้างปุ่มมาต่าง ปุ่มมีหลายรูปแบบให้เลือกใช้ เช่น

ตัวอย่าง
โค้ด

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

from tkinter import *

root = Tk()
root.option_add("*Font", "consolas 20")
Button(root, text="mind", width=20).pack()
Button(root, text="php", bg="orange").pack()
Button(root, text="python", fg="blue", padx=30).pack()
Button(root, text="java", fg="red", bd=10, width=20).pack()
Button(root, text="xml", fg="blue", bd=10, state=DISABLED).pack()
Button(root, text="MD\nsoft", fg="light green", bd=10, state=NORMAL).pack()

root.mainloop()
ผลรัน
รูปภาพ

เราสามารถตกแต่งปุ่มได้ ใส่สีปุ่ม สีตัวอักษร ปรับขนาดได้ ตามสิ่งที่เราต้องการ