Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.editor
Commits
0a466f6c
Commit
0a466f6c
authored
Apr 25, 2019
by
Samuel GAIST
Browse files
[widgets][spinboxes] Move floating type handling in base class
This allows for code simplification and wider range of type support.
parent
ddd7da66
Changes
1
Hide whitespace changes
Inline
Side-by-side
beat/editor/widgets/spinboxes.py
View file @
0a466f6c
...
...
@@ -59,7 +59,7 @@ class AbstractNumpySpinBox(QAbstractSpinBox):
"""
super
(
AbstractNumpySpinBox
,
self
).
__init__
(
parent
)
if
self
.
numpy_type
==
np
.
float
64
:
if
np
.
issubdtype
(
self
.
numpy_type
,
np
.
float
ing
)
:
self
.
_info
=
np
.
finfo
(
self
.
numpy_type
)
else
:
self
.
_info
=
np
.
iinfo
(
self
.
numpy_type
)
...
...
@@ -90,7 +90,12 @@ class AbstractNumpySpinBox(QAbstractSpinBox):
:param value numpy_type: value to change to text
"""
return
self
.
numpy_type
(
value
).
astype
(
"str"
)
text
=
self
.
numpy_type
(
value
).
astype
(
"str"
)
if
np
.
issubdtype
(
self
.
numpy_type
,
np
.
floating
):
if
text
.
endswith
(
".0"
):
text
=
text
[:
-
2
]
return
text
def
valueFromText
(
self
,
text
,
pos
):
"""Returns the value contained in the text
...
...
@@ -275,13 +280,3 @@ class Float64SpinBox(AbstractNumpySpinBox):
valueChanged
=
pyqtSignal
(
numpy_type
)
minimumChanged
=
pyqtSignal
(
numpy_type
)
maximumChanged
=
pyqtSignal
(
numpy_type
)
def
textFromValue
(
self
,
value
):
"""Returns the text version of value
:param value numpy_type: value to change to text
"""
text
=
self
.
numpy_type
(
value
).
astype
(
"str"
)
if
text
.
endswith
(
".0"
):
text
=
text
[:
-
2
]
return
text
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment