Programming an IcedApp¶
Overview¶
|
|
TODO |
|
A message generated through user interaction. |
|
|
|
Details¶
- class pyiced.IcedApp¶
- background_color()¶
Returns the background color of the application. Defaults to white.
- fullscreen()¶
True if the program should run in fullscreen mode.
The runtime will automatically transition your application if a new mode is returned.
- Return type
- new()¶
Initialize the application.
You can return
Commands
if you need to perform some async action in the background on startup. This is useful if you want to load state from a file, perform an initial HTTP request, etc.
- run(*, run=None)¶
Runs the application.
This method will take control of the current thread and will NOT return unless there is an error during startup.
It should probably be that last thing you call in your main function.
- scale_factor()¶
Returns the scale factor of the application.
It can be used to dynamically control the size of the UI at runtime (i.e. zooming).
For instance, a scale factor of 2.0 will make widgets twice as big, while a scale factor of 0.5 will shrink them to half their size.
- Return type
- property settings: Optional[pyiced.Settings]¶
The initial settings of the program.
Once queried once.
- should_exit()¶
Returns whether the application should be terminated.
This will kill the Python instance, too.
- Return type
- subscriptions()¶
Returns the event subscriptions for the current state of the application.
A subscription will be kept alive as long as you keep returning it, and the messages produced will be handled by update.
- title()¶
The current title of the application.
This title can be dynamic! The runtime will automatically update the title of your application when necessary.
- Return type
- class pyiced.Element¶
TODO
- class pyiced.Message¶
A message generated through user interaction.
Messages get passed to to
update()
.- alt¶
The alt key was pressed / released.
- Returns
True – Yes, the alt key was pressed or released.
False – No, the state of the alt key is unchanged.
None – Not a “keypress”, “keyrelease” or “modifierschanged” event.
- Return type
Optional[bool]
- amount¶
The scroll movement.
- Returns
The horizontal and vertical amount. The unit can be determined by inspecting
wheelscrolled
.None if not a scroll movement.
- Return type
- button¶
The button of a mouse event.
- characterreceived¶
A unicode character was received.
- Returns
The received, composed character. None if not a character event.
- Return type
Optional[str]
- control¶
The control key was pressed / released.
- Returns
True – Yes, the control key was pressed or released.
False – No, the state of the control key is unchanged.
None – Not a “keypress”, “keyrelease” or “modifierschanged” event.
- Return type
Optional[bool]
- cursormoved¶
The mouse cursor was moved
- file¶
The path of the hovering or dropped file.
- Returns
The path or none, if the Message is not a file action.
- Return type
Optional[pathlib.Path]
- finger¶
A unique identifier representing a finger on a touch interaction.
- Returns
Identifier of the finger.
- Return type
- key_code¶
The name of the pressed or released key.
See iced_native::keyboard::KeyCode for the name of the keys.
- Returns
The name of the key, or None if the not a key press or release.
- Return type
Optional[str]
- keyboard¶
The kind of the keyboard interaction.
- Returns
None if not a
Message(native="keyboard")
interaction”keypressed” when a key was pushed down
”keyreleased” when a key no more pushed down
”characterreceived” when a key press + release generated a character
”modifierschanged” when a modifier was pressed or released, e.g. shift
- Return type
Optional[str]
- kind¶
The kind of the native message.
- Returns
“mouse” for mouse interactions, e.g. mouse clicking
”window” for window interactions, e.g. resizing
”keyboard” for keyboard interactions, e.g. key presses
”touch” for touch interactions (impossible?)
- Return type
- logo¶
The “logo” key was pressed / released.
The logo key is the windows key, command key, etc.
- Returns
True – Yes, the “logo” key was pressed or released.
False – No, the state of the “logo” key is unchanged.
None – Not a “keypress”, “keyrelease” or “modifierschanged” event.
- Return type
Optional[bool]
- mouse¶
A mouse event.
- Returns
“cursorentered” – The mouse cursor entered the window.
”cursorleft” – The mouse cursor left the window.
”cursormoved” – The mouse cursor was moved
”buttonpressed” – A mouse button was pressed.
”buttonreleased” – A mouse button was released.
”wheelscrolled” – The mouse wheel was scrolled.
None – Not a mouse event.
- Return type
Optional[str]
- resized¶
The new size of the window.
- shift¶
The shift key was pressed / released.
- Returns
True – Yes, the shift key was pressed or released.
False – No, the state of the shift key is unchanged.
None – Not a “keypress”, “keyrelease” or “modifierschanged” event.
- Return type
Optional[bool]
- touch¶
A touch interaction.
- Returns
“fingerpressed” – A touch interaction was started.
”fingermoved” – An on-going touch interaction was moved.
”fingerlifted” – A touch interaction was ended.
”fingerlost” – A touch interaction was canceled.
None – Not a touch interaction.
- Return type
Optional[str]
- wheelscrolled¶
The unit of the scroll movement.
- Returns
“lines” – Counting in lines / columns.
”pixels” – Counting in pixels.
None – Not a scroll movement.
- Return type
Optional[str]
- window¶
The kind of the window message.
- Returns
“resized” – The window was resized.
”closerequested” – The window close button was clicked.
”focused” – The window was focus.
”unfocused” – The focus left the window.
”filehovered” – A file is hovering the window. A selection of multiple files cause multiple messages.
”filedropped” – A file was dropped on the window. A selection of multiple files cause multiple messages.
”fileshoveredleft” – The cursor the with hovering file(s) left the window.
None – Not a window message.
- Return type
Optional[str]
- class pyiced.Settings¶
- property antialiasing: bool¶
If set to true, the renderer will try to perform antialiasing for some primitives.
Enabling it can produce a smoother result in some widgets, like the Canvas, at a performance cost.
- Return type
- property default_font: Optional[pyiced.Font]¶
The font that will be used by default.
If None or Font.DEFAULT is provided, a default system font will be chosen.
- property exit_on_close_request: bool¶
Whether the
IcedApp
should exit when the user requests the window to close (e.g. the user presses the close button).- Return type
- property window: Optional[pyiced.WindowSettings]¶
The window settings.
- Return type
- class pyiced.WindowSettings¶
- property always_on_top: bool¶
Whether the window will always be on top of other windows.
- Return type
- property decorations: bool¶
Whether the window should have a border, a title bar, etc. or not.
- Return type