template¶
classDiagram
SupportState <|-- LineSupportState
SupportState <|-- ShapeSupportState
SupportState <|-- TextSupportState
SupportState <|-- TextureSupportState
SupportState <|-- WindowBackdropSupportState
SupportState <|-- WindowSupportState
WhateverBase <|-- LineBase
WhateverBase <|-- WindowBase
Template backend, identified as nobackend in Charmy runtime.
This is a template of all backends, providing basic fallback for functions that might be used but not implemented by actual backends. This template backend shall not be used in actual development.
This backend is identified as nobackend in Charmy, and will throw an error when trying to create window with it.
- class charmy.backend.template.Backend¶
基类:
objectThis is a template of Backend, does not have any actual function.
- name: str = 'nobackend'¶
- friendly_name: str = 'No available backend'¶
- version: str = '0.0.0'¶
- author: list[str] = ['Charmy dev team']¶
- class WindowBase(backend: Backend, charmy_window: window.WindowEntity)¶
基类:
WhateverBaseBase of the windows, abstracts window-level operations from the base UI lib.
- __init__(backend: Backend, charmy_window: window.WindowEntity) None¶
Initializes the dummy window.
- 参数:
backend -- The backend that this window uses
- clear_screen() Self¶
To clear all content from a window
- close() Self¶
- draw_background() Self¶
Draw the background of the window.
This is a fallback of such function, draws a rect that fills the window.
- Return self:
The WindowBase itself
- hide() Self¶
Hides the window, does nothing on a dummy window.
- set_icon(new: bytes) Self¶
Set title to window, does nothing on dummy.
- set_pos(new: tuple[int, int]) Self¶
Set window size, does nothing on dummy.
- set_size(new: tuple[int, int]) Self¶
Set window size, does nothing on dummy.
- set_title(new: str) Self¶
Set title to window, does nothing on dummy.
- show() Self¶
Shows the window, does nothing on dummy window.
- supports: WindowSupportState = <charmy.backend.template.WindowSupportState object>¶
- update(redraw: bool | tuple[tuple[int, int], tuple[int, int]] = True) Self¶
Updates the window, although not supported in nobackend and will throw an error
- title: str¶
- icon: bytearray | None¶
- pos: charmy_stuff.styles.shape.Size¶
- size: charmy_stuff.styles.shape.Size¶
- scale_mode: str¶
- background: charmy_stuff.styles.texture.Texture | charmy_stuff.styles.texture.TextureLike¶
- alpha: float¶
- state: str¶
- fullscreen: bool¶
- charmy_window: window.WindowEntity¶
- class LineBase(*args, **kwargs)¶
基类:
WhateverBaseSet of lines-relating APIs
- __init__(*args, **kwargs)¶
Not supposed to be instantiated.
- static draw_line(line: DrawnLine, *args, **kwargs)¶
To draw a line on a specific GUI or canvas.
- Args:
line: The line to be drawn window: The WindowBase to draw line
- supports: LineSupportState = <charmy.backend.template.LineSupportState object>¶
- class ShapeBase(*args, **kwargs)¶
基类:
objectSet of shape-relating APIs
- __init__(*args, **kwargs)¶
Not supposed to be instantiated.
- static draw_shape(shape: DrawnShape, *args, **kwargs)¶
To draw a shape on a specific GUI or canvas.
- 参数:
shape -- The shape to be drawn
window -- The WindowBase to draw shape
- supports: ShapeSupportState = <charmy.backend.template.ShapeSupportState object>¶
- class TextureBase¶
基类:
objectSet of texture-relating APIs
- __init__()¶
Not supposed to be instantiated.
- supports: TextureSupportState = <charmy.backend.template.TextureSupportState object>¶
- class TextBase¶
基类:
objectSet of text-relating APIs.
- __init__()¶
Not supported to be instantiated.
- static draw_text(drawn_text: DrawnText, *args, **kwargs)¶
To draw a line or paragraph of text on a specific GUI or canvas.
- static get_text_bound(drawn_text: DrawnText, *args, **kwargs)¶
To get the text's boundary when it is rendered by a specific backend.
- supports: TextSupportState = <charmy.backend.template.TextSupportState object>¶
- __init__()¶
Initialize a backend
- backend_init() None¶
- charmy.backend.template.not_implemented_func(backend_name: str = 'currently used', operation_desc: str = 'This operation', **kwargs) bool¶
To throw a warning to tell that a specific function is not implemented by the backend.
The parameters only affects the warning message.
- 参数:
backend_name -- Friendly name of the backend
operation_desc -- Description of the operation