[PyOpenGL-Users] Begginer's question: how to bind key press in OpenGK.Tk
Brought to you by:
mcfletch
From: <bus...@si...> - 2007-08-01 13:55:27
|
Hi, I just started to play around with PyOpenGL. I'm using the OpenGK.Tk package, and I have a problem binding keyboard input to my application. I attach a very simple code I wrote. Although I've done the bind("<KeyPress>"), it does not work. Any help will be really appreciated. Thanks! CODE: from OpenGL.Tk import * ################################################################3 # def redraw(o): glClearColor(0.5, 0.5, 0.5, 0) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glOrtho(0,1,0,1,0,1) glBegin(GL_QUADS) glVertex3f(0,0,0) glVertex3f(1,0,0) glVertex3f(1,1,0) glVertex3f(0,1,0) glEnd() ################################################################3 # def keyDown(event): print repr(event.char) ################################################################3 # o = Opengl(width = 300, height = 300, double = 1) o.redraw = redraw o.pack(side = 'top', expand = 1, fill = 'both') o.bind("<KeyPress>",keyDown) o.mainloop() ------------------------------------------------------------------------ Abans d'imprimir aquest correu electrònic pensa si és necessari fer-ho: el medi ambient és cosa de tots. ------------------------------------------------------------------------ |