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

Screenshot without margins #7

Open
wants to merge 86 commits into
base: main
Choose a base branch
from
Open

Conversation

melonora
Copy link
Owner

@melonora melonora commented May 5, 2024

References and relevant issues

Description

melonora and others added 7 commits May 5, 2024 20:23
Co-authored-by: olusesan olusesan.ajina@gmail.com
Co-authored-by: olusesan.ajina@gmail.com
Co-authored-by: olusesan.ajina@gmail.com
Co-authored-by: olusesan.ajina@gmail.com
img = viewer.screenshot(flash=False, fit_to_data=True)
assert img.shape == (250, 250, 4)
assert np.all(img != np.array([0, 0, 0, 1]))

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only fails when running the test itself. If you use the same code in a python script it does not fail. For some reason, there is no response to the canvas resize event when running inside a test.

melonora and others added 26 commits July 1, 2024 11:36
Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
…ons) (napari#7057)

# References and relevant issues

Follow up for
napari#7030 (comment)

# Description

Add tests for split rgb, split and merge layer actions functions
# References and relevant issues

In napari#7054, I noted that in napari#5432 we had inadvertently removed access to
mouse events from QtViewer.canvas, without a deprecation. @jni
[commented](napari#7054 (comment))
that we could temporarily restore access with a property, followed in
later versions by an alternate API and deprecation.

# Description

This PR adds an `events` property to QtViewer.canvas, restoring the
broken behavior. It does not yet have a deprecation message because we
don't have an alternate API.
This ensures correct sampling with anisotropic data

Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
…`File` menu (napari#7075)

# References and relevant issues
Closes napari#7068 

# Description
Add a new group to the `File` menu for the newly contributable menus,
allowing `Open Sample` to remain at the bottom of its group as it
previously was.
…apari#6965 (napari#7038)

# References and relevant issues

Alternative to napari#6950 that doesn't rely on registering/deregistering
actions but instead uses the mechanism from napari#6965.

Depends on: napari#6965

# Description

On macOS, there is no indication by default that a menubar submenu is
empty — one simply has to hover for an unnaturally long time to be sure
that indeed, there is nothing in that submenu. Instead of allowing this
behaviour, apps usually put an "Empty" placeholder in empty submenus
that quickly indicate to the user that there is nothing in this menu.

This is particularly critical for napari users since napari#7011, because that
PR added a *lot* of menus that are empty if the user has not installed
plugins.

In napari#6950, I tried to add this issue by:
- registering a do-nothing action
- de-registering it and re-registering it whenever the menus changed,
placing it in all menus that are empty.

The issue with that approach is that de-registering and re-registering
the action was itself changing the menus, which could cause infinite
loops if we weren't super careful — and indeed we did, and worse, we
seemed to do so stochastically.

This PR instead uses just-in-time functional context evaluation to check
whether a menu is empty as it's about to be shown, and show the empty
key if so.



https://github.com/napari/napari/assets/17995243/9b051a68-fe1d-41d9-ad39-b7fcc11d5206



## Trying stuff out

The easiest way to try this out is to just launch `napari` from main and
look for an empty menu e.g. `Layers -> Data`. Then, if you want to see
the placeholder disappear upon action registration, you can run the
following code in the console.

```python
from napari._app_model import get_app
from app_model.types import Action

my_action = Action(
    id='napari.new_action',
    title='On The Fly',
    callback=lambda: napari.utils.notifications.show_info("WOOOOOW"),
    menus=[{'id': 'napari/layers/data'}]
    )

app = get_app()
deregister_action = app.register_action(my_action)
# call deregister_action() to deregister the same action
```

---------

Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Co-authored-by: Juan Nunez-Iglesias <jni@fastmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants