;i0fddlZddlZddlZddlmZmZddlmZddl m Z m Z m Z ddl m Z dgZGdde jZGd d e jZdS) N)isinfisnan) functions)QtCoreQtGui QtWidgets) SignalProxySpinBoxcJeZdZdZejeZejeZejeeZ d&dZ dZ d'dZ d'dZ d Zd Zd Zd Zd ZdZdZdZdZfdZdZd(dZdZdZdZdZdZdZdZ dZ!dZ"dZ#d Z$d!Z%d"Z&d#Z'd$Z(fd%Z)xZ*S))r aW **Bases:** QtWidgets.QAbstractSpinBox Extension of QSpinBox widget for selection of a numerical value. Adds many extra features: * SI prefix notation (eg, automatically display "300 mV" instead of "0.003 V") * Float values with linear and decimal stepping (1-9, 10-90, 100-900, etc.) * Option for unbounded values * Delayed signals (allows multiple rapid changes with only one change signal) * Customizable text formatting ============================= ============================================== **Signals:** valueChanged(value) Same as QSpinBox; emitted every time the value has changed. sigValueChanged(self) Emitted when value has changed, but also combines multiple rapid changes into one signal (eg, when rolling the mouse wheel). sigValueChanging(self, value) Emitted immediately for all value changes. ============================= ============================================== Nc Jtj||d|_d|_d|_|dd|_|tj j j tj j j t||_idddgdddt!jd d dd dd dd ddddddddddddddddt$jdt jdd|_|d dr d|jd<ddg|_t!jt/||_|d|_||jj|dt?|j |jd|j!d|_"|j#di||$|j%&|j'dS)a ============== ======================================================================== **Arguments:** parent Sets the parent widget for this SpinBox (optional). Default is None. value (float/int) initial value. Default is 0.0. ============== ======================================================================== All keyword arguments are passed to :func:`setOpts`. NTrboundswrappingFstepz0.01decintfiniteprefixsuffixsiPrefix scaleAtZerodelayg333333?delayUntilEditFinisheddecimalsformatzJ{prefix}{prefixGap}{scaledValue:.{decimals}g}{suffixGap}{siPrefix}{suffix}regexevalFunc compactHeightminStep)rslot threadSafe)(r QAbstractSpinBox__init__lastValEmittedlastText textValidsetMinimumWidth_lastFontHeight setSizePolicy QSizePolicyPolicy Expanding PreferredErrorBoxlineEditerrorBoxdecimalDecimalfn FLOAT_REGEXoptsgetdecOptsstrval updateText skipValidatesetCorrectionModeCorrectionModeCorrectToPreviousValuesetKeyboardTrackingr sigValueChanging delayedChangeproxysetOpts _updateHeighteditingFinishedconnecteditingFinishedEvent)selfparentvaluekwargss MC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\pyqtgraph/widgets/SpinBox.pyr(zSpinBox.__init__0sz "++D&999"  Q# 907A9CXC_Cijjj 11  tTl  GOF++   5  5  d  b  b ! " 4# & S' * %d+ . / 2 b3 4 R^5 6 7 : T;  > ::eU # # " !DIf  * ?3u::.. ! t2IJJJ   '''  !)G$#      v  $$T%>?????c `|D]4\}}|dkr;||dd||ddG|dkr||de|dkr||d|dvr*tjt ||j|<|d kr|d krt ||j|<|d kr3t|t rtj ||j|<||jvr ||j|<$td |zd |vr| |d d|vrd |vr| |jd rt|j dd|jd<d|vr+|d}t||krtdn:t|j dd}|dkrd}||jd<d |vr d|jd <|jdr/|j d|jd|jd<d|vr |j|d|dS)aSet options affecting the behavior of the SpinBox. ============== ======================================================================== **Arguments:** bounds (min,max) Minimum and maximum values allowed in the SpinBox. Either may be None to leave the value unbounded. By default, values are unbounded. suffix (str) suffix (units) to display after the numerical value. By default, suffix is an empty str. siPrefix (bool) If True, then an SI prefix is automatically prepended to the units and the value is scaled accordingly. For example, if value=0.003 and suffix='V', then the SpinBox will display "300 mV" (but a call to SpinBox.value will still return 0.003). In case the value represents a dimensionless quantity that might span many orders of magnitude, such as a Reynolds number, an SI prefix is allowed with no suffix. Default is False. prefix (str) String to be prepended to the spin box value. Default is an empty string. scaleAtZero (float) If siPrefix is also True, this option then sets the default SI prefix that a value of 0 will have applied (and thus the default scale of the first number the user types in after the SpinBox has been zeroed out). step (float) The size of a single step. This is used when clicking the up/ down arrows, when rolling the mouse wheel, or when pressing keyboard arrows while the widget has keyboard focus. Note that the interpretation of this value is different when specifying the 'dec' argument. If 'int' is True, 'step' is rounded to the nearest integer. Default is 0.01 if 'int' is False and 1 otherwise. dec (bool) If True, then the step value will be adjusted to match the current size of the variable (for example, a value of 15 might step in increments of 1 whereas a value of 1500 would step in increments of 100). In this case, the 'step' argument is interpreted *relative* to the current value. The most common 'step' values when dec=True are 0.1, 0.2, 0.5, and 1.0. Default is False. minStep (float) When dec=True, this specifies the minimum allowable step size. int (bool) If True, the value is forced to integer type. If True, 'step' is rounded to the nearest integer or defaults to 1. Default is False finite (bool) When False and int=False, infinite values (nan, inf, -inf) are permitted. Default is True. wrapping (bool) If True and both bounds are not None, spin box has circular behavior. decimals (int) Number of decimal values to display. Default is 6. format (str) Formatting string used to generate the text shown. Formatting is done with ``str.format()`` and makes use of several arguments: * *value* - the unscaled value of the spin box * *prefix* - the prefix string * *prefixGap* - a single space if a prefix is present, or an empty string otherwise * *suffix* - the suffix string * *scaledValue* - the scaled value to use when an SI prefix is present * *siPrefix* - the SI prefix string (if any), or an empty string if this feature has been disabled * *suffixGap* - a single space if a suffix is present, or an empty string otherwise. regex (str or RegexObject) Regular expression used to parse the spinbox text. May contain the following group names: * *number* - matches the numerical portion of the string (mandatory) * *siPrefix* - matches the SI prefix string * *suffix* - matches the suffix string Default is defined in ``pyqtgraph.functions.FLOAT_REGEX``. evalFunc (callable) Fucntion that converts a numerical string to a number, preferrably a Decimal instance. This function handles only the numerical of the text; it does not have access to the suffix or SI prefix. compactHeight (bool) if True, then set the maximum height of the spinbox based on the height of its font. This allows more compact packing on platforms with excessive widget decoration. Default is True. ============== ======================================================================== rrFupdater"minmax)rr#rOrrzInvalid keyword argument '%s'.rrr#z/Integer SpinBox must have integer minStep size.z/{prefix}{prefixGap}{value:d}{suffixGap}{suffix}rNr)items setMinimum setMaximumr6r7r=r: isinstancerecompile TypeErrorsetValueroundr;r ExceptionrGsetDelayr?)rMr:kvrmss rQrHzSpinBox.setOptsxsP::<< F FCAaH}}!U333!U3333e%0000e%0000)))&s1vv66 ! gh"1vv ! g*Q"4"4!z!}} ! di  !  @1 DEEE d?? MM$w- ( ( ( t  t 3 3 MMOOO 9U  X %dimmFA&>&> ? ?DIf D  It99$$#$UVVV%y!445566B') )$t##&W (# 9U  9y}}Y''/'+y'8 )$ d?? J  W . . . rRTc|!tjt|}||jdd<|r|dSdS)z4Set the maximum allowed value (or None for no limit)Nrr"r6r7r=r:r_rMmrUs rQrZzSpinBox.setMaximumP =A''A!" (A   MMOOOOO  rRc|!tjt|}||jdd<|r|dSdS)z4Set the minimum allowed value (or None for no limit)Nrrrgrhs rQrYzSpinBox.setMinimumrjrRc|jdS)z/Return whether or not the spin box is circular.rr:rMs rQrzSpinBox.wrappingsy$$rRc||jd<dS)zfSet whether spin box is circular. Both bounds must be set for this to have an effect.rNrm)rMss rQ setWrappingzSpinBox.setWrapping s!" *rRc2||dS)zSet a string prefix. )rNrH)rMps rQ setPrefixzSpinBox.setPrefixs A rRc6|||gdS)zBSet the upper and lower limits for values in the spinbox. )rNrs)rMr0r1s rQsetRangezSpinBox.setRanges" r"g &&&&&rRcd|dkr||dStd|zdS)NrOz5Warning: SpinBox.setProperty('%s', ..) not supported.)r_print)rMpropr>s rQ setPropertyzSpinBox.setPropertys? 7?? MM#      IDP Q Q Q Q QrRc2||dS)zfloatrns rQrOz SpinBox.valueCs/ 9U  #tx== ?? "rRFc||}d}t|s|jd}d|vrp|jddurad}t|r|j}nt |}t |dt |d}}||z ||z z|z}n<|d||dkr d}|d}|d||dkr d}|d}|jdrt |}t|tj s!tj t|}|j|c}|_tj || } |r| s|s| | rC|j|t |j|s||S) aSet the value of this SpinBox. If the value is out of bounds, it will be clipped to the nearest boundary or wrapped if wrapping is enabled. If the spin is integer type, the value will be coerced to int. Returns the actual value set. If value is None, then the current value is used (this is for resetting the value after bounds, etc. have changed) NTrrFrr"r)rOrr:rr>rrr[r6r7r=r8eqr?rEemit emitChanged) rMrOrU delaySignalboundedrluprevchangeds rQr_zSpinBox.setValueMs =JJLLEU|| &Yx(F6!!di &;t&C&C<<6 HEE"%LLE ++U6!9-=-=qA"QY1q51A5EE!9(UVAY->->#G"1IE!9(UVAY->->#G"1IE 9U  JJE%11 0OCJJ//E5dheE4(((  w g  OO     #  ! & &tU48__ = = = #  """ rRc|j|_|jt |j|j|dSr)r>r) valueChangedrrsigValueChangedrns rQrzSpinBox.emitChangedsH"h uTX/// !!$'''''rRc tj|j|js|dSdS#t $rYdSwxYwr)r8rr>r)r RuntimeErrorrns rQrFzSpinBox.delayedChangesd 54#677 #  """"" # #    DD s39 AAc>|jtjtjfSr)rr rOr_rns rQwidgetGroupInterfacezSpinBox.widgetGroupInterfaces!7='2BCCrRc,tjddS)Nxr)rQSizerns rQsizeHintzSpinBox.sizeHints|C###rRc4|jj|jjzSr)StepEnabledFlag StepUpEnabledStepDownEnabledrns rQ stepEnabledzSpinBox.stepEnableds#1D4H4XXXrRcZ|||ddS)NTr)r_ _stepByValue)rMns rQstepByzSpinBox.stepBys, d''** =====rRct|jst|jr|jSt|}t jdt jdg|dk}|j}t tt|D]T}|jdr|dkr|jd}d}nt jdt jdg|dk}t jd||zz}t||z dtj }|jdt jd|zz}d|jvrt||jd}|||zz }n|||jdzz }d|jvr2t||jdkrt jd}V|S) Nr"rrr#z1.01r ) rr>rrr6r7rangeabsr:log10quantize ROUND_FLOORrW) rMstepssignr>irexpvsfudges rQrzSpinBox._stepByValues ?? eDHoo 8OE ##W_Q%7%78!Dhs3u::'' ) )Ay 0!889Y/DCC!/"--wq/A/AB3!8LB#OF33r BEcEk**0022;;Aw?RSSC9V,wr/B/Bc/IID ))tTYy%9::Dtd{"tdi///DI%%#c((TYy5I*I*Ioa(( rRct|si|jd}|d||dkrdS|d||dkrdS|jddrt||krdSdS)NrrFr"rT)rr:r;r)rMrOrs rQ valueInRangezSpinBox.valueInRangesU|| !Yx(Fay$):):uay$):):uy}}UE** !u::&& 5trRc d|_|jdi|}||||_d|_dS)NTFr&)r@ formatTextr4setTextr*)rMrPtxts rQr?zSpinBox.updateTextsV do'''' $$$ "rRc d|vrtjdtd|jd}|jd}|jd}|}|jdd ur|jd kr[|jd #t j|jd \}}nBt j|d \}}nt j|\}}||||||z|d }n |||d||d }|ddkrdnd|d<|ddkr|ddkrdnd|d<|jdj di|S)Nrz[updateText and formatText no longer take prev argument. This will error after January 2025.r) stacklevelrrrrTrrr")rOrrr scaledValuerr prefixGap suffixGaprr&) warningswarnDeprecationWarningr:rOr>r8siScalerr) rMrPrrrr>rprtpartss rQrzSpinBox.formatTexts V   Mm"     9Z(8$8$jjll 9Z D ( (x1}}9]+7Z -(@AAFQZ(9(9!(<(<==FQCA!VWXijkninyAAEE"VWYjmx~E#(?b#8#8RRck$)(Or$9$9eJ>OSU>U>URR\_k)ty")22E222rRc|jrtjjj}n |}|durtjjj}nf||r;|jds| |dtjjj}ntjjj}n=#ddl }|j | tjjj}YnxYw|tjjjkrd|_ n!|tjjjkrd|_ ||j|j |||fS)NFrrTrT)r@r QValidatorState Acceptable interpret Intermediaterr:r_sys excepthookexc_infor+rUr5 setVisible)rMstrnposretr>rs rQvalidatezSpinBox.validatesR   :"(3CC :nn&&%<<*0=CC((--B#y)AB= MM#eM<<<#.4?#.4A :  //&,9 %"(5 5 5"DNN E$*5 5 5!DN    T^!3444T3s BB668C0cv||Sr)r?r4r)rMrs rQfixupz SpinBox.fixups, }}##%%%rRc8|} ||jd}n2#t$r%|t |jdd}YnwxYw t j||jd|jd\}}}n#t$rYdSwxYw||jdkrdS|jd|}|jds |jd r t|st|rdS|jdr#tt j ||}nH t j ||}n1#t$r$d dl }|j|YdSwxYw|S) z1Return value of text or False if text is invalid.rNrrrFr rrr)r4r removeprefixr:AttributeErrorlenr8siParserarrrsiApplyrrr)rMrr>siprefixrrs rQrzSpinBox.interprets}}##%% 3$$TYx%899DD 3 3 3DIh/00112DDD 3 $&JtTYw5GPTPYZbPc$d$d$d !C66   55  TYx( ( (5$di #C(( Ie   ( 3 %** c  5 9U  bjh//00CC jh//     //uu   s5 A ,A87A8<1B.. B<;B<E))*FFc ||jkrdS |}n#t$rYdSwxYw|durdS||jkrdS||ddS)zEdit has finished; set value.NFr)r4rr*rrar>r_)rMr>s rQrLzSpinBox.editingFinishedEvent?s ==??   ! !T] 2 2 F ..""CC    FF  %<< F $(?? F cu -----sA AAc|jds|ddStj|}|j|kr||_||dSdS)Nr!i@B)r:setMaximumHeightr QFontMetricsfontheightr-)rMhs rQrIzSpinBox._updateHeightNsy)   ! !' * * * F  tyy{{ + + 2 2 4 4  1 $ $#$D  ! !! $ $ $ $ $ % $rRcr|t|dSr)rIr paintEventrs rQrzSpinBox.paintEventYs3  2rR)Nr )T)NTF)+__name__ __module__ __qualname____doc__rSignalobjectrrrEr(rHrZrYrrqruryr}rrrrrrOr_rrFrrrrrrr?rrrrrLrIr __classcell__)rs@rQr r s<!6=((L#fmF++O$v}VV44F@F@F@F@P{{{z%%%"""  ''' RRR!!!    (((    ###4444l((( DDD$$$YYY>>>6    " " "!3!3!3F    D&&& ###J . . . % % %rRc*eZdZdZdZdZdZdZdS)r3zRed outline to draw around lineedit when value is invalid. (for some reason, setting border from stylesheet does not work) ctj|||||t jjj| | ddSNF) r QWidgetr(installEventFilter setAttributerQtWidgetAttributeWA_TransparentForMouseEvents_resizer)rMrNs rQr(zErrorBox.__init__bsp""4000!!$''' &)3PQQQ  rRc|tjjjkr|dSr)typerQEventTypeResizer)rMobjrs rQ eventFilterzErrorBox.eventFilteris/ 7799 *1 1 1 LLNNNurRc|dd||dS)Nr) setGeometryrNwidthrrns rQrzErrorBox._resizensJ At{{}}2244dkkmm6J6J6L6LMMMMMrRctj|}|tjdd|||dS)Nrr)colorr)rQPaintersetPenr8mkPendrawRectrectr)rMrrts rQrzErrorBox.paintEventqs] N4  1---... 499;; rRN)rrrrr(rrrr&rRrQr3r3^s] NNNrRr3)r6r\rmathrrrrr8rrrr r __all__r'r rr3r&rRrQrs ))))))))))%%%%%% +N N N N N i(N N N by rR