I'm a newbie. I'm having a problem making a small toy,When I use tkinter . After I execute the script, it prints "?" directly in the terminal, and this time I don't trigger "ComboboxSelected". enter image description here Then, when I select the drop-down box other item, I think the event is fired, but there is no new "?" is printed
enter image description here My English is weak,so these texts are translated by translation software. There may be some errors.
import tkinter
from tkinter import ttk
top = top = tkinter.Tk()
cbox = ttk.Combobox(top)
cbox.grid(column=0)
cbox["value"] = ["a","b","c"]
def func(cbox):
print("?")
cbox.bind("<<ComboboxSelected>>>", func(cbox))
top.mainloop()
When I repeat bind twice, "?" Was printed twice, which I think proves that the loop is not clogged
import tkinter
from tkinter import ttk
top = top = tkinter.Tk()
cbox = ttk.Combobox(top)
cbox.grid(column=0)
cbox\["value"\] = \["a","b","c"\]
def func(cbox):
print("?")
cbox.bind("\<\<ComboboxSelected\>\>", func(cbox))
cbox.bind("\<\<ComboboxSelected\>\>", func(cbox))
top.mainloop()
I found another problem and he does work. text But why,I don't understand.