I am trying to get the selected option from the given below OptionMenu, but I am not able to use the selected value globally.
def callback(selection):
print(selection)
return selection
yearl=Label(Frame1, text='Select Year ',font=("Helvetica", 10) ).place(relx=-0.3, rely=-1.40)
valueyear= ['2018', '2019', '2020','2021', '2022', '2023']
n =StringVar(Frame1)
n.set(valueyear[0])
yearchoosen = OptionMenu(Frame1, n, *valueyear, command=callback).place(relx=0.3, rely=-1.45,
width=160)
In callback function I am getting the correct selected value but, I want to use selection value in other function as well.