# Creating a window

If the Window constructor is called with no arguments, defaults will be assumed for all parameters:

    window = pyglet.window.Window()

The default parameters used are:

- The window will have a size of 640x480, and not be resizable.
- A default context will be created using template config described in OpenGL configuration options.
- The window caption will be the name of the executing Python script (i.e., `sys.argv[0]`).

Windows are visible as soon as they are created, unless you give the `visible=False` argument to the constructor. The following example shows how to create and display a window in two steps:

    window = pyglet.window.Window(visible=False)
    # ... perform some additional initialisation
    window.set_visible()

# Context configuration

The context of a window cannot be changed once created. There are several ways to control the context that is created:

- Supply an already-created Context using the `context` argument:

      context = config.create_context(share)
      window = pyglet.window.Window(context=context)

- Supply a complete Config obtained from a Screen using the `config` argument. The context will be created from this config and will share object space with the most recently created existing context:

      config = screen.get_best_config(template)
      window = pyglet.window.Window(config=config)

- Supply a template Config using the `config` argument. The context will use the best config obtained from the default screen of the default display:

      config = gl.Config(double_buffer=True)
      window = pyglet.window.Window(config=config)

- Specify a Screen using the `screen` argument. The context will use a config created from default template configuration and this screen:

      screen = display.get_screens()[screen_number]
      window = pyglet.window.Window(screen=screen)

- Specify a Display using the `display` argument. The default screen on this display will be used to obtain a context using the default template configuration:

      display = platform.get_display(display_name)
      window = pyglet.window.Window(display=display)

If a template Config is given, a Screen or Display may also be specified; however any other combination of parameters overconstrains the configuration and some parameters will be ignored.

# Fullscreen windows

If the `fullscreen=True` argument is given to the window constructor, the window will draw to an entire screen rather than a floating window. No window border or controls will be shown, so you must ensure you provide some other means to exit the application.

By default, the default screen on the default display will be used, however you can optionally specify another screen to use instead. For example, the following code creates a fullscreen window on the secondary screen:

    screens = display.get_screens()
    window = pyglet.window.Window(fullscreen=True, screens[1])

There is no way to create a fullscreen window that spans more than one window (for example, if you wanted to create an immersive 3D environment across multiple monitors). Instead, you should create a separate fullscreen window for each screen and attach identical event handlers to all windows.

Windows can be toggled in and out of fullscreen mode with the set_fullscreen method. For example, to return to windowed mode from fullscreen:

    window.set_fullscreen(False)

The previous window size and location, if any, will attempt to be restored, however the operating system does not always permit this, and the window may have relocated.