'Difference Between Variable And Textvariable in tkinter

My code:

my_var = tk.StringVar()

m_var2 = tk.StringVar()

my_entry1 = ttk.Entry(root, width=16, textvariable=my_var)

my_radio1 = ttk.Radiobutton(root, text="1", variable=my_var2)

Now what is the difference between textvariable and variable ?



Solution 1:[1]

variable and textvariable are similar in concept, in that both represent variable data.

In the case of textvariable, which is mostly used with Entry and Label widgets, it is a variable that will be displayed as text. When the variable changes, the text of the widget changes as well.

In the case of variable, which is mostly used for Checkbutton and Radiobutton widgets, it represents the value that the widget holds. For example, you may have radio buttons with the text "Yes" and "No", but the actual values may be 1 and 0. In this case the variable represents the value of the widget.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bryan Oakley