Skip to content
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

vmin and vmax viewer properties set color range #723

Closed
PaulHax opened this issue Dec 20, 2023 · 1 comment · Fixed by #724
Closed

vmin and vmax viewer properties set color range #723

PaulHax opened this issue Dec 20, 2023 · 1 comment · Fixed by #724
Labels
enhancement New feature or request

Comments

@PaulHax
Copy link
Collaborator

PaulHax commented Dec 20, 2023

I don't know how to wrap get/set of color range with matplotlib like vmin and vmax properties. How to do synchronous wrapping of async Viewer methods?

Goal is something like adding this to Viewer class

    @property
    def vmin(self):
        range = self.get_image_color_range()
        return range[0]
    @vmin.setter
    def vmin(self, vmin):
        range = self.get_image_color_range()
        range[0] = vmin
        self.set_image_color_range(range)
@PaulHax PaulHax added the enhancement New feature or request label Dec 20, 2023
@bnmajor
Copy link
Collaborator

bnmajor commented Dec 20, 2023

Nice! The synchronous wrapping is added with the @fetch_value decorator, and you'll need to make make anything awaiting a network request async:

    @property
    @fetch_value
    async def vmin(self):
        range = await self.get_image_color_range()
        return range[0]
    @vmin.setter
    @fetch_value
    async def vmin(self, vmin):
        range = await self.get_image_color_range()
        range[0] = value
        self.set_image_color_range(range)

And just a reminder that if you're providing an example we need to resolve anything requiring a network request in the next cell (for now at least):

viewer.vmin = 10
vmin = viewer.vmin
vmin

PaulHax added a commit to PaulHax/itkwidgets that referenced this issue Dec 20, 2023
PaulHax added a commit to PaulHax/itkwidgets that referenced this issue Dec 21, 2023
PaulHax added a commit to PaulHax/itkwidgets that referenced this issue Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants