官术网_书友最值得收藏!

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()
主站蜘蛛池模板: 赫章县| 抚远县| 新丰县| 轮台县| 曲周县| 永川市| 左权县| 兴安县| 靖边县| 辉南县| 和龙市| 西林县| 湘潭市| 吴川市| 沈丘县| 海丰县| 梧州市| 上高县| 贡觉县| 沧州市| 寿光市| 清丰县| 鄢陵县| 石首市| 鄯善县| 余干县| 铜鼓县| 大田县| 新野县| 扶余县| 德钦县| 新化县| 习水县| 珠海市| 连云港市| 鄱阳县| 衢州市| 台前县| 马边| 嘉黎县| 长岭县|