0
는 파이썬에 새로 온 사람, 나는 드롭 다운 메뉴에서 항목을 선택하면 특성의 목록을 표시하는 GUI를 만들려고하고 있습니다. 드롭 다운 메뉴 아래에 텍스트를 표시하고 싶습니다. 여기에 지금까지 무엇을, 그러나이 제공하는 모든 빈 상자입니다 : 위젯 드롭 다운은 tkinter.OptionMenu
라고tkinter를 사용하여 드롭 다운 메뉴를 만드시겠습니까?
import tkinter
import tkinter as tk
#creates box
window =tkinter.Tk()
frame= tkinter.Frame(window)
frame.pack()
window.geometry("%dx%d+%d+%d" % (330, 80, 200, 150))
window.title("Breeds and Characteristics")
#data
data=('Abyssinian','American-Bobtail','American-Curl')
Output1 ="Aloof,Intelligent,Diseased"
Output2= "Affectionate,Intelligent,Diseased"
Output3= "Affectionate,Dull,Healthy"
display = Label(window, text="")
#create a dropdown list
p = tkinter.Combobox(window, textvariable=var, values=data)
p.pack()
def chars():
for values in p:
if item == 'Abyssinian':
print (Output1)
elif item == 'American-Bobtail':
print (Output2)
elif item == 'American-Curl':
print (Output3)
#starts dropdown box at first cat
var = tkinter.StringVar()
var.set('Abyssinian')
#updates text
def boxtext():
display.configure(text=(chars))
display.pack()
#button to view characteristics
button = Button(window, text='View Characteristics', command=select)
button.pack(side='left', padx=20, pady=10)
window.mainloop()
것은이 읽기 : [https://pythonspot.com/tk-dropdown-example/](https://pythonspot.com/tk-dropdown-example/) – 63677