X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=examples%2Ftogl.py;fp=examples%2Ftogl.py;h=1aa06d6b43db38ce1bdc4f4e174e61e17373455e;hb=a2aac66072e1037a90172a366f43beb5886cf245;hp=0000000000000000000000000000000000000000;hpb=20093059b2f6f571e1fec4c5ffc7f01f90617130;p=meshio%2Fpymeshio.git diff --git a/examples/togl.py b/examples/togl.py new file mode 100644 index 0000000..1aa06d6 --- /dev/null +++ b/examples/togl.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +# coding: utf-8 + +import OpenGL.Tk + + +class Widget(OpenGL.Tk.RawOpengl): + def __init__(self, master, engine, *args, **kw): + super(Widget, self).__init__(master, *args, **kw) + self.engine=engine + self.bind('', self.onDraw) + self.bind('', self.onDraw) + self.bind('', self.onResize) + self.bind('', lambda e: self.engine.onLeftDown(e.x, e.y) and self.onDraw()) + self.bind('', lambda e: self.engine.onLeftUp(e.x, e.y) and self.onDraw()) + self.bind('', lambda e: self.engine.onMotion(e.x, e.y) and self.onDraw()) + self.bind('', lambda e: self.engine.onMiddleDown(e.x, e.y) and self.onDraw()) + self.bind('', lambda e: self.engine.onMiddleUp(e.x, e.y) and self.onDraw()) + self.bind('', lambda e: self.engine.onMotion(e.x, e.y) and self.onDraw()) + self.bind('', lambda e: self.engine.onRightDown(e.x, e.y) and self.onDraw()) + self.bind('', lambda e: self.engine.onRightUp(e.x, e.y) and self.onDraw()) + self.bind('', lambda e: self.engine.onMotion(e.x, e.y) and self.onDraw()) + + def onDraw(self, *dummy): + self.tk.call(self._w, 'makecurrent') + self.update_idletasks() + self.engine.draw() + self.tk.call(self._w, 'swapbuffers') + + def onResize(self, event): + self.engine.onResize(event.width, event.height) + self.onDraw() +