我需要在tkinter.canvas中绘制一个矩形来响应click事件:
click_area = self.canvas.create_rectangle(0,0,pa_width,pa_height,fill='LightBlue',outline='lightBlue',tags=['A','CLICK_AREA'])
self.canvas.tag_bind('CLICK_AREA','',self.onClickArea)
有用.
此时,我必须在画布上绘制一系列网格,并且我希望它们被click_area覆盖,因此我需要使click_area透明.
但是,当我写这样的时候:
click_area = self.canvas.create_rectangle(0,0,pa_width,pa_height,fill='',outline='lightBlue',tags=['A','CLICK_AREA'])
它没有响应再点击.
所以,我的问题是如何使其透明并保持响应点击.或者,有没有其他方法来实现我想要的.
非常感谢你.
解决方法:
我想我明白了:绑定画布,而不是矩形.
更换
self.canvas.tag_bind('CLICK_AREA','',self.onClickArea)
同
self.canvas.bind('',self.onClickArea)
问题解决了.
标签:python,tkinter
来源: https://codeday.me/bug/0902/1790635.html