daplis_rtp.gui.layout module

One set of geometry rules for every tab.

Nothing in the old application decided how large it was. Five tabs each decided for themselves, in two different ways - three generated from .ui files by pyuic, two built by hand in Python - and the window took the largest minimum of the five. A panel added to the tab nobody was looking at set how tall the application opened, and a widget sized differently from its counterpart on another tab was invisible until the two were put side by side.

That cost real time. A status box added to one control column made every tab open 70 px taller; three tabs carried a 500x425 placeholder widget that nothing drew; the “Full Sensor” combo boxes had drifted to 80 px Expanding against everyone else’s 100 px Fixed. All three were found by measuring, not by looking.

So the numbers live here, once, and the tabs are built from TabShell rather than each inventing its own skeleton. What that buys is the thing the eye actually notices: the plot is the same size and in the same place on every tab, and so is every button.

The rules that govern, none of them obvious and all of them learnt the expensive way:

  • A control column’s minimum height is the sum of the panels stacked in it. Nothing in a QVBoxLayout gives height back. So every box added to a column used to be height the window could never lose, on every tab, forever. Hence ControlColumn, which is a scroll area: a column too tall for the window scrolls instead of pushing the window taller. That is what stops one tab’s panel from setting the size of all five.

  • The canvas is the only other thing that yields. MIN_CANVAS_HEIGHT is 240, tuned as the largest value that costs the window no height of its own.

  • The navigation toolbar does not push back. Squeeze a QToolBar below its contents and it hides them behind an overflow button rather than forcing its parent wider - and the cursor readout, which is how pixel numbers are read off the plot, is the first thing to go. See canvas.base.toolbar_min_width.

  • The window’s minimum is the worst tab, per axis. Height can come from one tab and width from another, which is why tests/test_tab_geometry.py measures all five.

Sizes here are quoted at the default 10 pt interface font and scaled with it, so that turning the font up in Preferences moves the rows and the control column with it instead of clipping them.

class daplis_rtp.gui.layout.ActionBar(parent=None)[source]

Bases: QWidget

The buttons at the foot of the control column.

Three slots, stacked, on every tab. A tab with one button leaves two empty rather than letting its button grow or the bar shrink - which is what puts “Refresh plot” under the same pixels whichever tab is in front.

Stacked rather than side by side because the column is 272 px wide: three buttons across it get 85 px each, which is narrower than the words on them. Full width each, and they are all legible and all the same size.

The slots mean something, and the tabs fill them the same way:

slot

what goes in it

1

look again now - “Refresh plot”, “Check clocks”

2

the thing the tab is for, and the one that runs - “Start stream”, “Acquire”. Marked primary.

3

the extra, if there is one - “Reset”, “Launch boards”

__init__(parent=None)[source]
add_button(text, tip=None, primary=False, slot=None)[source]

Put a button in a slot - the next free one unless told.

primary marks the one the tab is really for, which the stylesheet outlines in the accent colour.

apply_metrics()[source]
class daplis_rtp.gui.layout.ControlColumn(parent=None)[source]

Bases: QScrollArea

The right-hand column of controls, identical on every tab.

A scroll area rather than a plain column, and that is the whole point: a column with one panel too many scrolls, where before it made every tab in the application open taller. The width is fixed, so the plot beside it starts at the same x on all five tabs.

__init__(parent=None)[source]
add_group(title)[source]

A titled box to put rows in, returned with its layout.

add_heading(text)[source]

A small caption dividing one run of rows from the next.

add_pair_row(left, right)[source]

Two controls side by side, sharing one row’s height.

add_row(text, widget, tip=None)[source]

A label on the left, one fixed-width control on the right.

Every control column is this row repeated a dozen times, which is why it is a function rather than four lines written out each time.

add_stretch()[source]

Push everything above it to the top of the column.

add_wide_row(widget, tip=None)[source]

One control across the full width - a check box, a button.

add_widget(widget)[source]

A panel that brings its own height - a group box, a readout.

apply_metrics()[source]
class daplis_rtp.gui.layout.ElidedLabel(text='', parent=None)[source]

Bases: QLabel

A one-line label that shortens itself rather than widening the window.

A plain QLabel reports a minimum width equal to the whole of its text, and a layout never goes below that - so the sentence of guidance across the top of each tab set the narrowest the whole application could be made, at well over 2000 px. This one reports almost no minimum and paints an ellipsis instead, keeping the full text in its tooltip so nothing is actually lost.

__init__(text='', parent=None)[source]
minimumSizeHint(self) → QSize[source]
paintEvent(self, a0: QPaintEvent | None)[source]
setText(self, a0: str | None)[source]
class daplis_rtp.gui.layout.TabShell(parent=None, hint='')[source]

Bases: QWidget

The skeleton every tab is built in.

+------------------------------------------------------------+
| hint                                                       |
+-------------------------------------------+----------------+
| header row 0                              |                |
| header row 1                              |  control       |
|                                           |  column        |
|            canvas area                    |  (scrolls)     |
|                                           |                |
| footer row                                +----------------+
|                                           |  action bar    |
+-------------------------------------------+----------------+

Every one of those slots is the same height and width on all five tabs, whether or not the tab has anything to put in it. A tab that leaves the second header row empty still starts its plot at the same y as the tab that fills it.

__init__(parent=None, hint='')[source]
add_canvas_strip(widget)[source]

A row of controls across the top of the plot, on this tab only.

Inside the canvas area rather than a third header row, so the area itself stays the same rectangle on every tab: the row is taken out of this tab’s plot, and the tabs without one keep the height.

apply_metrics()[source]

Re-apply every font-dependent size.

Connected to the theme, so that changing the interface font in Preferences moves the rows rather than clipping their contents.

property canvas_area

The rectangle the plot occupies.

Exposed so that tests/test_tab_geometry.py can assert it is the same rectangle on all five tabs, which is the one property of this module the eye actually notices.

footer_row(index=0)[source]

The horizontal box of the row under the plot.

header_row(index=0)[source]

The horizontal box of header row index (0 or 1).

set_canvas(widget)[source]

Put the plot - or, on the Synchronization tab, the log - in.

Named for the plot because that is what it holds on four tabs out of five, and because the point of the shell is that the fifth occupies exactly the same rectangle.

set_hint(text)[source]
daplis_rtp.gui.layout.action_height()[source]
daplis_rtp.gui.layout.allow_shrink(widget)[source]

Let a widget be squeezed below the width of its own contents.

A row of readings, or a status line, must not be what decides how narrow the window can be made: the plot is the thing being sized, and a reading that is clipped at 1300 px is a smaller loss than a window that cannot be made narrower than 1600. Qt’s Ignored policy is exactly this - the layout stops counting the widget’s minimum, and it takes whatever space is left.

daplis_rtp.gui.layout.control_box_width()[source]
daplis_rtp.gui.layout.control_column_width()[source]
daplis_rtp.gui.layout.control_content_width()[source]

The column’s width less the room kept for its scroll bar.

Everything in the column - the rows, the panels, the action buttons - is laid out to this, so that the contents sit in the same place on a tab whose column scrolls and one whose column does not.

daplis_rtp.gui.layout.fixed_row(parent=None, height=None)[source]

A widget of exactly one row’s height, holding a horizontal box.

Used for the rows above and below the plot. Fixed rather than minimum, so that a tab which leaves one empty still starts its plot at the same height as the tab beside it.

daplis_rtp.gui.layout.hint_height()[source]
daplis_rtp.gui.layout.label(text, parent=None, object_name=None)[source]
daplis_rtp.gui.layout.led(parent=None)[source]

The round status lamp used by the panels and the sync tab.

Its colour comes from the ledState property and the stylesheet rather than from a per-widget palette, so it follows the theme.

daplis_rtp.gui.layout.row_height()[source]

One control row, never shorter than the text it has to hold.

daplis_rtp.gui.layout.scale()[source]

How far the interface font is from the size the numbers assume.

daplis_rtp.gui.layout.set_led(lamp, state)[source]

Re-colour a lamp: ‘idle’, ‘ok’, ‘warn’ or ‘error’.

The property alone changes nothing on screen - Qt only re-reads the stylesheet when told to - so the widget is unpolished and polished again, which is the documented way of doing this.

daplis_rtp.gui.layout.size_like_ui_tabs(widget, width=None)[source]

Give one control the width and height every other control has.

Named after what it was for: the two hand-built tabs had to be made to agree with the three generated ones. Now it is the only way any of them is sized.