之后应该调用什么小部件? [英] What widget should after be called on?

查看:32
本文介绍了之后应该调用什么小部件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 after 来创建延迟回调.我注意到许多不同的对象都有一个 after 方法,并且不清楚在 tk.Frameafter 之间是否有任何区别code> 或 tk.Button.

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.

我还没有看到一个指南提到无论调用什么对象 after 都可以期待相同的行为.从实现来看,它似乎只是在一个公共小部件基类中委托给 self.tk.call('after', ms, name) ,但这并不意味着所有子类的行为都相同.

I haven't seen a single guide mention if you can expect identical behavior regardless of what object after is called on. 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.

如果我在需要调用 after 时手头有多个小部件,是否有任何理由选择一个而不是另一个,或者无论如何我都可以期待相同的行为?

If I have multiple widgets on-hand when I need to call after, is there any reason to choose one over another, or can I expect identical behavior regardless?

推荐答案

我正在使用 after 创建延迟回调.我注意到许多不同的对象都有一个 after 方法,并且不清楚调用 after 之间是否有任何区别,比如 tk.Frame 或 tk.Button.

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.

不,没有区别.您可以使用任何您想要的小部件调用 after ,它的行为将完全相同.

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

看看实现,它似乎只是委托给 self.tk.call('after', ms, name) 一个公共基类的小部件,但这并不意味着行为将是相同的对于所有子类.

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.

事实上,确实如此.您将其作为小部件上的方法调用这一事实是 Tkinter 实现的产物.在底层 tcl/tk 库中,它只是一个与任何小部件无关的函数调用.

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.

这篇关于之后应该调用什么小部件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆