Widgets API
skelarm.widgets
Shared PyQt6 widgets for the skelarm GUI tools: QtAwesome icons, the transport bar, and the playback clock.
The tools bind their keys (Space, R, Q, ...) as window-wide shortcuts. A focused
text field normally claims every key it could type, which silences those
shortcuts until the user clicks another widget that takes the focus; number
inputs should therefore be :class:ShortcutFriendlySpinBox.
PlaybackClock
Bases: QObject
A real-time playback clock that ticks a timeline forward at an adjustable speed.
The clock owns a :class:~PyQt6.QtCore.QTimer firing every period_ms
milliseconds while it runs. Each tick emits :attr:ticked with the timeline
seconds to advance: the period times the :attr:speed at that tick, so a speed
change takes effect on the next tick. The period is nominal; timer jitter is not
measured. The clock holds no timeline position of its own: connect :attr:ticked
to whatever advances the timeline, and pair :meth:start / :meth:stop with
:meth:TransportBar.set_playing to keep a play button in step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
QObject
|
Parent object, which owns the clock. |
None
|
period_ms
|
int
|
Real time between ticks, in milliseconds (default: 20). |
_PLAYBACK_PERIOD_MS
|
speed
|
float
|
Initial speed: timeline seconds per real second (default: 1). |
1.0
|
Source code in src/skelarm/widgets.py
is_running
property
Whether the clock is ticking.
period_ms
property
Real time between ticks, in milliseconds.
speed
property
writable
Timeline seconds per real second; any value is kept as given (no clamping).
ticked = pyqtSignal(float)
class-attribute
instance-attribute
Emitted on each tick with the timeline seconds to advance (period_ms / 1000 * speed).
__init__(parent=None, *, period_ms=_PLAYBACK_PERIOD_MS, speed=1.0)
Build a stopped clock.
Source code in src/skelarm/widgets.py
start()
ShortcutFriendlySpinBox
Bases: QDoubleSpinBox
A number box that leaves the window's keyboard shortcuts working.
A plain :class:~PyQt6.QtWidgets.QDoubleSpinBox claims every key it could
type while it has the focus, and keeps the focus until the user clicks another
widget that takes it, so shortcuts such as Space (play) or R (reset) stop
working after the user edits a value. This box claims only the keys that edit
a number: the digits, the decimal point, the signs, the cursor and deletion
keys, and the keys that step the value; Space, letters, and other keys reach
the shortcuts even while it has the focus. Enter or Escape commits the value
and hands the focus back to the window, so the keys it does claim (such as
Right or Home) work as shortcuts again. Key combinations with Ctrl, Alt, or
Meta behave as in any text field.
Source code in src/skelarm/widgets.py
event(event)
Decline the keys a number does not need, so they reach the window's shortcuts.
Source code in src/skelarm/widgets.py
keyPressEvent(e)
Commit on Enter or Escape and give the focus back to the window.
Source code in src/skelarm/widgets.py
SpeedSpinBox
Bases: ShortcutFriendlySpinBox
A spin box for a playback speed multiplier, as the replay player shows it.
It offers 0.1x to 10x in steps of 0.1, with two decimals. Handle its
valueChanged signal by setting a :class:PlaybackClock's
:attr:~PlaybackClock.speed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
QWidget
|
Parent widget. |
None
|
speed
|
float
|
Initial value, clamped to the range (default: 1). It is set before any signal is connected, so it emits nothing. |
1.0
|
Source code in src/skelarm/widgets.py
__init__(parent=None, *, speed=1.0)
Configure the range, step, and decimals, and show speed.
Source code in src/skelarm/widgets.py
TransportBar
Bases: QWidget
A media-player-style horizontal row of icon-only playback buttons.
The bar owns up to four :class:~PyQt6.QtWidgets.QToolButton widgets:
play_button— checkable;checkedmeans playing. Its icon and tooltip swap between play and pause, and it drives the enablement ofstep_buttonandback_button(stepping is only meaningful while paused).back_button— step one tick/frame backward while paused. Only built whenback_labelis given (the replay player); otherwiseNone.step_button— advance one tick/frame while paused.reset_button— return to the initial state.
Wire behavior by connecting to play_button.toggled,
back_button.clicked, step_button.clicked, and
reset_button.clicked.
Each button is also bound to window-wide keyboard shortcuts, advertised in
its tooltip: Space play/pause, →/F step, ←/B back (when
present), R reset. The :class:~PyQt6.QtGui.QShortcut objects live in
:attr:shortcuts, keyed by action name ("play", "step",
"reset", and "back" when built). A key must be bound at most once
per window — Qt resolves duplicates as ambiguous and then activates
neither binding, silently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
QWidget
|
Parent widget. |
None
|
playing
|
bool
|
Initial toggle state ( |
False
|
play_label
|
str
|
Tooltip shown while paused (the action the click performs). |
'Play'
|
pause_label
|
str
|
Tooltip shown while playing. |
'Pause'
|
step_label
|
str
|
Tooltip and accessible name of the step button. |
'Step'
|
reset_label
|
str
|
Tooltip and accessible name of the reset button. |
'Reset'
|
back_label
|
str
|
Tooltip and accessible name of the backward-step button; omit (the default) to build the bar without one. |
None
|
Source code in src/skelarm/widgets.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
__init__(parent=None, *, playing=False, play_label='Play', pause_label='Pause', step_label='Step', reset_label='Reset', back_label=None)
Build the bar and set the initial toggle state.
Source code in src/skelarm/widgets.py
set_playing(playing)
Sync the toggle to playing without emitting toggled.
Use this for programmatic state changes (e.g. auto-pause at the end of a replay) so the connected pause/resume handlers do not fire again.
Source code in src/skelarm/widgets.py
bind_quit_key(window)
Bind Q to close window, returning the created shortcut.
Closing goes through the normal close() path, so closeEvent
handlers (e.g. the trajectory recorder's unsaved-take warning) still run.
Source code in src/skelarm/widgets.py
make_icon(name)
Return a QtAwesome icon by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Icon name including its font prefix, e.g. |
required |
Returns:
| Type | Description |
|---|---|
QIcon
|
A font-rendered icon that works on every platform, including the offscreen one used in headless tests. |