在下拉/选项菜单上,每次选择一个选项时,屏幕上都会显示一个弹出窗口。此弹出窗口是另一个窗口。
#function to create pop-up
def alert_popup():
root = Tk()
root.title("title")
sw = root.winfo_screenwidth()
sh = root.winfo_screenheight()
root.geometry('%dx%d+%d+%d' % (sw/2, sh/2, sh/2, sw/2))
w = Label(root, text=" ", width=120, height=10)
w.grid()
b = Button(root, text="OK", command=root.destroy, width=10)
b.grid()
#code to select the option and display the pop-up
drop = OptionMenu( root , clicked , *options )
drop.grid(pady= 10)
print(clicked.get())
def changed():
print (clicked.get())
clicked.trace("w", changed)
# each time i select this particular option the pop-up should open
if(clicked.get() == "Particular Option"):
alert_popup()