;i;%ndZddlZddlZddlmZmZdgZdZdZdZ d Z Gd dej Z dS) a WidgetGroup.py - WidgetGroup class for easily managing lots of Qt widgets Copyright 2010 Luke Campagnola Distributed under MIT/X11 license. See license.txt for more information. This class addresses the problem of having to save and restore the state of a large group of widgets. N)QtCore QtWidgets WidgetGroupc|}|SN) saveStatetoPercentEncodingdatadecode)wss IC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\pyqtgraph/WidgetGroup.py splitterStaters8 ''))..007799A Hct|tur||nxt|turE|t j|ntdt|| dkrM| D] }|dkrdS |dg| zdSdS)Nz.Can't configure QSplitter using object of typer2) typelistsetSizesstr restoreStater QByteArrayfromPercentEncodingencodeprintcountsizes)r ris rrestoreSplitterr s Aww$ 1 aC v(<QHHHwwyy1}}  A1uu B4!''))#$$$$$ }rc*|}||}|C |sd}n|d}n#t$rYnwxYw|"t ||S|S)Nr) currentIndexitemDataisValidtoIntAttributeErrorritemText)r indr s r comboStater)"s ..  C ::c??D  <<>> 'zz||A    D  |1::c??### s1A A,+A,ct|tur2||}|dkr||dS||t |dS)N)rintfindDatasetCurrentIndexfindTextr)r vr(s r setComboStater12sn Aww#~~jjmm 88  c " " " FajjQ(()))))rcXeZdZdZejdejjejjfejdejjejjfej de e dfej dej j ej jfejdeefejdejj ejjdfejd d ejjfejd ejj ejjfejd ejjejjfi ZejeeZdd ZddZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dS)raFState manager for groups of widgets. WidgetGroup handles common problems that arise when dealing with groups of widgets like a control panel: - Provide a single place for saving / restoring the state of all widgets in the group - Provide a single signal for detecting when any of the widgets have changed c|jSr valueChangedr s rzWidgetGroup.Manrc|jSrr4r6s rr7zWidgetGroup.Rr8rNTc|jSr) stateChangedr6s rr7zWidgetGroup.]r8rc|jSr)currentIndexChangedr6s rr7zWidgetGroup.bs a+rc|jSrtoggledr6s rr7zWidgetGroup.gairc|jSr)editingFinishedr6s rr7zWidgetGroup.ms a'rcDt|Sr)rtextr6s rr7zWidgetGroup.nsc!&&((mmrc|jSrr?r6s rr7zWidgetGroup.rrArc|jSrr4r6s rr7zWidgetGroup.wr8rc`tj|tj|_tj|_i|_tj|_t|tjr| |dSt|tr|D] }|j | dSt|tr2|D]\}}| ||dS|dStdt!|z)a%Initialize WidgetGroup, adding specified widgets into this group. widgetList can be: - a list of widget specifications (widget, [name], [scale]) - a dict of name: widget pairs - any QObject, and all compatible child widgets will be added recursively. The 'scale' parameter for each widget allows QSpinBox to display a different value than the value recorded in the group state (for example, the program may set a spin box value to 100e-6 and have it displayed as 100 to the user) NzWrong argument type %s)rQObject__init__weakrefWeakKeyDictionary widgetListscalescacheuncachedWidgets isinstanceautoAddr addWidgetdictitems Exceptionr)selfrMr names rrJzWidgetGroup.__init__s7 %%%!355/11  &8:: j&. 1 1 I LL $ $ $ $ $  D ) ) I # #""" # #  D ) ) I%++-- ( (aq$'''' ( (   F4tJ7G7GGHH Hrc||stdt|z|!t|}|dkrtdt|z||j|<||j|<||t|tj vr&tj t|d}n| d}|Otj |stj |r ||}||jdSd|j|<dS)Nz+Widget type %s not supported by WidgetGroupz&Cannot add widget '%s' without a name.r) acceptsTyperVrr objectNamerMrN readWidgetrclasseswidgetGroupInterfaceinspect isfunctionismethodconnect widgetChangedrP)rWr rXscalesignals rrSzWidgetGroup.addWidgetsD"" UIDQRGGSTT T <q||~~&&D 2::Ds1vvMNN N! A  77k) ) ) (a1!4FF++--a0F  !&)) #W-=f-E-E # NN4- . . . . .&*D  # # #rcD|jD]}|j||kr|cSdSr)rM)rWrXr s r findWidgetzWidgetGroup.findWidgets8  Aq!T))*trct|}|tjvrtj|S|Sr)rrr^r_)rWobjts r interfacezWidgetGroup.interfaces; II # # #&q) )++-- -rcb||}t|dko|dS)zSReturn true if we should automatically search the children of this object for more.)rllen)rWrjifaces rcheckForChildrenzWidgetGroup.checkForChildrens,s##E Q+58,rc||}|r|||r||r,|D]}||dSdSr)r[rSrqchildrenrR)rWrjacceptedcs rrRzWidgetGroup.autoAdds##C((  NN3    40055 \\^^   Q    rcntjD]}t||rdSt|drdSdS)NTr_F)rr^rQhasattr)rWrjrus rr[zWidgetGroup.acceptsTypesO$  A#q!! tt  3. / / 4urcp||}||j|<|||dSr)r]rN setWidget)rWwidgetrevals rsetScalezWidgetGroup.setScales9oof%%# F vs#####rc|}|j|}|j|}||}||kr(|j|j||dSdSr)senderrMrOr] sigChangedemit)rWargsr nv1v2s rrdzWidgetGroup.widgetChangedsl KKMM OA  Z] __Q   88 O !3R 8 8 8 8 8 8rcr|jD]}|||jSr)rPr]rOcopy)rWr s rstatezWidgetGroup.states;%  A OOA    z   rcv|jD]0}|j|}||vr||||1dSr)rMry)rWrr rs rsetStatezWidgetGroup.setStatesP $ $A"Azz NN1ad # # # #  $ $rct|tjvr&tjt|d}n|d}|dSt j|r|j |}n ||}|j|||j|z}|j|}||j |<|S)Nr) rrr^r_r`rb__self__rNrMrO)rWr getFuncr{rs rr]zWidgetGroup.readWidgets 77k) ) )!)$q''215GG,,..q1G ?4  G $ $ )9)E'))CC'!**C ;q> % 4;q> !C OA  1  rc^|j|||j|z}t|tjvr&tjt|d}n|d}t j|r|j ||dS|||dS)N)rNrrr^r_r`rbr)rWr r0setFuncs rryzWidgetGroup.setWidgets ;q> % Q A 77k) ) )!)$q''215GG,,..q1G  G $ $ )9)E GAJJJJJ GAqMMMMMrr)NN)*__name__ __module__ __qualname____doc__rQSpinBoxvaluesetValueQDoubleSpinBox QSplitterrr QCheckBox isChecked setChecked QComboBoxr)r1 QGroupBox QLineEditsetText QRadioButtonQSliderr^rSignalrobjectrrJrSrhrlrqrRr[r|rdrrr]ryrrrr;sB  $ $   $   '  $ $  $ *  $ -#        $ $   )   *  + +        )   *    ' ' # #   '     " ,  " -!  $ $   #   & W0GdsF++JIIII8++++. ...---    $$$ 999!!! $$$.r) rr`rKQtrr__all__rr r)r1rIrrrrrs!!!!!!!! /    % % % ***[[[[[&.[[[[[r