What widget should after be called on?

前端 未结 1 1172
遥遥无期
遥遥无期 2021-01-19 17:20

I\'m using after to create a delayed callback. I noticed though that many different objects have an after method, and it isn\'t clear if there\'s a

相关标签:
1条回答
  • 2021-01-19 18:06

    I'm using after to create a delayed callback. I noticed though that many different objects have an after method, and it isn't clear if there's any difference between calling after on say a tk.Frame or a tk.Button.

    No, there is no difference. You can call after using any widget you want and it will behave exactly the same.

    Looking at the implementation, it seems like it just delegates to self.tk.call('after', ms, name) in a common base class of widgets, but that alone doesn't mean that the behavior will be identical for all subclasses.

    Actually, it does. The fact that you call it as a method on a widget is an artifact of the Tkinter implementation. In the underlying tcl/tk library it's just a function call that isn't tied to any widget.

    0 讨论(0)
提交回复
热议问题