-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Snap button widget #147
Snap button widget #147
Conversation
Co-authored-by: Ian Hunt-Isaak <ianhuntisaak@gmail.com>
I wanted to modify the snap method in the main_window like below:
but when the image is snapped and the
Do you know why? |
Yeah that suggests your communicating with the gui across threads. Updating the napari viewer should never happen in a non main thread. You need to connect the viewer update to a callback after the worker is finished |
micromanager_gui/main_window.py
Outdated
def _snap(self, img: np.ndarray): | ||
# update in a thread so we don't freeze UI | ||
create_worker(self.update_viewer, img, _start_thread=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def _snap(self, img: np.ndarray): | |
# update in a thread so we don't freeze UI | |
create_worker(self.update_viewer, img, _start_thread=True) | |
def _snap(self, img: np.ndarray): | |
self.stop_live() | |
# run snap in a thread so we don't freeze UI | |
create_worker( | |
self._mmc.snap, | |
_start_thread=True, | |
) |
This can't just update the viewer - it also needs to trigger a new snap so that it works for snap_on_click
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can probably remove this entirely in the future once the new stage widget comes in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fdrgsp this still needs to be changed - currently snap on click is broken
@fdrgsp can you add some tests - even a super basic one like in https://github.com/tlambert03/napari-micromanager/pull/150? After that I'm happy to give this a more thorough review |
also, rebasing on main should fix the test failures |
Codecov Report
@@ Coverage Diff @@
## main #147 +/- ##
==========================================
+ Coverage 81.56% 81.84% +0.27%
==========================================
Files 25 26 +1
Lines 2268 2314 +46
==========================================
+ Hits 1850 1894 +44
- Misses 418 420 +2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
micromanager_gui/main_window.py
Outdated
def _snap(self, img: np.ndarray): | ||
# update in a thread so we don't freeze UI | ||
create_worker(self.update_viewer, img, _start_thread=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fdrgsp this still needs to be changed - currently snap on click is broken
test error due to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment on a small improvment - but on the whole this looks good
@tlambert03 I think this is ready and would be a nice to have as a separate widget for the demo. Any chance of merging this todayish? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good stuff. Thanks!
Creating a new general purpose Snap
QPushButton
widget linked to thepymmcore-plus
snap
method.Once the button is
clicked
, an image is snapped and thepymmcore-plus
imageSnapped
signal is emitted.