mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 05:42:15 +01:00
integer and lfoat widget merged into one number widget
This commit is contained in:
parent
78c88a9429
commit
22ec0a03b9
1 changed files with 4 additions and 20 deletions
|
|
@ -1,28 +1,12 @@
|
|||
from Qt import QtWidgets, QtCore, QtGui
|
||||
|
||||
|
||||
class ModifiedIntSpinBox(QtWidgets.QSpinBox):
|
||||
class NumberSpinBox(QtWidgets.QDoubleSpinBox):
|
||||
def __init__(self, *args, **kwargs):
|
||||
min_value = kwargs.pop("minimum", -99999)
|
||||
max_value = kwargs.pop("maximum", 99999)
|
||||
super(ModifiedIntSpinBox, self).__init__(*args, **kwargs)
|
||||
self.setFocusPolicy(QtCore.Qt.StrongFocus)
|
||||
self.setMinimum(min_value)
|
||||
self.setMaximum(max_value)
|
||||
|
||||
def wheelEvent(self, event):
|
||||
if self.hasFocus():
|
||||
super(ModifiedIntSpinBox, self).wheelEvent(event)
|
||||
else:
|
||||
event.ignore()
|
||||
|
||||
|
||||
class ModifiedFloatSpinBox(QtWidgets.QDoubleSpinBox):
|
||||
def __init__(self, *args, **kwargs):
|
||||
min_value = kwargs.pop("minimum", -99999)
|
||||
max_value = kwargs.pop("maximum", 99999)
|
||||
decimals = kwargs.pop("decimal", 2)
|
||||
super(ModifiedFloatSpinBox, self).__init__(*args, **kwargs)
|
||||
decimals = kwargs.pop("decimal", 0)
|
||||
super(NumberSpinBox, self).__init__(*args, **kwargs)
|
||||
self.setFocusPolicy(QtCore.Qt.StrongFocus)
|
||||
self.setDecimals(decimals)
|
||||
self.setMinimum(min_value)
|
||||
|
|
@ -30,7 +14,7 @@ class ModifiedFloatSpinBox(QtWidgets.QDoubleSpinBox):
|
|||
|
||||
def wheelEvent(self, event):
|
||||
if self.hasFocus():
|
||||
super(ModifiedFloatSpinBox, self).wheelEvent(event)
|
||||
super(NumberSpinBox, self).wheelEvent(event)
|
||||
else:
|
||||
event.ignore()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue