Combobox 위젯은 일부 값이 포함된 드롭다운 목록을 만드는 데 사용되는 tkinter의 다양한 위젯 중 하나입니다. 콤보 상자 위젯의 기본값으로 대체되는 값을 드롭다운 목록에서 선택할 수 있습니다. Combobox(root, width, text)의 생성자를 초기화하여 콤보박스 위젯을 생성할 수 있습니다. 위젯.
사용자가 콤보 상자 위젯에서 선택한 값을 지우려면 set(' ') 방법. 다음 예는 수행 방법을 보여줍니다.
예시
# Import the required libraries
from tkinter import *
from tkinter import ttk
# Create an instance of tkinter frame or window
win = Tk()
# Set the size of the window
win.geometry("700x350")
# Create a function to clear the combobox
def clear_cb():
cb.set('')
# Define Days Tuple
days= ('Sun','Mon','Tue','Wed','Thu','Fri','Sat')
# Create a combobox widget
var= StringVar()
cb= ttk.Combobox(win, textvariable= var)
cb['values']= days
cb['state']= 'readonly'
cb.pack(fill='x',padx= 5, pady=5)
# Create a button to clear the selected combobox text value
button = Button(win, text= "Clear", command= clear_cb)
button.pack()
win.mainloop() 출력
위의 코드를 실행하면 콤보 상자 위젯이 있는 창이 표시되고 콤보 상자 위젯에서 선택한 값을 지우는 "지우기" 버튼이 표시됩니다.

이제 콤보 상자 위젯에서 선택한 값을 지우려면 "지우기" 버튼을 클릭하십시오.
