Round dial widget¶
This is a developer reference for embedding a reusable angular/scalar readback widget. It displays values rather than accepting movement commands. For using the motor control panel, see Controllers.
Available classes¶
The dial components are available from either of these import paths:
from stoner_measurement.ui import RoundDialWidget, RoundDialDemoWidget, RoundDialPanel
or:
from stoner_measurement.ui.widgets import (
RoundDialWidget,
RoundDialDemoWidget,
RoundDialPanel,
)
The main classes are:
stoner_measurement.ui.widgets.round_dial.RoundDialWidget— a single scalable dial displaystoner_measurement.ui.widgets.round_dial_demo.RoundDialDemoWidget— a small demonstration panel with common presetsstoner_measurement.ui.widgets.round_dial_panel.RoundDialPanel— a convenience container for embedding one or more dials in other panels
Angle convention¶
The dial uses a top-referenced clockwise angular convention:
0degrees = vertically upwards90degrees = right180degrees = down270degrees = left
This makes it suitable for motor position, compass direction, stage angle, sample rotation, and similar readouts.
Basic example¶
from qtpy.QtWidgets import QApplication, QVBoxLayout, QWidget
from stoner_measurement.ui import RoundDialWidget
app = QApplication.instance() or QApplication([])
panel = QWidget()
layout = QVBoxLayout(panel)
dial = RoundDialWidget()
dial.setTitle("Motor Position")
dial.setRange(0.0, 360.0)
dial.setScaleAngles(0.0, 360.0)
dial.setTickSteps(30.0, 4, 30.0)
dial.setUnitsText("°")
dial.setWrap(True)
dial.setValue(15.0)
layout.addWidget(dial)
panel.show()
app.exec()
The remaining snippets assume an existing QApplication, as above. Embedded application widgets reuse its event loop instead of starting another one.
Partial-arc example¶
dial = RoundDialWidget()
dial.setTitle("Position")
dial.setRange(0.0, 100.0)
dial.setScaleAngles(-225.0, 45.0)
dial.setTickSteps(10.0, 4, 10.0)
dial.setUnitsText("%")
dial.setValue(62.0)
Built-in presets¶
The widget provides a few convenience presets:
dial.setAngleValueMode() # 0..360°, full circle
dial.setCompassMode() # compass-style direction display
dial.setBidirectionalAngleMode() # -180..180°
dial.setClockMode() # 12-hour clock-face display
Theme support¶
The dial automatically follows the application’s dark/light theme by deriving
its default colours from stoner_measurement.ui.theme.
If you set custom colours explicitly, those overrides remain in place across theme changes until you call:
dial.resetThemeColors()
Standalone demo¶
A small standalone demo window is available from the console script:
stoner-measurement-round-dial-demo
This opens a themed demo window showing several useful dial presets.
Clock mode¶
Clock mode configures the dial as a 12-hour face with 12 vertically at the
top and labels 1 through 11 arranged clockwise around the dial.
The central value readout is formatted as HH:MM using the integer part as
the hour and the fractional part converted to minutes. For example:
3.5displays as03:3011.75displays as11:45
Embedding multiple dials¶
Use stoner_measurement.ui.widgets.round_dial_panel.RoundDialPanel
when you want a quick container for several readback dials:
from stoner_measurement.ui import RoundDialPanel
panel = RoundDialPanel()
motor = panel.add_dial(
"Motor Position",
minimum=0.0,
maximum=360.0,
minimum_angle=0.0,
maximum_angle=360.0,
major_tick_step=30.0,
minor_ticks_per_major=4,
label_step=30.0,
units="°",
)
motor.setWrap(True)
motor.setValue(12.5)