1. # draw lines on the current rendering target (PySDL2 sdl2.ext version)
  2.  
  3. from sdl2 import *
  4. import sdl2.ext
  5.  
  6. # initialize
  7. sdl2.ext.init()
  8.  
  9. # create window
  10. win = sdl2.ext.Window("RenderDrawLines", size=(640, 480))
  11. win.show()
  12.  
  13. # create renderer
  14. renderer = sdl2.ext.Renderer(win, flags=sdl2.SDL_RENDERER_ACCELERATED)
  15.  
  16. # fill background with white
  17. renderer.color = sdl2.ext.Color(255,255,255)
  18. renderer.clear()
  19.  
  20. # draw a black line
  21. renderer.color = sdl2.ext.Color(0,0,0)
  22. renderer.draw_line([0, 0, 640, 480])
  23.  
  24. # show
  25. renderer.present()
  26.  
  27. # event loop
  28. running = True
  29. while running:
  30.   events = sdl2.ext.get_events()
  31.   for event in events:
  32.     if event.type == SDL_QUIT:
  33.       running = False
  34.       break
  35.   SDL_Delay(40)
  36.  
  37. # clean up
  38. sdl2.ext.quit()
  39.  
[raw code]