;i>RddlZddlmZddlmZdgZGddejZdS)N) OrderedDict) QtWidgetsComboBoxceZdZdZddZdZdZdZdZdZ ee d Z d Z d Z d Z d ZdZedZedZedZdZee dZedZdZdZdZdS)raExtends QComboBox to add extra functionality. * Handles dict mappings -- user selects a text key, and the ComboBox indicates the selected value. * Requires item strings to be unique * Remembers selected value if list is cleared and subsequently repopulated * setItems() replaces the items in the ComboBox and blocks signals if the value ultimately does not change. Nctj|||j|jd|_dtjvr)| tjj j d|_ t|_|.|||||dSdSdS)NFdarwin)r QComboBox__init__currentIndexChangedconnect indexChanged_ignoreIndexChangesysplatformsetSizeAdjustPolicySizeAdjustPolicyAdjustToContents _chosenTextr_itemssetItemssetValue)selfparentitemsdefaults NC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\pyqtgraph/widgets/ComboBox.pyr zComboBox.__init__s$$T6222  (():;;;"' s| # #  $ $Y%8%I%Z [ [ [!mm   MM% " g&&&&&  ""cd}|jD]\}}||kr|}n|t|||dS)z>Set the selected item to the first one having the given value.N)rr ValueErrorsetText)rvaluetextkvs rrzComboBox.setValue%sm;$$&&  CAaEzz <U## # Trc||}|dkrt|||dS)z=Set the selected item to the first one having the given text.N)findTextr setCurrentIndex)rr#inds rr!zComboBox.setText1sDmmD!! "99T"" " S!!!!!rcx|dkrdS|}|j|S)a If items were given as a list of strings, then return the currently selected text. If items were given as a dict, then return the value corresponding to the currently selected key. If the combo list is empty, return None. rN)count currentTextr)rr#s rr"zComboBox.value9s: ::<<1  4!!{4  rcfd}|S)Ncf|j}d|_ |g|Ri|}||_n #||_wxYw|SNT)r)rargskwdsprevretfuncs rfnz&ComboBox.ignoreIndexChange..fnGs[*D&*D # /d4/$///$//*.''$'....Js % .r5r6s` rignoreIndexChangezComboBox.ignoreIndexChangeEs#      rcfd}|S)Nc|}|}|d |g|Ri|}||n#||wxYw||kr,|j||Sr0)r"signalsBlocked blockSignalsr emit currentIndex)rr1r2prevValblockedr4r5s rr6z%ComboBox.blockIfUnchanged..fnUsjjllG))++G   d # # # +d4/$///$//!!'****!!'****zz||w&&(--d.?.?.A.ABBBJs A""A9r7r8s` rblockIfUnchangedzComboBox.blockIfUnchangedQs#      rcX|||dS)z *items* may be a list, a tuple, or a dict. If a dict is given, then the keys are used to populate the combo box and the values will be used for both value() and setValue(). N)clearaddItemsrrs rrzComboBox.setItemses)  erc4|jSN)rcopyrs rrzComboBox.itemspsz   rc,||SrH)rrFs r updateListzComboBox.updateListss}}U###rcJ|jrdS||_dSrH)rr-rrindexs rrzComboBox.indexChangedws,  "  F++--rcFtj||dSrH)rr r)rNs rr)zComboBox.setCurrentIndex}s!++D%88888rcp|j. ||jdS#t$rYdSwxYwdSrH)rr!r rJs r itemsChangedzComboBox.itemsChangedsU   '  T-.....     ( 's % 33ctrHNotImplementedErrorrr1s r insertItemzComboBox.insertItem!###rctrHrTrVs r insertItemszComboBox.insertItemsrXrc t|dtr;|d}t|dkr |d}nQ|d|}n:|d}t|dkr |d}n|d|}n#t$rt dwxYw||jvrtd|z||j|<tj j |g|R| dS)Nrrr"z5First or second argument of addItem must be a string.%ComboBox already has item named "%s".) isinstancestrlenget IndexError TypeErrorr Exceptionrr addItemrR)rr1r2r#r"s rrfzComboBox.addItems U$q'3'' 4Awt99>> GEE HHWd33EEAwt99>> GEE HHWd33E U U USTT T U 4;  CdJKK K! D#D040000 s BBB-c\||jvr|||dS||j|<dSrH)rrf)rnamer"s r setItemValuezComboBox.setItemValues; t{ " " LLu % % % % % %DK   rcHt|tst|tr|}td|D}nVt|tr"t|}nt dt |z|D]}||jvrtd|z| D]\}}||j|<tj |t|| dS)Ncg|]}||fSr7r7).0xs r z%ComboBox.addItems..s000Q1a&000rz6items argument must be list or dict or tuple (got %s).r^)r_listtupledictkeysrdtyperrerrr rErR)rrtextstr$r%s rrEzComboBox.addItemss, eT " " dj&>&> dE00%00011EE t $ $ d&&EETW[\aWbWbbcc c M MADK G! KLLL ;;==  CAaDKNN$$T4;;777 rct|_tj||dSrH)rrrr rDrRrJs rrDzComboBox.clears<!mm !!$''' rc|}||}|C |sd}n|d}n#t$rYnwxYw|||S|S)Nr)r?itemDataisValidtoIntAttributeErroritemText)rr*datas r saveStatezComboBox.saveStates!!}}S!!   ||~~+DD::<<?D!     <==%% %Ks1A A,+A,ct|tur2||}|dkr||dS||t |dS)Nr')rsintfindDatar)r(r`)rr%r*s r restoreStatezComboBox.restoreStatesp 77c>>--""CRxx$$S))) T]]3q662233333rc*|j|j|jfSrH)r r~rrJs rwidgetGroupInterfacezComboBox.widgetGroupInterfaces($.$:KLLr)NNN)__name__ __module__ __qualname____doc__r rr!r"r9rBrrrLrr)rRrWrZrfrirErDr~rrr7rrrrs''''"   """ ! ! !   (!!!$$$... 999$$$ $$$ 4&&& ( "444MMMMMr)r collectionsrQtr__all__r rr7rrrs ###### ,cMcMcMcMcMy"cMcMcMcMcMr