Skip to content

new_window

malibx.new_window(mlx: Mlx, size_x: int, size_y: int, title: str) -> 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 loop runs is shown on its first frame.
  • The window can't be resized. Its drawing area is always size_x × size_y pixels.
  • 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_size first.

Example

import malibx

mlx = malibx.init()
win = malibx.new_window(mlx, 800, 600, "My game")
malibx.loop(mlx)

See also

init · destroy_window · clear_window · Your first window