2

I have a canvas where I draw an image

that image contains a console text where I display the last 10 lines or something

I want to change the lines (array index) I display by catching mouse wheel events

there is no scroll bar so I don't have a huge image to scroll, I just redraw the text

here is how I try to setup the scroll function:

def drawConsole(self):
    canvas = self.window["CONSOLE-CANVAS"]
    canvas.TKCanvas.bind_all("<MouseWheel>", self.vscroll)

def vscroll(self,event):
    print( -1 * (event.delta // 120) )

somewhere in my layout, there is a canvas:

[sg.Canvas(size=(1400, 300), background_color='black', key="CONSOLE-CANVAS")],

the vscroll function is never triggered

thanks for helping me on this

[edit : just found out return_keyboard_events but how do I figure over which component I am ?]

user7082181
  • 354
  • 3
  • 15

1 Answers1

2

ok I found out

using return_keyboard_events =True

and finding which component gets overed over:

self.window["CONSOLE-CANVAS"].bind('<Enter>', '+MOUSE OVER+')
self.window["CONSOLE-CANVAS"].bind('<Leave>', '+MOUSE AWAY+')
user7082181
  • 354
  • 3
  • 15