pyopengltk icon indicating copy to clipboard operation
pyopengltk copied to clipboard

OpenglFrame only takes mouse input tkinter binds and not kebaord binds.

Open ShaunKulesa opened this issue 3 years ago • 6 comments

I have noticed that the openglframe supports <Enter> and <MouseWheel> but not any keyboard input. Is this something that can be changed?.

ShaunKulesa avatar Mar 04 '21 23:03 ShaunKulesa

Works fine for me in moderngl-window

self._tk.bind("<KeyPress>", self.tk_key_press)
self._tk.bind("<KeyRelease>", self.tk_key_release)

Signature of callback methods are:

def tk_key_press(self, event: tkinter.Event) -> None:
def tk_key_release(self, event: tkinter.Event) -> None:

Or do you mean adding native support for it?

einarf avatar Mar 05 '21 00:03 einarf

app.bind("<KeyPress>", sys.exit) does not work at all, but mouse inputs do.

ShaunKulesa avatar Mar 05 '21 00:03 ShaunKulesa

app.bind("<KeyPress>", sys.exit) does not work at all, but mouse inputs do.

I would never assume this actually working. tkinter might be discarding the callable you are providing for some reason. Bind KeyPress to your own function instead.

einarf avatar Mar 05 '21 00:03 einarf

Also it might be better to self.destroy(), Using sys.exit() is not good practice.

einarf avatar Mar 05 '21 00:03 einarf

oh. wait. Are you trying to register the events on the frame itself or using the tk root?

einarf avatar Mar 05 '21 00:03 einarf

To the frame. I did "<a>", function and that never worked.

ShaunKulesa avatar Mar 05 '21 09:03 ShaunKulesa