0
私はPythonを初めて使い、ドロップダウンメニューの項目が選択されたときに特性のリストを表示するGUIを作成しようとしています。ドロップダウンメニューの下にテキストを表示したい。ここで私はこれまで持っているものですが、それが提供するすべてのは、空のボックスです: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