这些是我的按钮,我想在鼠标进入某个按钮时更改我的状态栏文本。我只想用鼠标输入按钮的一种方法。怎么做?在
self.connectBtn = tk.Button(self.master, text="CONNECT", width=8)
self.connectBtn.place(x=10, y=100)
self.backupBtn = tk.Button(self.master, text="BACKUP", width=8)
self.backupBtn.place(x=80, y=100)
self.copyBtn = tk.Button(self.master, text="COPY", width=8)
self.copyBtn.place(x=10, y=130)
self.moveBtn = tk.Button(self.master, text="MOVE", width=8)
self.moveBtn.place(x=80, y=130)
for self.button in [self.connectBtn, self.backupBtn, self.copyBtn, self.moveBtn]:
self.button.bind("<Enter>", self.mouseOver)
self.button.bind("<Leave>", self.mouseLeave)
我的鼠标搜索方法
^{pr2}$如果鼠标输入了备份按钮,则状态栏中的文本应为“备份所选数据库”。然后在其他按钮上。我不知道用什么来做那些按钮。谢谢!在
这个SO help page建议发布一个最小的、完整的、可验证的示例(很少有人会这样做;-)。我建议做同样的实验。当从空闲或控制台运行时(为了有一个可以打印的地方),下面将打印“Success!”每次鼠标进入按钮。在
关键点是:回调得到一个参数,一个事件对象;事件有大约20个属性,其中一个是小部件;可以比较小部件是否相等。应用于您的代码,下面的代码将(应该)起作用。在
^{pr2}$不过,我个人会进一步考虑代码。在
相关问题 更多 >
编程相关推荐