Skip to content

feat(PlotItem) define context menu action visibility#2584

Merged
j9ac9k merged 2 commits intopyqtgraph:masterfrom
jmkerloch:feature/disable_context_menu_options
Feb 10, 2023
Merged

feat(PlotItem) define context menu action visibility#2584
j9ac9k merged 2 commits intopyqtgraph:masterfrom
jmkerloch:feature/disable_context_menu_options

Conversation

@jmkerloch
Copy link
Copy Markdown
Contributor

@jmkerloch jmkerloch commented Jan 11, 2023

Add method setContextMenuActionVisible in PlotItem.

Based on action name ('Transforms', 'Downsample', 'Average', 'Alpha', 'Grid', 'Points'), action is set visible depending on the argument visible

To avoid issue with translation (action text is translated) action name is translated to get correction action.

Fixes #2351

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Jan 19, 2023

Hi @jmkerloch

Thanks for the PR; this feature request has come up a few times, so I really appreciate the PR to implement this.

One nit-pick I have is to switch to a numpy doc style docstring; you can see another example in PlotItem here: https://github.com/pyqtgraph/pyqtgraph/blob/master/pyqtgraph/graphicsItems/PlotItem/PlotItem.py#L1179C2-L1203

Also, how do you feel about accepting str | Iterable[str] where you can pass multiple action names.

I'm not sold on the method name, but I can't think of anything better, @outofculture @ixjlyons either of you two think of a better name here (or have other comments?)

@jmkerloch
Copy link
Copy Markdown
Contributor Author

@j9ac9k I updated the docstring. It seems OK to me in the generated documentation.

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Feb 10, 2023

Thanks @jmkerloch This PR looks good to me, we appreciate your contribution!

@j9ac9k j9ac9k merged commit a4d35d7 into pyqtgraph:master Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable actions in pg.PlotItem custom menu

2 participants