Window reference¶
Bases: Widget
id
property
writable
¶
The ID of this node.
This property is overridden from DOMnode because id
cannot be none in the Window class.
maximize_state = reactive(False, init=False)
class-attribute
instance-attribute
¶
The maximize state of the window. You can modify this directly if you wish.
name
property
¶
The name of the node.
This property is overridden from DOMnode because name
cannot be none in the Window class.
open_state = reactive(False, init=False)
class-attribute
instance-attribute
¶
The open/minimized state of the window. You can modify this directly if you wish.
Note that this does not remove the window from the DOM or the window bar/manager. You
must use remove_window()
or close_window
to do that.
snap_state = reactive(True, init=False)
class-attribute
instance-attribute
¶
The lock state (snap to parent) of the window. You can modify this directly if you wish.
Closed
¶
Bases: WindowMessage
Message sent when the window is closed.
Initialized
¶
Bases: WindowMessage
Message sent when the window is completed initialization.
Minimized
¶
Bases: WindowMessage
Message sent when the window is minimized.
Opened
¶
Bases: WindowMessage
Message sent when the window is opened.
__init__(*children, id, mode='temporary', icon=None, classes=None, name=None, starting_horizontal='center', starting_vertical='middle', start_open=False, start_snapped=True, allow_resize=True, allow_maximize=False, menu_options=None, animated=True, show_title=True, disabled=False)
¶
Initialize a window widget.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*children
|
Widget
|
Child widgets. |
()
|
id
|
str
|
The ID of the window - Used for the window's title bar, the WindowBar, and the
WindowSwitcher. |
required |
mode
|
MODE
|
This controls whether the widget should be removable, or a permanent fixture of your app. In temporary mode, the close button will remove the window from the DOM as well as the window bar and manager (like a normal desktop would). Ctrl-w behavior in this mode is to remove the window. In permanent mode, the close button is removed from the window and windowbar menus, the window is only able to be minimized, and Ctrl-w behavior is to minimize the window. (minimize and close will do the same thing in this mode). |
'temporary'
|
icon
|
str | None
|
The icon for the window to use in the title bar and window bar. |
None
|
classes
|
str | None
|
The CSS classes for the widget. |
None
|
name
|
str | None
|
The name of the window. If you wish for the display name to be different than the ID for some reason, you can set this to whatever display name you'd like. |
None
|
starting_horizontal
|
STARTING_HORIZONTAL
|
The starting horizontal position of the window. |
'center'
|
starting_vertical
|
STARTING_VERTICAL
|
The starting vertical position of the window. |
'middle'
|
start_open
|
bool
|
Whether the window should start open or closed. |
False
|
start_snapped
|
bool
|
Whether the window should start snapped (locked) within the parent area. |
True
|
allow_resize
|
bool
|
Whether the window should be resizable. |
True
|
allow_maximize
|
bool
|
Whether to show the maximize button on the top bar. |
False
|
menu_options
|
dict[str, Callable[..., Optional[Any]]] | None
|
A dictionary of options to show in a hamburger menu. The hamburger menu will be shown automatically if you pass in any options. The key is the name of the option as it will be displayed in the menu. The value is a callable that will be called when the option is selected. ! add note about functools partial?¶ |
None
|
animated
|
bool
|
Whether the window should be animated.
This will add a fade in/out effect when opening/closing the window. You can modify
the |
True
|
show_title
|
bool
|
Whether to show the title bar or not. |
True
|
disabled
|
bool
|
Whether the widget is disabled or not. |
False
|
bring_forward()
¶
This is called automatically when the window is opened, as long as
auto_bring_forward
is set to True on the window. If you want manual control,
you can set that to False and call this method yourself.
clamp_into_parent_area()
¶
This function returns the widget into its parent area.
There shouldn't be any need to call this manually, but it is here if you need it.
close_window()
¶
Alias for remove_window. (You may be looking for Window.minimize
).
This will remove the window from the DOM and the Window Bar.
disable_snap()
¶
Disable window locking (set snap_state to False)
enable_snap()
¶
Enable window locking (set snap_state to True)
maximize()
¶
Resize the window to its maximum.
minimize()
¶
This will close the window, but not remove it from the DOM. Runs the close animatiom and blurs all children.
mount_all_in_window(widgets, *, before=None, after=None)
¶
Mount widgets from an iterable into the Window.
Do not use mount
or mount_all
to mount widgets inside of the window.
Use this (or mount_in_window
) instead.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
widgets
|
Iterable[Widget]
|
An iterable of widgets. |
required |
before
|
int | str | Widget | None
|
Optional location to mount before. An |
None
|
after
|
int | str | Widget | None
|
Optional location to mount after. An |
None
|
Returns:
Type | Description |
---|---|
AwaitMount
|
An awaitable object that waits for widgets to be mounted. |
Raises:
Type | Description |
---|---|
MountError
|
If there is a problem with the mount request. |
Note
Only one of before
or after
can be provided. If both are
provided a MountError
will be raised.
mount_in_window(*widgets, before=None, after=None)
¶
Mount widgets inside of the window.
Do not use mount
or mount_all
to mount widgets inside of the window.
Use this (or mount_all_in_window
) instead.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*widgets
|
Widget
|
The widget(s) to mount. |
()
|
before
|
int | str | Widget | None
|
Optional location to mount before. An |
None
|
after
|
int | str | Widget | None
|
Optional location to mount after. An |
None
|
Returns:
Type | Description |
---|---|
AwaitMount
|
An awaitable object that waits for widgets to be mounted. |
Raises:
Type | Description |
---|---|
MountError
|
If there is a problem with the mount request. |
Note
Only one of before
or after
can be provided. If both are
provided a MountError
will be raised.
open_window()
¶
Runs the open animation (if animate=True), and brings the window forward
(if auto_bring_forward
is set to True on the window).
remove_children_in_window(selector='*')
¶
Remove the widgets inside of this window from the DOM.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
selector
|
str | type[QueryType] | Iterable[Widget]
|
A CSS selector or iterable of widgets to remove. |
'*'
|
Returns:
Type | Description |
---|---|
AwaitRemove
|
An awaitable object that waits for the widgets to be removed. |
remove_window()
¶
This will remove the window from the DOM and the Window Bar.
reset_position()
async
¶
Reset the window position to its starting position.
reset_size()
async
¶
Reset the window size to its starting size.
reset_window()
async
¶
Reset the window to its starting position and size.
restore()
¶
(Opposite of maximize) Restore the window to its previous size and position.
toggle_lock()
¶
Alias for toggle_snap(). Toggle the window snap (lock) state.
toggle_maximize()
¶
Toggle the window between its maximum size and its previous size.
toggle_snap()
¶
Toggle the window snap (lock) state.
toggle_window()
¶
Toggle the window open and closed.