โดย Jom07 » 21/02/2018 5:07 pm
การใช้ปุ่ม 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()
ผลรัน
เราสามารถตกแต่งปุ่มได้ ใส่สีปุ่ม สีตัวอักษร ปรับขนาดได้ ตามสิ่งที่เราต้องการ
การใช้ปุ่ม Button ชนืดต่างๆ ใน Python GUI (Tkinter) เป็นการสร้างปุ่มมาต่าง ปุ่มมีหลายรูปแบบให้เลือกใช้ เช่น
[b]ตัวอย่าง[/b]
[b]โค้ด[/b]
[code]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()
[/code]
[b]ผลรัน[/b]
[img]http://snap.mindphp.com/index.php?view=2018Feb21_5a8d419cad90e[/img]
[b]เราสามารถตกแต่งปุ่มได้ ใส่สีปุ่ม สีตัวอักษร ปรับขนาดได้ ตามสิ่งที่เราต้องการ[/b]