Tkinter OptionMenu reading selected option & updating label on click of button, trace of StringVar

preview_player
Показать описание
We can read the selected option value of the OptionMenu on click of a button by using command. This command will execute one function and inside the function we will read the selected options and transfer the value to a string variable.

def my_show():
Here set_out is another string variable , this string variable is associated to the label which will display our selected option of the OptionMenu

On Button click
We used command option to trigger the function my_show() to read the user selected value and display the same using the label. The function my_show() will use the string variable my_out to set the text of the Label.
On Selection of OptionMenu.
We can use the trace method of the string variable to track the changes in value of the string variable.
Above command will trigger the function my_show each time the value of string variable options changes.
Рекомендации по теме
Комментарии
Автор

thank you so much it wa reaally helpfull

mekkiferiel