1. The Essential Structure
Every app must have these components to talk to the kebabOS kernel:
python
import pygame
# Define window defaults
config = {
"width": 350,
"height": 250
}
# This runs once when the app is opened
def init_data():
return {"content": "Type here...", "color": (50, 50, 50)}
# This runs when your window is the active (top) one
def handle_input(event, data):
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_BACKSPACE:
data["content"] = data["content"][:-1]
else:
data["content"] += event.unicode
# This runs every frame
def draw_content(surface, rect, data, is_active):
# Use 'rect' to stay inside your window boundaries
font = pygame.font.SysFont("Arial", 16)
text_surf = font.render(data["content"], True, data["color"])
surface.blit(text_surf, (rect.x + 10, rect.y + 10))
2. Pro-Tips for Apps
- Icons: Save a
favicon.pngin your app folder. The kernel finds it automatically. - Clipping: Don’t worry about drawing over the taskbar; the Pygame Surface clipping in the kernel handles that for you.
- Coordination: Always use
rect.xandrect.yas your anchor points so your UI moves when the window is dragged.