-
Notifications
You must be signed in to change notification settings - Fork 47
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
Table widget updates #301
Table widget updates #301
Conversation
Codecov Report
@@ Coverage Diff @@
## main #301 +/- ##
==========================================
+ Coverage 90.19% 90.21% +0.01%
==========================================
Files 29 29
Lines 3254 3281 +27
==========================================
+ Hits 2935 2960 +25
- Misses 319 321 +2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @hanjinliu!
this looks great. Can you just remove the commented code and (possibly) add a test for the uncovered displayText method?
One general comment I'll add. I'm slightly hesitant (but not opposed) to start adding more qt-specific logic like this, since it makes backend-agnostic things like ipywidgets (https://github.com/napari/magicgui/pull/87) and perhaps a wxpython or kivy backend all the more difficult. I realize that that's perhaps not the main current use case, but it's a use case that I don't want to rule out (hence all the redirection and composition in the current design). The ItemDelegate here is a small one, and we can always re-implement it on the python side in the future, but just wanted to point out the general design philosophy.
Thank you for your check! |
could you perhaps extract the formatting logic to a testable function? def displayText(self, value, locale):
value = _format_number(value, self.ndigits) # test this
return super().displayText(value, locale) |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Is this test OK? |
sure that test is fine. (probably would have made it a pure function that didn't require a qapp and instantiation of the item delegate... but this is fine too, just want to make sure we're at least roughly testing new things).
no worries! to avoid that in the future, you can install pre-commit locally with |
This PR adds three changes in
Table
widget:"enable_exp"
property that allow exponential notation like "5.2e-02", or dynamically change float format upon resized).setFlags
method is useful when we have to set different editability flags separately for each item. Here we only have to change editability of table itself,setEditTriggers
is faster because we don't have to run for loops.