Skip to content

Give siPrefix behavior to values of zero#2842

Merged
campagnola merged 10 commits intopyqtgraph:masterfrom
outofculture:si-spin-improve
Jan 17, 2024
Merged

Give siPrefix behavior to values of zero#2842
campagnola merged 10 commits intopyqtgraph:masterfrom
outofculture:si-spin-improve

Conversation

@outofculture
Copy link
Copy Markdown
Contributor

This PR adds new behavior to the SpinBox widget when siPrefix is True. By default, values of 0 will now take on the SI prefix associated with the initial step, as would immediately be present if the user were to press up or down once. This scaling hint will make it clearer what that initial step will be, as well as make it so that initial values typed in manually will be set to that scale. This behavior can also be overridden with a new scaleAtZero option, which can be configured to any value regardless of that initial step. Tests and example coverage are included.

This PR also corrects a small, unrelated incompatibility in the (likely not broadly used) GarbageCollector class, as well as adds a test that would have caught the problem.

Other Tasks

Bump Dependency Versions

Files that need updates

Confirm the following files have been either updated or there has been a determination that no update is needed.

  • README.md
  • setup.py
  • tox.ini
  • .github/workflows/main.yml and associated requirements.txt and conda environemt.yml files
  • pyproject.toml
  • binder/requirements.txt
Pre-Release Checklist

Pre Release Checklist

  • Update version info in __init__.py
  • Update CHANGELOG primarily using contents from automated changelog generation in GitHub release page
  • Have git tag in the format of pyqtgraph-
Post-Release Checklist

Steps To Complete

  • Append .dev0 to __version__ in __init__.py
  • Announce on mail list
  • Announce on Twitter

sb = pg.SpinBox(suffix=suffix)

sb.lineEdit().setText('0.1' + suffix)
sb.lineEdit().setText(f'0.1{suffix}')
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.

love the f-strings!

if isinf(self.val) or isnan(self.val):
return self.val
steps = int(steps)
sign = [decimal.Decimal(-1), decimal.Decimal(1)][steps >= 0]
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.

Thanks for replacing single character variable names!

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Oct 31, 2023

Hi @outofculture

The PR looks good to me, I'm wondering if we need to go through a deprecation dance for removing the prev argument to updateText and formatText methods.

I would be open to having those methods accept **kwargs and have a check if prev is in the kwargs dictionary, and if present, emit a deprecation warning saying the argument is ignored, and it's presence will raise an error in a future version of pyqtgraph.

@outofculture
Copy link
Copy Markdown
Contributor Author

Here's that deprecation warning. Thanks for the review!

@campagnola campagnola merged commit 261a325 into pyqtgraph:master Jan 17, 2024
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.

3 participants