edifice.Window#
- class edifice.Window(title='Edifice Application', icon=None, menu=None, _on_open=None, on_close=None, on_window_state_change=None, full_screen=False, _size_open=None, **kwargs)[source]#
Bases:
VBoxView
The root
View
element of anApp
which runs in an operating system window.The children of this
Window
are the visible Elements of theApp
. When thisWindow
closes, all of the children are unmounted and then theApp
stops.Props
All props from
QtWidgetElement
plus:- Parameters:
title (
str
) – The window title.icon (
Union
[str
,QImage
,QPixmap
,None
]) –The window icon image.
See caveats in windowIcon. This prop is not supported on all platforms.
menu – The window’s menu bar. In some GUI settings, for example Mac OS, this menu will appear seperately from the window.
_on_open (
Optional
[Callable
[[QApplication
],None
]]) –This argument is not a prop and will not cause re-render when changed.
Event handler for when this window is opening. This event handler function will be called exactly once, before the children are mounted.
The event handler function will be passed the application’s QApplication object.
on_close (
Optional
[Callable
[[QCloseEvent
],Optional
[Awaitable
[None
]]]]) –Event handler for when this window is closing. This event handler will fire before the children are unmounted.
The event handler function will be passed a QCloseEvent.
on_window_state_change (
Optional
[Callable
[[Literal
['Normal'
,'Maximized'
,'Minimized'
,'FullScreen'
],Literal
['Normal'
,'Maximized'
,'Minimized'
,'FullScreen'
]],Optional
[Awaitable
[None
]]]]) –Event handler for when the window state changes.
This event handler will be passed the old window state and the new window state.
full_screen (
bool
) – Whether the window is in full screen mode._size_open (
Union
[tuple
[int
,int
],Literal
['Maximized'
],None
]) –This argument is not a prop and will not cause re-render when changed.
It will only be used once to set width and height of the window when it is opened.
If the value
"Maximized"
is passed, the window will be opened maximized (does not work on X11, see showMaximized ).
Usage
@component def Main(self): full_screen, full_screen_set = use_state(False) def handle_key_down(event: PySide6.QtGui.QKeyEvent): if event.key() == PySide6.QtGui.Qt.Key.Key_F11: full_screen_set(not full_screen) with Window( title="Full Screen Example", _size_open=(800, 600), full_screen=full_screen, on_key_down=handle_key_down, ): Label("Press F11 to toggle full screen mode")
Methods
__init__
([title, icon, menu, _on_open, ...])register_ref
(reference)Registers provided
Reference
to this Element.set_key
(key)Set the key of an
Element
.Attributes
children
The children of this Element.
props
The props of this Element.
underlying
The underlying QWidget, which may not exist if this Element has not rendered.