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
QVBoxLayoutgives height back. So every box added to a column used to be height the window could never lose, on every tab, forever. HenceControlColumn, 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_HEIGHTis 240, tuned as the largest value that costs the window no height of its own.The navigation toolbar does not push back. Squeeze a
QToolBarbelow 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. Seecanvas.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.pymeasures 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:
QWidgetThe 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”
- class daplis_rtp.gui.layout.ControlColumn(parent=None)[source]
Bases:
QScrollAreaThe 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.
- class daplis_rtp.gui.layout.ElidedLabel(text='', parent=None)[source]
Bases:
QLabelA one-line label that shortens itself rather than widening the window.
A plain
QLabelreports 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.
- class daplis_rtp.gui.layout.TabShell(parent=None, hint='')[source]
Bases:
QWidgetThe 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.
- 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.pycan assert it is the same rectangle on all five tabs, which is the one property of this module the eye actually notices.
The horizontal box of the row under the plot.
- 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
Ignoredpolicy is exactly this - the layout stops counting the widget’s minimum, and it takes whatever space is left.
- 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.led(parent=None)[source]
The round status lamp used by the panels and the sync tab.
Its colour comes from the
ledStateproperty 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.