标签:
这里列出一种在窗口Window中画图的程序框架。。。。。。。。。。
#-*- coding:utf-8 -*- from pyglet.gl import * def draw_rect(x, y, width, height): glBegin(GL_LINE_LOOP) glVertex2f(x, y) glVertex2f(x + width, y) glVertex2f(x + width, y + height) glVertex2f(x, y + height) glEnd() class Button(): def draw(self): draw_rect(0.0,0.0,10.0,10.0) class MyWindow(pyglet.window.Window): def __init__(self): super(MyWindow,self).__init__() #按钮 self.button=Button() self.need_draw=[ self.button, ] def on_draw(self): print(‘g‘) self.clear() for draw_object in self.need_draw: draw_object.draw() if __name__ == "__main__": wn=MyWindow() pyglet.app.run()
标签:
原文地址:http://www.cnblogs.com/yinwei-space/p/4604685.html