Skip to content

Promote interactive Run action to group level#2414

Merged
ntjess merged 7 commits intopyqtgraph:masterfrom
ntjess:interactive-refactoring
Sep 21, 2022
Merged

Promote interactive Run action to group level#2414
ntjess merged 7 commits intopyqtgraph:masterfrom
ntjess:interactive-refactoring

Conversation

@ntjess
Copy link
Copy Markdown
Contributor

@ntjess ntjess commented Sep 13, 2022

Much less screen real estate is required if an interactive parameter's "Run" button is associated with the group rather than as a subchild (similar to the pen parameter):
image
A very nice additional benefit is being able to run the function even when all parameters are not expanded:
image

Because "Run" buttons would no longer clutter a parameter and make unnecessary children, there is minimal drawback to making [RunOptions.ON_CHANGED, RunOptions.ON_ACTION] the default instead of RunOptions.ON_CHANGED.

To facilitate this change, minor refactoring of action's button meant more of its options (icon, shortcut, other button properties as desired) could be exposed as parameter opts.

Note: The current shortcut behavior means an action only listens to the shortcut when any of its items are visible. So if a tree is hidden (or no parameter items were spawned), the shortcut doesn't work. There are many other ways of implementing parameter shortcuts, but this is the most pain-free (doesn't require the user to specify a widget parent in opts, doesn't depend on shortcut parent's life cycle). If this behavior is unintuitive, my next plan would be to force the user to provide a shortcutParent (or something similar) if shortcut is specified. This is the widget whose focus determines whether the shortcut will be listening. The downside is if this object is deleted, it can lead to confusing behavior. However, it would allow the shortcut to be tied to the parameter itself, rather than an instantiated button. (I could also simply remove shortcut from the list of available options, but I find it useful enough)

  • TODO: Update ActionParameter docs to incorporate new options once the discussion regarding shortcut is settled.

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Sep 14, 2022

I think shortcuts not working if a parameter is hidden is fine; especially for an initial go. If people complain, we can certainly revisit!

@ntjess ntjess force-pushed the interactive-refactoring branch from 4cae4a6 to f982c00 Compare September 15, 2022 01:00

``sigActivated(self)`` is emitted when the button is clicked.

============== ============================================================
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would you mind changing this docstring to numpy style docstring? We are hoping to migrate the rest of the repo to that, but it may be a while.

Also I think it should be

:class:`QIcon`  and :class`QKeySequence`

Our docs are now smart enough to link to the upstream Qt docs for Qt types like that 👍🏻

@ntjess ntjess force-pushed the interactive-refactoring branch 4 times, most recently from 0c27677 to 736bbd1 Compare September 17, 2022 17:01
Save space by placing the button inside the nested group where possible. This has the added benefit of allowing a function to be run while parameters are collapsed
For now, simply remove positional arguments from consideration
- Add extra `action` arguments
- Rename `FunctionParameterGroup` -> `ActionGroup` for clarity
- Bugfix on setting icon in `action` arguments
@ntjess ntjess force-pushed the interactive-refactoring branch from 736bbd1 to 279996b Compare September 20, 2022 19:43
@ntjess ntjess merged commit 5ed8464 into pyqtgraph:master Sep 21, 2022
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.

2 participants