1

I am trying to make my gui more beatifull and there is problem with bind_class.

My bind_class code is below;

mainWindow.bind_class('Button', '<Enter>', onCursorButton)
mainWindow.bind_class('Button', '<Leave>', notCursorButton, add='+')

Here's my functions;

def onCursorButton(event):
  lighter = hex_to_hsv(event.widget['background'])
  lighter_list = list(lighter)
  if not (lighter[1]-0.4) <= 0:
    lighter_list[1] = lighter_list[1]-0.4
  if not (lighter[2]+0.4) >= 1:
    lighter_list[2] = lighter_list[2]+0.4
  lighter = tuple(lighter_list)
  event.widget.config(bg=hsv_to_hex(lighter))

def notCursorButton(event):
  event.widget.config(bg=generalBtnColor)

This function is work better than I execpted but after, these buttons's own command is not working.

bgButton = tk.Button(themeWindow, text=' ', relief='ridge',
                     bg=generalBgColor, width=6, command=lambda: pickColor(1, generalBgColor))

fgButton = tk.Button(themeWindow, text=' ', relief='ridge',
                     bg=generalFgColor, width=6, command=lambda: pickColor(2, generalFgColor))

btnButton = tk.Button(themeWindow, text=' ', relief='ridge',
                      bg=generalBtnColor, width=6, command=lambda: pickColor(3, generalBtnColor))

And yes, normally this buttons were perfect working.

Seminet
  • 69
  • 6
  • 2
    I think you just need the `add='+'` option for both bindings. Buttons have a built-in binding for ``, you're currently preventing that from ever being invoked, and apparently it's doing something critical for the normal click functionality. – jasonharper Sep 14 '22 at 20:14
  • Oh thanks, that fixed my problem. But why? How it is possible to effect button's self command? – Seminet Sep 14 '22 at 20:19

0 Answers0