change preview opacity on mouse hover
in create_layout_btn() add 2 events
event_img.connect("enter-notify-event",self.on_over_img, True) # mouse over box
event_img.connect("leave-notify-event",self.on_over_img, False) # mouse out box
def on_over_img(self, box, event, isOverImage):
"""on mouse over / out : change opacity"""
if box.btn.get_active():
return
if isOverImage:
box.btn.image.set_opacity(Opacity.MIDDLE)
else:
box.btn.image.set_opacity(Opacity.LOW)
for a code more readable/easy to change, change all values 1, 0.7 and 0.45 by constants
class Opacity:
TOP = 1
MIDDLE = 0.70
LOW = 0.45
def on_button_toggled(self, button, name):
state = Opacity.LOW
if button.get_active():
state = Opacity.TOP
...