panda3d.core.GraphicsWindow

class GraphicsWindow

Bases: GraphicsOutput

A window, fullscreen or on a desktop, into which a graphics device sends its output for interactive display.

Inheritance diagram

Inheritance diagram of GraphicsWindow

getProperties() → WindowProperties

Returns the current properties of the window.

Return type

WindowProperties

getRequestedProperties() → WindowProperties

Returns the properties of the window that are currently requested. These properties will be applied to the window (if valid) at the next execution of process_events().

Return type

WindowProperties

clearRejectedProperties() → None

Empties the set of failed properties that will be returned by getRejectedProperties().

getRejectedProperties() → WindowProperties

Returns the set of properties that have recently been requested, but could not be applied to the window for some reason. This set of properties will remain unchanged until they are changed by a new failed request, or clearRejectedProperties() is called.

Return type

WindowProperties

requestProperties(requested_properties: WindowProperties) → None

Requests a property change on the window. For example, use this method to request a window change size or minimize or something.

The change is not made immediately; rather, the request is saved and will be applied the next time the window task is run (probably at the next frame).

isClosed() → bool

Returns true if the window has not yet been opened, or has been fully closed, false if it is open. The window is not opened immediately after GraphicsEngine::make_window() is called; nor is it closed immediately after GraphicsEngine.removeWindow() is called. Either operation may take a frame or two.

isFullscreen() → bool

Returns true if the window has been opened as a fullscreen window, false otherwise.

setWindowEvent(window_event: str) → None

Changes the name of the event that is generated when this window is modified externally, e.g. to be resized or closed by the user.

By default, all windows have the same window event unless they are explicitly changed. When the event is generated, it includes one parameter: the window itself.

getWindowEvent() → str

Returns the name of the event that is generated when this window is modified externally, e.g. to be resized or closed by the user. See setWindowEvent().

setCloseRequestEvent(close_request_event: str) → None

Sets the event that is triggered when the user requests to close the window, e.g. via alt-F4, or clicking on the close box.

The default for each window is for this event to be the empty string, which means the window-close request is handled immediately by Panda (and the window will be closed without the app getting a chance to intervene). If you set this to a nonempty string, then the window is not closed, but instead the event is thrown. It is then up to the app to respond appropriately, for instance by presenting an “are you sure?” dialog box, and eventually calling close_window() when the user is sure.

It is considered poor form to set this string and then not handle the event. This can frustrate the user by making it difficult for him to cleanly shut down the application (and may force the user to hard-kill the app, or reboot the machine).

getCloseRequestEvent() → str

Returns the name of the event set via setCloseRequestEvent(). If this string is nonempty, then when the user requests to close window, this event will be generated instead. See setCloseRequestEvent().

setUnexposedDraw(unexposed_draw: bool) → None

If this flag is false, the window is redrawn only after it has received a recent “unexpose” or “draw” event from the underlying windowing systme. If this flag is true, the window is redrawn every frame regardless. Setting this false may prevent the window from redrawing unnecessarily when it is hidden, and may play nicer with other windows on the desktop, but may adversely affect frame rate even when the window is fully visible; setting it true will ensure that the window contents are always current.

getUnexposedDraw() → bool

See setUnexposedDraw().

getWindowHandle() → WindowHandle

Returns the WindowHandle corresponding to this window on the desktop. This is mainly useful for communicating with external libraries. Use window_handle->get_os_handle()->get_handle(), or window_handle->get_string_handle(), to get the actual OS-specific window handle object, whatever type that might be.

Return type

WindowHandle

getNumInputDevices() → int

Returns the number of separate input devices associated with the window. Typically, a window will have exactly one input device: the keyboard/mouse pair. However, some windows may have no input devices, and others may add additional devices, for instance for a joystick.

getInputDevice(i: int) → InputDevice

Returns the nth input device associated with the window. Typically, a window will have exactly one input device: the keyboard/mouse pair.

Return type

InputDevice

getInputDeviceName(device: int) → str

Returns the name of the nth input device.

hasPointer(device: int) → bool

Returns true if the nth input device has a screen-space pointer (for instance, a mouse), false otherwise.

hasKeyboard(device: int) → bool

Returns true if the nth input device has a keyboard, false otherwise.

getKeyboardMap() → ButtonMap

Returns a ButtonMap containing the association between raw buttons and virtual buttons.

Return type

ButtonMap

enablePointerEvents(device: int) → None

Turn on the generation of pointer events.

disablePointerEvents(device: int) → None

Turn off the generation of pointer events.

getPointer(device: int) → MouseData

Returns the MouseData associated with the nth input device’s pointer. This is deprecated; use get_pointer_device().:meth:~GraphicsWindow.getPointer instead, or for raw mice, use the InputDeviceManager interface.

Return type

MouseData

movePointer(device: int, x: int, y: int) → bool

Forces the pointer to the indicated position within the window, if possible.

Returns true if successful, false on failure. This may fail if the mouse is not currently within the window, or if the API doesn’t support this operation.

closeIme() → None

Forces the ime window to close if any

static getClassType() → TypeHandle
Return type

TypeHandle

getInputDevices() → list
getInputDeviceNames() → list
property properties

Returns the current properties of the window.

Return type

WindowProperties

property requested_properties

Returns the properties of the window that are currently requested. These properties will be applied to the window (if valid) at the next execution of process_events().

Return type

WindowProperties

property rejected_properties

Returns the set of properties that have recently been requested, but could not be applied to the window for some reason. This set of properties will remain unchanged until they are changed by a new failed request, or clearRejectedProperties() is called.

Return type

WindowProperties

property closed

Returns true if the window has not yet been opened, or has been fully closed, false if it is open. The window is not opened immediately after GraphicsEngine::make_window() is called; nor is it closed immediately after GraphicsEngine.removeWindow() is called. Either operation may take a frame or two.

Return type

bool

property window_event
Getter

Returns the name of the event that is generated when this window is modified externally, e.g. to be resized or closed by the user. See setWindowEvent().

Setter

Changes the name of the event that is generated when this window is modified externally, e.g. to be resized or closed by the user.

By default, all windows have the same window event unless they are explicitly changed. When the event is generated, it includes one parameter: the window itself.

Return type

string

property close_request_event
Getter

Returns the name of the event set via setCloseRequestEvent(). If this string is nonempty, then when the user requests to close window, this event will be generated instead. See setCloseRequestEvent().

Setter

Sets the event that is triggered when the user requests to close the window, e.g. via alt-F4, or clicking on the close box.

The default for each window is for this event to be the empty string, which means the window-close request is handled immediately by Panda (and the window will be closed without the app getting a chance to intervene). If you set this to a nonempty string, then the window is not closed, but instead the event is thrown. It is then up to the app to respond appropriately, for instance by presenting an “are you sure?” dialog box, and eventually calling close_window() when the user is sure.

It is considered poor form to set this string and then not handle the event. This can frustrate the user by making it difficult for him to cleanly shut down the application (and may force the user to hard-kill the app, or reboot the machine).

Return type

string

property unexposed_draw
Getter

See setUnexposedDraw().

Setter

If this flag is false, the window is redrawn only after it has received a recent “unexpose” or “draw” event from the underlying windowing systme. If this flag is true, the window is redrawn every frame regardless. Setting this false may prevent the window from redrawing unnecessarily when it is hidden, and may play nicer with other windows on the desktop, but may adversely affect frame rate even when the window is fully visible; setting it true will ensure that the window contents are always current.

Return type

bool

property window_handle

Returns the WindowHandle corresponding to this window on the desktop. This is mainly useful for communicating with external libraries. Use window_handle->get_os_handle()->get_handle(), or window_handle->get_string_handle(), to get the actual OS-specific window handle object, whatever type that might be.

Return type

WindowHandle