Creating Tkinter-compatible variables

So, how would we go about using a variable to update this label? Tkinter comes with four built-in variable objects for us to handle different data types:

  • StringVar: This holds characters like a Python string.
  • IntVar: This holds an integer value.
  • DoubleVar: This holds a double value (a number with a decimal place).
  • BooleanVar: This holds a Boolean to act like a flag.

To create a variable, just instantiate it like any other class. These do not require any arguments. For example:

label_text = tk.StringVar()
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset