Karana.WebUI#

Classes and modules related to Web UI.

Submodules#

Classes#

Package Contents#

class Karana.WebUI.Channel#
broadcastMessage(msg: str) None#
defer(callback: collections.abc.Callable[[], None]) None#
sendMessage(msg: str, client_id: SupportsInt) None#
setOnConnect(callback: collections.abc.Callable[[SupportsInt], None]) None#
setOnDisconnect(callback: collections.abc.Callable[[SupportsInt], None]) None#
setOnMessage(callback: collections.abc.Callable[[str, SupportsInt], None]) None#
sync() None#
uuid() str#
class Karana.WebUI.ClientApp(url: str)#
static findExecutable() pathlib.Path | None#
getStderr() str#
getStdout() str#
shutdown() None#
class Karana.WebUI.ContentSource#
class Karana.WebUI.Dock(router: Router)#
addChild(title: str, widget: Widget) None#
addChild(title: str, widget: Widget, relative_to: Widget, direction: str = '') None
class Karana.WebUI.HttpWsServer(port: SupportsInt)#
broadcastMessage(msg: bytes) None#

Broadcast binary data to all clients.

close() None#
defer(callback: collections.abc.Callable) None#
getPort() int#
getUrl() str#
printConnectionInfo() None#

Print info to stdout about how to connect

sendMessage(msg: bytes, client_id: SupportsInt) 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#
serveData(url: str, content: str, headers: collections.abc.Sequence[tuple[str, str]] = []) None#
serveFile(url: str, path: os.PathLike | str | bytes, headers: collections.abc.Sequence[tuple[str, str]] = []) None#
setOnConnect(callback: collections.abc.Callable) None#
setOnDisconnect(callback: collections.abc.Callable) None#
setOnMessage(callback: collections.abc.Callable) None#
sync() None#
waitForClients(clients: SupportsInt = 1, timeout: SupportsFloat = 0.0) bool#

Wait for a given number of clients to connect. :param clients:

  • Number of clients to wait for

Parameters:

timeout_seconds

  • Timeout, if positive

Returns:

True if the requested client count was reached

class Karana.WebUI.IFrame(router: Router, url: str)#

Bases: Widget

class Karana.WebUI.Markdown(router: Router, text: str)#

Bases: Widget

setText(text: str) None#
class Karana.WebUI.Router(arg0: HttpWsServer)#
channel(esm: Any, css: Any = '', init_msg: str = '') Channel#
class Karana.WebUI.Server(port: SupportsInt = 8765)#
static canFindLocalClientExecutable() bool#

Check if the client executable can be found…. :returns: Whether the client executable can be found

closeLocalClients() None#

Close all managed clients.

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. :param options:

  • Parameters struct for the local client.

onThread() bool#

Check whether the current thread is the io thread :returns: Whether the current thread is the io thread

port() int#

Get the port the server is bound to. :returns: The port number.

printConnectionInfo() None#

Print info to stdout about how to connect

sync() None#

Wait for currently queued tasks to complete

waitForClients(clients: SupportsInt = 1, timeout_seconds: SupportsFloat = 0.0) None#

Wait for a given number of clients to connect. :param clients:

  • Number of clients to wait for.

Parameters:

timeout

  • Timeout in seconds, if positive

class Karana.WebUI.TreeView(router: Router, nodes: collections.abc.Sequence[TreeView], on_select: collections.abc.Callable[[SupportsInt], None] = None)#

Bases: Widget

class Node(id: SupportsInt, label: str = 'unnamed', parent: SupportsInt | None = None)#
label: str#
property id: int#
property parent: int | None#
select(id: SupportsInt) None#
class Karana.WebUI.Widget(channel: Channel)#
channel() Channel#
domId() str#