mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 03:31:50 +02:00
refactor: DoubleValidationDelegate moved to qt_utils
This commit is contained in:
@ -15,6 +15,8 @@ from PyQt5.QtWidgets import QStyledItemDelegate, QLineEdit
|
||||
from PyQt5.QtGui import QKeySequence
|
||||
from PyQt5.QtWidgets import QShortcut
|
||||
|
||||
from bec_widgets.qt_utils import DoubleValidationDelegate
|
||||
|
||||
from bec_lib.core import MessageEndpoints, BECMessage
|
||||
|
||||
|
||||
@ -684,12 +686,12 @@ class MotorApp(QWidget):
|
||||
ui_element.setStyleSheet("background-color: #FFA700;")
|
||||
|
||||
|
||||
class DoubleValidationDelegate(QStyledItemDelegate):
|
||||
def createEditor(self, parent, option, index):
|
||||
editor = QLineEdit(parent)
|
||||
validator = QDoubleValidator()
|
||||
editor.setValidator(validator)
|
||||
return editor
|
||||
# class DoubleValidationDelegate(QStyledItemDelegate):
|
||||
# def createEditor(self, parent, option, index):
|
||||
# editor = QLineEdit(parent)
|
||||
# validator = QDoubleValidator()
|
||||
# editor.setValidator(validator)
|
||||
# return editor
|
||||
|
||||
|
||||
class MotorActions(Enum):
|
||||
|
@ -1,2 +1,3 @@
|
||||
from .crosshair import Crosshair
|
||||
from .colors import Colors
|
||||
from .validator_delegate import DoubleValidationDelegate
|
||||
|
10
bec_widgets/qt_utils/validator_delegate.py
Normal file
10
bec_widgets/qt_utils/validator_delegate.py
Normal file
@ -0,0 +1,10 @@
|
||||
from PyQt5.QtGui import QDoubleValidator
|
||||
from PyQt5.QtWidgets import QStyledItemDelegate, QLineEdit
|
||||
|
||||
|
||||
class DoubleValidationDelegate(QStyledItemDelegate):
|
||||
def createEditor(self, parent, option, index):
|
||||
editor = QLineEdit(parent)
|
||||
validator = QDoubleValidator()
|
||||
editor.setValidator(validator)
|
||||
return editor
|
Reference in New Issue
Block a user