เราสามารถอัปเดตวิดเจ็ตปุ่มใน Tkinter ได้หลายวิธี เช่น เราสามารถเปลี่ยนขนาด เปลี่ยนสีพื้นหลัง หรือลบเส้นขอบ ฯลฯ ในตัวอย่างต่อไปนี้ เราจะสร้างวิดเจ็ตปุ่มสามรายการและแต่ละปุ่ม เมื่อคลิก จะเรียกใช้ฟังก์ชันอื่นเพื่ออัปเดตคุณลักษณะ
ตัวอย่าง
# Import the required library
from tkinter import *
from tkinter import ttk
# Create an instance of tkinter frame
win = Tk()
# Define geometry of the window
win.geometry("700x300")
# Function to Increase the Size of the Button
def Button_Size():
button1.configure(font=('Calibri 20 bold'))
# Function to change the background color
def Button_Color():
button2.configure(bg='green')
# Function to Remove Border
def Button_Border():
button3.configure(borderwidth=0)
# First Button
button1=Button(win, text="Increase the Button Size",
command=Button_Size)
button1.pack(pady=20)
# Second Button
button2=Button(win, text="Change the Background Color",
command=Button_Color)
button2.pack(pady=20)
# Third Button
button3 = Button(win, text="Remove the Border",
command=Button_Border)
button3.pack(pady=20)
win.mainloop() ผลลัพธ์
เมื่อดำเนินการ จะแสดงหน้าต่างต่อไปนี้ก่อน -

เมื่อคุณคลิก "เพิ่มขนาดปุ่ม" มันจะสร้างผลลัพธ์ต่อไปนี้ -

เมื่อคลิก "เปลี่ยนสีพื้นหลัง" มันจะสร้างผลลัพธ์ต่อไปนี้ -

หากคุณคลิก "ลบเส้นขอบ" มันจะสร้างผลลัพธ์ต่อไปนี้ -
