tkintertools icon indicating copy to clipboard operation
tkintertools copied to clipboard

请求为Text、Image添加bind接口

Open shu-shu-1 opened this issue 1 year ago • 1 comments

🎯 Feature Description

请求为Text、Image添加bind接口,方便绑定事件

🚀 Possible Implementation

No response

✉️ Contact Details

No response

⚠️ Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

shu-shu-1 avatar Aug 16 '24 04:08 shu-shu-1

目前绑定事件可以通过自定义控件实现,但这或许不是很方便,未来会考虑加入 bind 方法来绑定事件。

Xiaokang2022 avatar Aug 16 '24 05:08 Xiaokang2022

@shu-shu-1

已在 38582c1586d105349823ccf8445e9cf164fd0d18 里通过给 virtual.Widget 添加了属性 _update_hooks 充当钩子来满足控件更新(状态改变或者手动更新时触发)时执行额外函数的功能,此功能仍在测试中,暂为保护属性。此功能对所有控件均有效。

后续可能还将添加一个类似的 _event_hooks 充当控件触发对应事件时执行额外函数的钩子,这个相比前者的细粒度会更小。

Xiaokang2022 avatar Sep 30 '24 14:09 Xiaokang2022

@shu-shu-1

该 Issue 的需求已经完成,但未来 bind 方法还会有一定的改进。目前 bind 并非是对事件绑定,而是对控件的状态更新进行绑定,故参数和使用方式与 tk 的完全不同,但也能完成一些功能需求,未来还将提升绑定的细粒度,以对具体的事件进行绑定。

Xiaokang2022 avatar Oct 01 '24 17:10 Xiaokang2022