forked from RainingComputers/whipFTP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhipFTP_ToolbarButton.py
32 lines (26 loc) · 1008 Bytes
/
whipFTP_ToolbarButton.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#Custom button class for whipFTP, Copyrights Vishnu Shankar B,
from tkinter import *
from tkinter import ttk
from tkinter import PhotoImage
#Custum button class that uses the 'Label' widget
class Button(ttk.Label):
def __init__(self, parent, image, image_hover, command):
#Save reference to icon
self.icon = image
self.hover_icon = image_hover
#save reference to the function
self.command = command
#Create the label
super().__init__(parent, image = self.icon)
#Bind events
super().bind('<Enter>', self.hover)
super().bind('<Leave>', self.left)
super().bind('<Button-1>', self.click)
def click(self, event):
super().configure(image = self.icon)
if self.command is not None: self.command()
super().configure(image = self.hover_icon)
def hover(self, event):
super().configure(image = self.hover_icon)
def left(self, event):
super().configure(image = self.icon)