Karana.WebUI#
Classes and modules related to Web UI.
Submodules#
Attributes#
Classes#
Use this in conjunction with setSizeClass to set a widget's size. |
|
Widget displaying a Slider triggering a server-side callback |
|
Package Contents#
- class Karana.WebUI.Accordion(router: Router, summary: str = '', on_toggle: collections.abc.Callable[[bool], None] = None, exclusive_tag: str = '', open_state: State = None)#
Bases:
Widget
- class Karana.WebUI.Button(router: Router, text: str, on_press: collections.abc.Callable[[], None], tooltip: str = '')#
Bases:
Widget
- class Karana.WebUI.Channel#
-
- defer(callback: collections.abc.Callable[[], None]) None#
- setOnConnect(callback: collections.abc.Callable[[SupportsInt | SupportsIndex], None]) None#
- setOnDisconnect(callback: collections.abc.Callable[[SupportsInt | SupportsIndex], None]) None#
- setOnMessage(callback: collections.abc.Callable[[str, SupportsInt | SupportsIndex], None]) None#
- class Karana.WebUI.ClientApp(url: str, extra_args: collections.abc.Sequence[str] = [])#
- static findExecutable() pathlib.Path | None#
- class Karana.WebUI.ContentSource#
- class Karana.WebUI.Dock(router: Router, style: collections.abc.Mapping[str, str] = {})#
Bases:
Widget
- class Karana.WebUI.Dropdown(router: Router, text: str, choices: collections.abc.Sequence[str], on_change: collections.abc.Callable[[SupportsInt | SupportsIndex], None] = None, value_state: State = None)#
Bases:
Widget
- class Karana.WebUI.FloatInput(router: Router, text: str, tooltip: str = '', on_change: collections.abc.Callable[[SupportsFloat | SupportsIndex], None] = None, rapid_submit: bool = False, value_state: State = None)#
Bases:
Widget- setMax(max: SupportsFloat | SupportsIndex) None#
Set the max value of the slider
- Parameters:
max – The upper bound on possible values
- setMin(min: SupportsFloat | SupportsIndex) None#
Set the min value of the slider
- Parameters:
min – The lower bound on possible values
- setStep(step: SupportsFloat | SupportsIndex) None#
Set the step size of the slider
- Parameters:
step – The step size of values on the slider
- setValue(value: SupportsFloat | SupportsIndex, trigger_own_callback: bool = False) None#
Set the current value of the input field; performs type checking internally and prints a warning on mismatch.
- Parameters:
value – The value of the input field
trigger_own_callback – Whether to invoke the on_change callback
- class Karana.WebUI.HttpWsServer(port: SupportsInt | SupportsIndex, display_name: str = 'Web server')#
-
- defer(callback: collections.abc.Callable[[], None]) None#
- sendMessage(msg: bytes, client_id: SupportsInt | SupportsIndex) None#
Send binary data to a specific client.
- serveCasData(content: str, url_prefix: str = '', headers: collections.abc.Sequence[tuple[str, str]] = []) str#
- serveCasFile(path: os.PathLike | str | bytes, url_prefix: str = '', headers: collections.abc.Sequence[tuple[str, str]] = []) str#
- serveFile(url: str, path: os.PathLike | str | bytes, headers: collections.abc.Sequence[tuple[str, str]] = []) None#
- setOnConnect(callback: collections.abc.Callable[[SupportsInt | SupportsIndex], None]) None#
- setOnDisconnect(callback: collections.abc.Callable[[SupportsInt | SupportsIndex], None]) None#
- setOnError(callback: collections.abc.Callable[[str], None]) None#
- setOnMessage(callback: collections.abc.Callable[[str, SupportsInt | SupportsIndex], None]) None#
- waitForClients(clients: SupportsInt | SupportsIndex = 1, timeout: SupportsFloat | SupportsIndex = 0.0) bool#
Wait for a given number of clients to connect.
- Parameters:
clients –
Number of clients to wait for
timeout_seconds –
Timeout, if positive
- Returns:
True if the requested client count was reached
- class Karana.WebUI.InputGroup(router: Router, title: str = '', style: collections.abc.Mapping[str, str] = {})#
Bases:
Widget
- class Karana.WebUI.IntInput(router: Router, text: str, tooltip: str = '', on_change: collections.abc.Callable[[SupportsInt | SupportsIndex], None] = None, rapid_submit: bool = False, value_state: State = None)#
Bases:
Widget- setMax(max: SupportsInt | SupportsIndex) None#
Set the max value of the slider
- Parameters:
max – The upper bound on possible values
- setMin(min: SupportsInt | SupportsIndex) None#
Set the min value of the slider
- Parameters:
min – The lower bound on possible values
- setStep(step: SupportsInt | SupportsIndex) None#
Set the step size of the slider
- Parameters:
step – The step size of values on the slider
- setValue(value: SupportsInt | SupportsIndex, trigger_own_callback: bool = False) None#
Set the current value of the input field; performs type checking internally and prints a warning on mismatch.
- Parameters:
value – The value of the input field
trigger_own_callback – Whether to invoke the on_change callback
- class Karana.WebUI.Layout(router: Router, style: collections.abc.Mapping[str, str] = {})#
Bases:
Widget
- class Karana.WebUI.QuantityInput(router: Router, text: str, on_change: collections.abc.Callable[[SupportsFloat | SupportsIndex, str], None] = None, quantity_state: State = None)#
Bases:
Widget
- class Karana.WebUI.Router(server: HttpWsServer)#
- class Karana.WebUI.Selection(items: collections.abc.Sequence[Selection] = [])#
- class Item(id: SupportsInt | SupportsIndex, context: Karana.WebUI.Json = None)#
- context: Karana.WebUI.Json#
- dump() Karana.WebUI.Json#
- class Karana.WebUI.Server(port: SupportsInt | SupportsIndex = 8765)#
- static canFindLocalClientExecutable() bool#
Check if the client executable can be found….
- Returns:
Whether the client executable can be found
- guessUrl() str#
Generate a URL to connect to the sever.
Note that this URL is a best guess from the point of view of the server. It may not reflect the publicly accessible URL for the server.
- Returns:
The URL guess
- launchLocalClient(*, silent: bool = True) None#
Spawn a managed electron client as a subprocess.
- Parameters:
options –
Parameters struct for the local client.
- class Karana.WebUI.SizeClass(*args, **kwds)#
Bases:
enum.EnumUse this in conjunction with setSizeClass to set a widget’s size. The actual behavior is defined by CSS
- class Karana.WebUI.Slider(router: Router, text: str, on_change: collections.abc.Callable[[SupportsFloat | SupportsIndex], None] = None, opts: SliderOptions = None, value_state: State = None)#
Bases:
Widget- setMax(max: SupportsFloat | SupportsIndex) None#
Set the max value of the slider
- Parameters:
max – The upper bound on possible values
- setMin(min: SupportsFloat | SupportsIndex) None#
Set the min value of the slider
- Parameters:
min – The lower bound on possible values
- class Karana.WebUI.SliderOptions#
Widget displaying a Slider triggering a server-side callback
- class Karana.WebUI.State(router: Router, init_value: Karana.WebUI.Json = None, sync: bool = True)#
-
- get() Karana.WebUI.Json#
- onChange(on_change: collections.abc.Callable[[Karana.WebUI.Json], None]) int#
- setValidator(validator: collections.abc.Callable[[Karana.WebUI.Json], None]) None#
- class Karana.WebUI.StringInput(router: Router, text: str, tooltip: str = '', on_change: collections.abc.Callable[[str], None] = None, rapid_submit: bool = False, value_state: State = None)#
Bases:
Widget
- class Karana.WebUI.Toggle(router: Router, text: str, on_toggle: collections.abc.Callable[[bool], None], tooltip: str = '', render_as_button: bool = False, toggle_state: State = None)#
Bases:
Widget
- class Karana.WebUI.TreeView(router: Router, nodes: collections.abc.Sequence[TreeView] = [], edges: collections.abc.Sequence[TreeView] = [], on_select: collections.abc.Callable[[Selection], None] = None, on_refresh: collections.abc.Callable[[], None] = None, selection: State = None)#
Bases:
Widget- class Edge(parent_id: SupportsInt | SupportsIndex, child_id: SupportsInt | SupportsIndex)#
- class Node(id: SupportsInt | SupportsIndex, label: str = 'unnamed', style_class: str = '', tooltip: str = '', collapsed: bool = False)#
- refresh() None#
Forces a refresh of the TreeView via its on_refresh() callback, if any was set.
Do not call this from the on_refresh callback itself, since that would create a cycle.
- setTree(nodes: collections.abc.Sequence[TreeView], edges: collections.abc.Sequence[TreeView]) None#
- class Karana.WebUI.Widget(router: Router, esm: Any = '', css: Any = '', states: collections.abc.Mapping[str, State] = {}, style: collections.abc.Mapping[str, str] = {}, init_msg: str = '')#