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.Dock(router: Router)#
addChild(title: str, dom_id: str, relative_to: str | None = None, direction: str | None = None) → 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.

serveData(url: str, content: str, content_type: str = 'application/octet-stream') → None#
serveFile(url: str, path: os.PathLike | str | bytes, content_type: 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)#
domId() → str#
class Karana.WebUI.Router(arg0: HttpWsServer)#
channel(esm: str) → Channel#
channel(esm: os.PathLike | str | bytes) → 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