Troubleshooting Qt and Widgets¶
For problems with the core itself (finding Micro-Manager, loading device adapters), see Troubleshooting for pymmcore-plus.
No Qt bindings¶
If you get an error similar to the one above, it means that you did not install one
of the necessary PyQt or
PySide libraries. Install pymmcore-widgets with
an extra that brings one along:
See Installing a Qt backend for how to choose.
"no matches found" when installing¶
zsh (the default shell on macOS) treats the square brackets as a file pattern. Put
quotes around the package name: pip install "pymmcore-widgets[PyQt6]".
Must construct a QApplication¶
... followed by Python crashing. Every Qt program needs a QApplication, and it must
exist before you create any widget. Create it first thing (and create it before the
CMMCorePlus, too, for the reasons explained in Qt
integration):
from qtpy.QtWidgets import QApplication
app = QApplication([])
# ... now create the core and the widgets
app.exec()
The widgets don't follow my script¶
If you change something from your own code (core.setExposure(50), say) and a widget
doesn't update, the widget is probably connected to a different core. Widgets use the
global CMMCorePlus.instance() unless you pass mmcore=, so a core you created with
CMMCorePlus() is a separate object, with its own devices and its own events. Either
use CMMCorePlus.instance() in your script, or pass your core to each widget:
ExposureWidget(mmcore=my_core).
Also check that the widget uses a core at all (the sequence editors, like
ChannelTable and ZPlanWidget, don't). See Choosing a
core.
The GUI freezes¶
Anything that blocks the main thread (the one running app.exec()) freezes the whole
GUI until it returns: a long core.snapImage(), a slow stage move, a time.sleep()
in a callback, etc... Run long operations in a thread instead.
CMMCorePlus.run_mda already does this for you.
See Qt integration for an example.
Please open an issue if you run into something that isn't covered here.