这里列出一种在窗口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()
    
        

 

相关文章:

  • 2020-06-06
  • 2021-07-27
  • 2022-03-05
  • 2021-10-29
  • 2022-03-02
  • 2022-12-23
  • 2018-01-17
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2019-12-15
  • 2022-01-09
  • 2022-12-23
  • 2021-10-04
  • 2021-05-27
相关资源
相似解决方案