DS Log
In my blog, I delve into the world of programming web technologies, Linux, Unix-like, and graphic design using free tools on Linux.
KINGCODE
KingCode Editor (ex Texty Editor) is my project developed using Java Swing. Project is still in development and in beta version. I plan to add additional features focused for PYTHON, PHP, JAVA, C, JS and BASH.
Read more ↗
VUE on Linux
In this guide, I'll walk you through the step-by-step process of setting up Vue.js on your Linux system, empowering you to create dynamic and interactive web applications. Let's harness the power of Vue.js together on the Linux platform!
Read more ↗
Symfony PHP
Dive into the world of Symfony PHP with this comprehensive introduction. In this guide, you'll learn the essential steps to create and manage posts and users, empowering you to build dynamic web applications with ease.
Read more ↗
Trying Linux from Windows
How to set up a PHP development server on Ubuntu 22.04
Text editors
List of text editors for developers.
Read more ↗
Fonts
Important fonts everyone needs to know.
Read more ↗
Try Linux from Windows
Here are some quick videos I made showing how to try out Linux Mint on Windows.
Read more ↗
Monday, April 6, 2026
How to setup SDL2 lib for Python
SDL 2 (Simple DirectMedia Layer 2) is an open‑source, cross‑platform library that gives programs low‑level access to graphics, audio, input devices, and timing. By handling window creation, 2D rendering, OpenGL/Vulkan contexts, sound playback, keyboard/mouse/controller input, and basic threading, it lets developers write multimedia and game code once and run it on Windows, macOS, Linux, iOS, Android, and many consoles.
Install Ubuntu package:
sudo apt install python3-sdl2
test.py:
import sdl2
version = sdl2.SDL_version()
sdl2.SDL_GetVersion(version)
print(f"SDL2 version: {version.major}.{version.minor}.{version.patch}")
Hello world example:
import sdl2
import sdl2.ext
def run():
sdl2.ext.init()
window = sdl2.ext.Window("Hello SDL2", size=(640, 480))
window.show()
running = True
while running:
events = sdl2.ext.get_events()
for event in events:
if event.type == sdl2.SDL_QUIT:
running = False
break
sdl2.ext.quit()
if __name__ == "__main__":
run()
Example using font and image extensions:
import sdl2
import sdl2.ext
import sdl2.sdlttf as sdlttf
import sdl2.sdlimage as sdlimage
def run():
# Initialise core + extensions
sdl2.ext.init()
sdlttf.TTF_Init()
sdlimage.IMG_Init(sdlimage.IMG_INIT_PNG)
window = sdl2.ext.Window("SDL2 with TTF & Image", size=(800, 600))
window.show()
renderer = sdl2.ext.Renderer(window)
# --- Load a PNG image ---
surface = sdlimage.IMG_Load(b"image.png")
# Create Texture wrapper from SDL_Texture
texture = sdl2.ext.Texture(renderer, surface)
sdl2.SDL_FreeSurface(surface)
# --- Render a TrueType font ---
font = sdlttf.TTF_OpenFont(b"mono.ttf", 48)
fg = sdl2.SDL_Color(255, 255, 255)
text_surface = sdlttf.TTF_RenderUTF8_Blended(font, b"Hello, SDL2!", fg)
text_texture = sdl2.ext.Texture(renderer, text_surface)
sdl2.SDL_FreeSurface(text_surface)
running = True
while running:
for event in sdl2.ext.get_events():
if event.type == sdl2.SDL_QUIT:
running = False
renderer.clear(sdl2.SDL_Color(0, 0, 0))
# draw image - using Texture objects directly
renderer.copy(texture, dstrect=sdl2.SDL_Rect(100, 100, 200, 200))
# draw text
renderer.copy(text_texture, dstrect=sdl2.SDL_Rect(350, 250, 300, 60))
renderer.present()
# Clean up
texture.destroy()
text_texture.destroy()
sdlttf.TTF_CloseFont(font)
sdlttf.TTF_Quit()
sdlimage.IMG_Quit()
sdl2.ext.quit()
if __name__ == "__main__":
run()