Py5Surface.set_location()#

Set the Sketch’s window location.

Examples#

1py5.run_sketch(block=False)
2surface = py5.get_surface()
3# move the sketch window to the upper left corner of the display
4surface.set_location(0, 0)
 1# this sketch will hide itself and reappear elsewhere on your display.
 2def setup():
 3    global surface
 4    global visible
 5    surface = py5.get_surface()
 6    visible = True
 7
 8
 9def draw():
10    global visible
11    if py5.frame_count % 250 == 0:
12        # this negates the visible variable
13        visible = not visible
14        if visible:
15            surface.set_location(py5.random_int(py5.display_width),
16                                 py5.random_int(py5.display_height))
17        surface.set_visible(visible)

Description#

Set the Sketch’s window location. Calling this repeatedly from the draw() function may result in a sluggish Sketch. Negative or invalid coordinates are ignored. To hide a Sketch window, use Py5Surface.set_visible().

Underlying Processing method: PSurface.setLocation

Syntax#

set_location(x: int, y: int, /) -> None

Parameters#

  • x: int - x-coordinate for window location

  • y: int - y-coordinate for window location

Updated on November 12, 2021 11:30:58am UTC