plesty.server.view.app

Open the console: Qt application, plesty-lib theme, our stylesheet, the window.

Attributes

UI_FONTS

MONO_FONTS

Classes

ConsoleGuard

The claim one console holds on its bench home.

Functions

pick_font(→ str)

The first of candidates the host has, else fallback — quoted for QSS.

installed_font(→ str)

The first of candidates the host has, as a bare family name; "" for none.

window_theme(→ dict[str, Any])

The console's palette, fonts and mark, for the update window (#29).

stylesheet(→ str)

The console stylesheet: assets/console.qss with the palette and fonts substituted.

mark_icon(→ PySide6.QtGui.QIcon)

The PLESTY mark (assets/plesty-mark.svg, the static version) as a window icon.

application(→ PySide6.QtWidgets.QApplication)

The running Qt application, created, themed and branded when there is none.

build_window(→ plesty.server.view.window.MainWindow)

A themed main window on bench (the application must exist).

claim_console(→ ConsoleGuard | None)

Become the one console of the bench home at root, or wake the one there is.

_socket_name(→ str)

The local socket of root's console: one per home, short enough for every OS.

ask_forward(→ bool)

Ask the console of the home at root to come forward; False when none answers.

_come_forward(→ None)

Show window in front, from minimised or behind other windows.

run_gui(→ int)

Open the console on bench and run until the window closes; returns the exit code.

_version(→ str)

Module Contents

plesty.server.view.app.UI_FONTS = ('Inter', 'SF Pro Text', 'Segoe UI', 'Helvetica Neue', 'Arial')
plesty.server.view.app.MONO_FONTS = ('SF Mono', 'Menlo', 'Consolas', 'DejaVu Sans Mono', 'Courier New')
plesty.server.view.app.pick_font(candidates: tuple[str, Ellipsis], fallback: str) → str

The first of candidates the host has, else fallback — quoted for QSS.

Asked rather than listed: Qt warns at start-up for every stylesheet family that is missing on the host, and the answer differs per bench.

Parameters:
  • candidates (tuple[str, Ellipsis])

  • fallback (str)

Return type:

str

plesty.server.view.app.installed_font(candidates: tuple[str, Ellipsis]) → str

The first of candidates the host has, as a bare family name; "" for none.

Parameters:

candidates (tuple[str, Ellipsis])

Return type:

str

plesty.server.view.app.window_theme(theme: plesty.lib.ui.theme.Theme | None, mark: pathlib.Path) → dict[str, Any]

The console’s palette, fonts and mark, for the update window (#29).

That window is not Qt — Qt lives in the environment the update replaces — so it is handed what to look like: the palette tokens, the two fonts by family name, and the PLESTY mark rendered to mark as a PNG, which Tk reads where it cannot read the SVG.

Parameters:
  • theme (plesty.lib.ui.theme.Theme | None)

  • mark (pathlib.Path)

Return type:

dict[str, Any]

plesty.server.view.app.stylesheet(theme: plesty.lib.ui.theme.Theme | None = None) → str

The console stylesheet: assets/console.qss with the palette and fonts substituted.

Parameters:

theme (plesty.lib.ui.theme.Theme | None)

Return type:

str

plesty.server.view.app.mark_icon() → PySide6.QtGui.QIcon

The PLESTY mark (assets/plesty-mark.svg, the static version) as a window icon.

Return type:

PySide6.QtGui.QIcon

plesty.server.view.app.application() → PySide6.QtWidgets.QApplication

The running Qt application, created, themed and branded when there is none.

Return type:

PySide6.QtWidgets.QApplication

plesty.server.view.app.build_window(bench: plesty.server.presenter.Bench, title: str | None = None) → plesty.server.view.window.MainWindow

A themed main window on bench (the application must exist).

Parameters:
Return type:

plesty.server.view.window.MainWindow

class plesty.server.view.app.ConsoleGuard(lock: PySide6.QtCore.QLockFile, server: PySide6.QtNetwork.QLocalServer)

The claim one console holds on its bench home.

Two consoles on one home share its jobs, runs and remembered fleet, and each acts on a state the other changes underneath it: a second copy, started by clicking the shortcut again while the first sat minimised, rewrote the remembered fleet and left the run table of both out of date (#28). So a home has one console. A lock file says which, and the holder listens on a local socket, so a second launch can bring its window forward instead of opening another.

Hold lock on the home and answer bring-forward requests on server.

Parameters:
  • lock (PySide6.QtCore.QLockFile)

  • server (PySide6.QtNetwork.QLocalServer)

_lock
server
on_raise(callback: collections.abc.Callable[[], None]) → None

Call callback whenever another launch asks this console to come forward.

Parameters:

callback (collections.abc.Callable[[], None])

Return type:

None

release() → None

Give the home up: the lock and the socket.

Return type:

None

plesty.server.view.app.claim_console(root: pathlib.Path) → ConsoleGuard | None

Become the one console of the bench home at root, or wake the one there is.

Parameters:

root (pathlib.Path) – The bench home.

Returns:

The guard to keep for as long as the console is open, or None when another console holds the home.

Return type:

ConsoleGuard | None

plesty.server.view.app._socket_name(root: pathlib.Path) → str

The local socket of root’s console: one per home, short enough for every OS.

Parameters:

root (pathlib.Path)

Return type:

str

plesty.server.view.app.ask_forward(root: pathlib.Path) → bool

Ask the console of the home at root to come forward; False when none answers.

Parameters:

root (pathlib.Path)

Return type:

bool

plesty.server.view.app._come_forward(window: plesty.server.view.window.MainWindow) → None

Show window in front, from minimised or behind other windows.

Parameters:

window (plesty.server.view.window.MainWindow)

Return type:

None

plesty.server.view.app.run_gui(bench: plesty.server.presenter.Bench, title: str | None = None) → int

Open the console on bench and run until the window closes; returns the exit code.

A home that already has a console open is not given a second one: that console is brought forward instead, and this launch ends.

Parameters:
Return type:

int

plesty.server.view.app._version() → str
Return type:

str