Py5Surface.set_location()#
Set the Sketch’s window location.
Examples#
py5.run_sketch(block=False)
surface = py5.get_surface()
# move the sketch window to the upper left corner of the display
surface.set_location(0, 0)
# this sketch will hide itself and reappear elsewhere on your display.
def setup():
global surface
global visible
surface = py5.get_surface()
visible = True
def draw():
global visible
if py5.frame_count % 250 == 0:
# this negates the visible variable
visible = not visible
if visible:
surface.set_location(py5.random_int(py5.display_width),
py5.random_int(py5.display_height))
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().
This method provides the same functionality as window_move().
Underlying Processing method: PSurface.setLocation
Signatures#
set_location(
x: int, # x-coordinate for window location
y: int, # y-coordinate for window location
/,
) -> None
Updated on March 06, 2023 02:49:26am UTC