qcc_kplugin.dialogs

Dialogs that fit the screen.

A long dialog (route options, a component’s parameters, Simulate) used to grow past the bottom of the screen, with its OK button out of reach and no way to scroll or shrink it. Here:

  • Rows collects form rows like QFormLayout.addRow does, in sections, and lays them out in one column, or in two when one column would be taller than the screen allows (Settings ▸ “Long dialogs in two columns”).

  • fit() puts a dialog’s body in a scroll area with the buttons below it (always visible), makes the dialog resizable (a size grip) and sizes it to its content, but never wider or taller than the free screen area.

  • fit_window() caps a non-modal window (results text, the circuit picture) to the screen.

Only the layout changes: the widgets, their order and their labels are the dialogs’ own.

Attributes

Classes

Rows

Form rows in sections, laid out by build(). addRow takes what QFormLayout.addRow takes (a label

Functions

available_size([widget]) → tuple[int, int]

Width and height (logical pixels) of the free screen area (without the task bar) under widget, else under

fit(dialog, body[, buttons, want]) → pya.QScrollArea

Lay dialog out as body (a widget or layout) in a scroll area and buttons below it, resizable, sized

fit_window(window, width, height) → None

Resize a non-modal window to width x height, but at most SCREEN_SHARE of the screen.

side_by_side(parent, left, right[, columns]) → pya.QWidget

Two layouts (or widgets) next to each other when two columns are on, else one under the other.

two_columns_enabled() → bool

Settings ▸ "Long dialogs in two columns" (on by default).

Module Contents

class qcc_kplugin.dialogs.Rows(parent=None)

Form rows in sections, laid out by build(). addRow takes what QFormLayout.addRow takes (a label and a widget or layout, or one widget or layout spanning the row); section() starts a new section (with an optional bold title). Two columns split only between sections (or, with a single section, between rows).

addRow(*args)
build(columns: int | None = None) → pya.QWidget

The dialog body: the rows in one or two columns (each a form, top-aligned).

section(title: str | None = None)

Start a section; title adds a bold label as its first row. Returns the label (or None).

split(columns: int | None = None) → list[list[tuple]]

The rows of each column: one, or two balanced by height when two are allowed and needed.

units() → list[list[tuple]]
columns = 1
parent = None
sections: list[list[tuple]] = [[]]
qcc_kplugin.dialogs.available_size(widget=None) → tuple[int, int]

Width and height (logical pixels) of the free screen area (without the task bar) under widget, else under KLayout’s main window.

qcc_kplugin.dialogs.fit(dialog, body, buttons=None, want: tuple[int, int] | None = None) → pya.QScrollArea

Lay dialog out as body (a widget or layout) in a scroll area and buttons below it, resizable, sized to the content (at least want) and at most SCREEN_SHARE of the free screen area. Returns the area.

qcc_kplugin.dialogs.fit_window(window, width: int, height: int) → None

Resize a non-modal window to width x height, but at most SCREEN_SHARE of the screen.

qcc_kplugin.dialogs.side_by_side(parent, left, right, columns: int | None = None) → pya.QWidget

Two layouts (or widgets) next to each other when two columns are on, else one under the other.

qcc_kplugin.dialogs.two_columns_enabled() → bool

Settings ▸ “Long dialogs in two columns” (on by default).

qcc_kplugin.dialogs.FALLBACK_SCREEN = (1280, 800)
qcc_kplugin.dialogs.SCREEN_SHARE = (0.92, 0.88)
qcc_kplugin.dialogs.TWO_COLUMNS_ABOVE = 0.6