버튼 위젯은 애플리케이션의 모든 기존 기능을 통해 통신하는 방법을 제공합니다. 기능과 객체를 캡슐화하는 Button의 도움으로 특정 작업을 수행할 수 있습니다. 그러나 하나의 버튼으로 여러 작업을 수행하려는 경우가 있을 수 있습니다. 이는 애플리케이션에서 여러 이벤트 또는 콜백을 대상으로 하는 람다 함수를 정의하여 달성할 수 있습니다.
예시
이 예에서는 특정 버튼에 여러 이벤트를 추가합니다.
#Import the Tkinter Library
from tkinter import *
#Create an instance of Tkinter Frame
win = Tk()
#Set the geometry of window
win.geometry("700x350")
#Define functions
def display_msg():
label.config(text="Top List of Programming Language")
def show_list():
listbox= Listbox(win, height=10, width= 15, bg= 'grey', activestyle= 'dotbox',font='aerial')
listbox.insert(1,"Go")
listbox.insert(1,"Java")
listbox.insert(1,"Python")
listbox.insert(1,"C++")
listbox.insert(1,"Ruby")
listbox.pack()
button.destroy()
#Create a Label widget to display the message
label= Label(win, text= "", font= ('aerial 18 bold'))
label.pack(pady= 20)
#Define a Button widget
button= Button(win, text= "Click Here",command= lambda:[display_msg(), show_list()])
button.pack()
win.mainloop() 출력
위의 코드를 실행하면 버튼이 포함된 창이 표시됩니다.

버튼을 클릭하면 두 가지 작업을 병렬로 수행합니다. 레이블 위젯과 문자열 목록이 포함된 창이 표시됩니다.
