def button_from_label(self, text, image_url, cmd, status):
image = Image.open(image_url)
image = image.resize((30, 30), Image.ANTIALIAS)
photo = ImageTk.PhotoImage(image)
btn = Label(self,
text=text,
image=photo,
compound=TOP,
width=70,
bg=NOTEBOOK_COLOR,
cursor='hand2')
btn.bind('<Button-1>', cmd)
btn.bind('<Enter>', lambda e: (btn.config(bg='light cyan'),
self.controller.status_bar.set(status)))
btn.bind('<Leave>', lambda e:
(btn.config(bg=NOTEBOOK_COLOR),
self.controller.status_bar.set('Ready')))
btn.bind('<ButtonRelease-1>', lambda e: btn.config(bg='light cyan'))
return btn, photo
评论列表
文章目录