A small myTk GUI for the Spectra-Physics
Millennia eV CW pump laser, driven through
PyHardwareLibrary's
MillenniaDevice.
The window provides:
- Pump Diodes On/Off — a toggle button (driver
ON/OFF, status?D). - Shutter Open/Close — a toggle button (
SHT:1/SHT:0, status?SHT). - Power Monitor — live output power in watts (
?P) plus On/Off and Open/Closed lamps for the diodes and the shutter.
All serial I/O runs on a background worker thread, so the eV's slow write-then-confirm actions never freeze the UI. If the laser's serial port is already in use by another program (on this bench the eV's USB port is routinely captured by Parallels for the Windows Spectra-Physics app), the status line says so explicitly.
Auto-reconnect. If the connection drops (cable pulled, port disappears) — or the laser simply isn't present at launch — the app keeps watching for the port and reconnects automatically as soon as it reappears. During this the status line shows it is monitoring and the button reads Disconnect so you can cancel the auto-retry. An explicit Disconnect is honoured: it will not reconnect on its own until you press Connect again.
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install git+https://github.com/DCC-Lab/PyHardwareLibrary.gitpython millennia_ui.py # auto-detect the Millennia serial port
python millennia_ui.py --port /dev/cu.usbmodemXXXX
python millennia_ui.py --simulate # no hardware needed (DebugMillenniaDevice)A double-clickable bundle can be built with PyInstaller (no Python install needed by the end user, and it launches in the user's own GUI session):
./packaging/build_app.sh # -> packaging/dist/MilleniaUI.appSee packaging/BUILD.md for details, Gatekeeper notes, and code-signing.
- Port busy. If the Spectra-Physics Windows app (or any program) holds the
laser's USB/serial port, macOS will not expose a
/dev/cu.*node for it and the GUI cannot connect. Quit that app first. - GUI session. A Tkinter app can only open a window in the GUI login session
that owns the screen. Launching it from a shell that belongs to a different
logged-in user (e.g. running as
dccotewhile the console is logged in asdcclab) aborts inlibxpcbefore any window appears. Run it as the user logged in at the screen, or launch the.appfrom Finder.
MIT © 2026 Daniel Côté (DCC-Lab)