new_window¶
MiniLibX: mlx_new_window
Opens a new window with a black drawing area.
Parameters¶
| Name | Type | Description |
|---|---|---|
mlx |
Mlx |
The connection from init |
size_x |
int |
Width of the drawing area, in pixels |
size_y |
int |
Height of the drawing area, in pixels |
title |
str |
Text shown in the title bar |
Returns¶
A Window handle, to pass to the drawing and hook
functions.
Raises¶
| Exception | When |
|---|---|
RuntimeError |
The window couldn't be created, for example because there's no display: new_window failed: … |
OverflowError |
size_x or size_y is negative |
Notes¶
- The window starts black. Anything you draw before
loopruns is shown on its first frame. - The window can't be resized. Its drawing area is always
size_x×size_ypixels. - Windows show the malibx logo as their icon: the Dock icon on macOS and the window icon on Linux X11. Wayland and Windows keep the system default.
- You can open as many windows as you like. Each has its own pixels, font size and hooks.
- A window closes when the user clicks its close button, or when you call
destroy_window. - To fit a window on the screen, check
get_screen_sizefirst.
Example¶
import malibx
mlx = malibx.init()
win = malibx.new_window(mlx, 800, 600, "My game")
malibx.loop(mlx)