pip install PySDL2
python
import sdl2
import sdl2.ext
sdl2.ext.init()
window = sdl2.ext.Window("PySDL2 Demo", size=(800, 600))
window.show()
surface = window.get_surface()
bg_color = sdl2.ext.Color(255, 255, 255)
surface.fill(bg_color)
font_manager = sdl2.ext.FontManager()
font = font_manager.get_system_font()
text_color = sdl2.ext.Color(0, 0, 0)
text_surface = font.render("Hello, PySDL2!", color=text_color)
text_rect = text_surface.get_rect()
text_rect.center = surface.get_rect().center
surface.blit(text_surface, text_rect)
window.refresh()
running = True
while running:
for event in sdl2.ext.get_events():
if event.type == sdl2.SDL_QUIT:
running = False
break
sdl2.ext.quit()