When to use Variable classes? (BooleanVar, DoubleVar, IntVar, StringVar)

后端 未结 2 1110
感情败类
感情败类 2020-11-30 14:41

Can\'t tkinter.widget.configure(text=\"our text\") be used for all widgets? What is the advantage, or the main purpose of using:

var_cls = tkint         


        
2条回答
  •  萌比男神i
    2020-11-30 15:23

    StringVar can be bound to a widget, so you just need to have a handle on the StringVar and you can modify its value and it will update automatically. Otherwise, you would need to keep a handle on the widget itself and handle the event loop stuff etc. Basically you should use StringVar etc. when the value could change. If it's going to be static for certain, you don't need it.

提交回复
热议问题