@@ -502,15 +502,23 @@ def __init__(self, minv, maxv, step, parent=None):
502502 super ().__init__ (parent )
503503 self .setRange (minv , maxv )
504504 self .setSingleStep (step )
505+ self .changed = False
506+
507+ def onValueChanged (self ):
508+ """
509+ Sets the flag to determine whether the value has been changed.
510+ """
511+ self .changed = True
505512
506513 def onEnter (self ):
507514 """
508515 Commits the change by calling the appropriate callbacks.
509516 """
510- if self .cback :
517+ if self .cback and self . changed :
511518 self .cback (int (str (self .text ())))
512- if self .cfunc :
519+ if self .cfunc and self . changed :
513520 self .cfunc ()
521+ self .changed = False
514522
515523
516524class DoubleSpinBoxWFocusOut (QtWidgets .QDoubleSpinBox ):
@@ -522,12 +530,20 @@ def __init__(self, minv, maxv, step, parent):
522530 self .setDecimals (math .ceil (- math .log10 (step )))
523531 self .setRange (minv , maxv )
524532 self .setSingleStep (step )
533+ self .changed = False
534+
535+ def onValueChanged (self ):
536+ """
537+ Sets the flag to determine whether the value has been changed.
538+ """
539+ self .changed = True
525540
526541 def onEnter (self ):
527- if self .cback :
542+ if self .cback and self . changed :
528543 self .cback (float (str (self .text ()).replace ("," , "." )))
529- if self .cfunc :
544+ if self .cfunc and self . changed :
530545 self .cfunc ()
546+ self .changed = False
531547
532548
533549def spin (widget , master , value , minv , maxv , step = 1 , box = None , label = None ,
@@ -650,6 +666,7 @@ def spin(widget, master, value, minv, maxv, step=1, box=None, label=None,
650666 cbox .disables = [sbox ]
651667 cbox .makeConsistent ()
652668 if callback and callbackOnReturn :
669+ sbox .valueChanged .connect (sbox .onValueChanged )
653670 sbox .editingFinished .connect (sbox .onEnter )
654671 if hasattr (sbox , "upButton" ):
655672 sbox .upButton ().clicked .connect (
0 commit comments