For an StringVar() so we can check the different modes of this variable, like this
r :Read - the variable is read by someone w :Write- the variable is written by someone. u :undefined – The variable is deleted
Here is an example which uses w ( write ) mode to display the value of the variable when ever it changes.
We used one Button and used on Click event to change the value of this variable str1 from Hello to Welcome.
StringVar() is a class in Tkinter. In a GUI application we require various events to be captured to trigger different functions (requirements). If we use normal Python variable with widgets then monitoring the changes is difficult. However by using a StringVar we can monitor the changes and trigger functions based on the requirements.
Example : Declare the password is strong or weak based on the number of chars entered by user. Here we can use StringVar and each time the variable changes its stored data, we can trigger the function checking the length of the input and show the message.
DoubleVar()» IntVar()» BooleanVar()»