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

ตอบกระทู้

รูปแสดงอารมณ์
: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] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: การใช้ปุ่ม Button ชนิดต่างๆ ใน Python GUI (Tkinter)

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

โดย 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()
ผลรัน
รูปภาพ

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

ข้างบน