Fa%@sVdZddlTddljZddljZddlj Z ddl m Z ddl mZddlmZddlmZddlmZdd lmZdd lmZdd lmZGd d d eZdZddiZddZGddde Z!e"dkrRddl#Z#e#j$dddddddl%m&Z&e&edS)aIDLE Configuration Dialog: support user customization of IDLE by GUI Customize font faces, sizes, and colorization attributes. Set indentation defaults. Customize keybindings. Colorization and keybindings can be saved as user defined sets. Select startup options including shell/editor and default window size. Define additional help sources. Note that tab width in IDLE is currently fixed at eight due to Tk issues. Refer to comments in EditorWindow autoindent code for details. )*N)idleConf) DynOptionMenu) GetKeysDialog)GetCfgSectionNameDialog)GetHelpSourceDialog) TabbedPageSet) view_text) macosxSupportc@seZdZdddddZddZddZd d Zd d Zd dZddZ ddZ ddZ ddZ ddZ ddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Zd=d>Z d?d@Z!dAdBZ"dCdDZ#dEdFZ$dGdHZ%dIdJZ&dKdLZ'dMdNZ(dOdPZ)dQdRZ*dSdTZ+dUdVZ,dWdXZ-dYdZZ.d[d\d]Z/d^d_Z0d`daZ1dbdcZ2dddeZ3dfdgZ4dhdiZ5djdkZ6dldmZ7dndoZ8dpdqZ9drdsZ:dtduZ;dvdwZ<dxdyZ=dzd{Z>d|d}Z?d~dZ@ddZAddZBddZCddZDddZEddZFddZGddZHddZIddZJddZKddZLddZMddZNddZOd[S) ConfigDialogFcCs|tj||||_|r(i|_|j|jdd|j|pQd|jd|jd|j |sdndfdd6d d7dd8dd9dd:dd;dd<dd=d d>d#d?d&d@d)dAd,dBd/dCi|_ |j |j |j d2td3t|j||j|jd4|j|jj|j|j|sx|j|jd5S)Dz _htest - bool, change box location when running htest _utest - bool, don't wait_window when running unittest borderwidthzIDLE Preferencesz+%d+%dz Normal Textnormal00zPython Keywordskeyword01zPython Definitions definition02zPython Builtinsbuiltin03zPython Commentscomment04zPython Stringsstring05z Selected Texthilite06z Found Texthit07Cursorcursor08zEditor Breakpointbreak09zShell Normal Textconsole10zShell Error Texterror11zShell Stdout Textstdout12zShell Stderr Textstderr13heightwidthZWM_DELETE_WINDOWN)rr)rr)rr)rr)rr)rr)rr)r r!)r#r$)r%r&)r'r()r)r*)r+r,)r-r.)Toplevel__init__parent instance_dictZ wm_withdraw configuretitleZgeometryZ winfo_rootxZ winfo_rooty themeElementsResetChangedItems CreateWidgetsZ resizableFALSEZ transientZgrab_setZprotocolCanceltabPagesZ focus_set LoadConfigsAttachVarCallbacksZ wm_deiconifyZ wait_window)selfr3r6Z_htestZ_utestr@*/usr/lib/python3.5/idlelib/configDialog.pyr2sH   !        zConfigDialog.__init__cCst|ddddddg|_|jjdtdtd t|j|j|j|j |j |j jdt dS) NZ page_namesz Fonts/Tabs HighlightingKeysGeneral Extensionssideexpandfill) rr<packTOPTRUEBOTHCreatePageFontTabCreatePageHighlightCreatePageKeysCreatePageGeneralCreatePageExtensionscreate_action_buttonsBOTTOM)r?r@r@rAr9Qs       zConfigDialog.CreateWidgetsc Cstjri}nddddi}t|dd}t|dd}xud|jfd|jfd|jfd |jffD]=\}}t|d |d |d t|j d t ddqWt|ddddj d t |j d t |S)NpadxpadyOkApplyr;Helptextcommand takefocusrFrr/r r) r ZisAquaTkFramerYrZr;r[Buttonr:rILEFTrJrS)r?Z paddingArgsZouterZbuttonsZtxtcmdr@r@rArR]s     "z"ConfigDialog.create_action_buttonsc Cs|j}t||_t||_t||_t||_tj |d+|_ |j j dj }t|dddtdd }t|dddtdd }t|}t|}t|d tdd }t|d ddtdt|_|jjd|jt|}|jd|jj|jjd|jt|dd} t||jdd|j|_t|d|jddddddd|j} t|dt dd} t| d td|j dd|_!t|} t| d tdd} t"| d|jddd dd!dd"d#|_#|j$d$td%dd&dd't%d(t&|j$d$td%dd&dd(t'|j$d$t(d%dd&dd(t)|j$d$t(d%dd&dd(t)|j$d$t(d)t*|jj$d$td't%d(t)|j$d$td(t'| j$d$td)t*|jj$d$td)t*| j$d$td)t*d%d*| j$d$t(d%dd&dd't%d(t&|j!j$d't%d(t&| j$d$t(d(t)| j$d$t(d)t*d%d|j#j$d$t(d%dd(t)|S),Ncourier rz Fonts/Tabsr rXreliefr\z Base Editor Font z Indentation Width Zjustifyz Font Face :r/rr^exportselectionzr]yscrollcommandzSize :variableonvalueoffvaluerZBoldfontz,AaBbCcDdEe FfGgHhIiJjK 1234567890 #:+=(){}[]zPython Standard: 4 Spaces!orientZ horizontalZ tickintervalZfrom_ZtorFrTrVrGrHanchorr)rcrdr)+r3 StringVarfontSize BooleanVarfontBoldfontNameIntVarspaceNumtkFontZFontZeditFontr<pagesframe LabelFrameGROOVEr_LabelraListboxr: listFontNamebindOnListFontButtonRelease Scrollbarconfigyviewsetr SetFontSampleoptMenuFontSize CheckbuttonSOLIDlabelFontSampleZScaleZ scaleSpaceNumrIrKrLYrJXW)r?r3ryZ frameFontZ frameIndentZ frameFontNameZframeFontParamZlabelFontNameTitleZ scrollFontZlabelFontSizeTitleZ checkFontBoldZframeFontSampleZframeIndentSizeZlabelSpaceNumTitler@r@rArMrsn          ("""(zConfigDialog.CreatePageFontTabc!Cs|j}t||_t||_t||_t||_t||_t||_t||_ |j j dj }t |dddtdd}t |dddtdd}t|dtddd d\d ddddddtdddt |_|j}|jddd|jdddd}}x)|D]!}|jt|d|dqHWx>|jD]3}|dBdC} |j|j|ddD| qwW|jdEtt|dtdd|_t|} t|jddFdG|jdd} t|j|j ddd|_ t!| dH|jdIdddJdG|j"|_#t!| dH|jdIdddKdG|j"|_$|jj%dt|ddLdG|j&} t'|ddM} t!|dH|jdIddG|j(ddN|_)t!|dH|jdIddG|j(ddO|_*t||jddGd|_+t||jddGd|_,t|ddPdG|j-|_.t'|dQd|_/|j0dRt1dSdTdUdTdVt2dWt3|j0dRt1dSdTdUdTdWt4|jj0dRt5dSdTdUdTdVt2dWt6| j0dRt5dSdTdUd|jj0dRt5dSdTdUdTdVt2dWt3| j0dRt5dVt2dWt6dSdXdUdY|j j0dRt5dVt2dWt6dSdXdUdZ|j#j0dRt1d[t7|j$j0dRt8d[t9| j0dRt:dWt6dSdTdUdT| j0dRt5d[t9dSdTdUdT|j)j0dRt5d[t9dSdT|j*j0dRt5d[t9dSdTdUd|j+j0dRt5dWt6dSdTdUdT|j,j0dRt5dWt6d[t9dSdTdUdT|j.j0dRt5dWt6dSdTdUdT|j/j0dRt5dWt6dUdT|S)~NrBr rXrer\z Custom Highlighting z Highlighting Theme rjrlrc r r#Zhand2r0r/ r^highlightthicknessrZwrapzcSsdS)Nr%r@)er@r@rAsz2ConfigDialog.CreatePageHighlight..z cSsdS)Nr%r@)rr@r@rArs#you can click herer r#to choose itemsdefr funcr (param): """string"""r var0 = 'string' var1 = 'selected'r var2 = 'found'r var3 = listr(None)  breakpoint("line")r%  error r)cursor | shellr'r+r-cSs|jjjj|dS)N)ZwidgetZwinfo_toplevelhighlightTargetr)eventelemr@r@rAtemsz-ConfigDialog.CreatePageHighlight..temzstatezChoose Colour for :r]rhvalueZ ForegroundZ BackgroundzSave as New Custom Themez Select : za Built-in Themeza Custom ThemezDelete Custom ThemebdrFrTrrVrGrHrWro)rcrr rrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrr%rrrr)rrrr#rrrr'rrr+r+rrr-r-rr) rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr);r3rp builtinTheme customThemerrfgHilitecolourrtthemeIsBuiltinrr<rxryrzr{ZTextrr:ZNONEtextHighlightSamplerinsertENDr7Ztag_bindrDISABLEDr_frameColourSetr` GetColourroptMenuHighlightTarget RadiobuttonSetColourSampleBindingradioFgradioBgrSaveAsNewThemer| SetThemeTypeZradioThemeBuiltinradioThemeCustomoptMenuThemeBuiltinoptMenuThemeCustomDeleteCustomThemebuttonDeleteCustomThemenew_custom_themerIrarKrLrrJrERIGHTrrS)r?r3ry frameCustomZ frameThemer\Z textAndTagsZtxTaelementrZ frameFgBgZbuttonSetColourZbuttonSaveCustomThemeZlabelTypeTitler@r@rArNs          ("+ ( ""%%+%z ConfigDialog.CreatePageHighlightc s|j}t||_t||_t||_t||_t||_|jj dj }t |dddt dd}t |dddt ddt |}t|dd}t|}t|d t}t|d td t|_|jjd |j|jd |jj|jd |jj|jjd|j|jjd|jt|ddd |jdt|_fddtdD}t|dd|jddd |j dd|_!t|dd|jddd |j dd|_"t#|d|jdd d|_$t#|d|jdd d|_%t|dddd |j&|_'t|dddd |j(} |j)dt*ddddd t+d!t,j)dt*ddddd!t,|jj)dt*d!t-dddd|j)dt.ddddd t+d!t,|j/dd"d|j0dd"d|j1d#dd$dd%dd&t2|jj1d#dd$dd&t3|j1d#dd$dd&t4|j1d#dd$dd&t5|j!j1d#dd$dd&t2t4|j"j1d#dd$dd&t2t4|j$j1d#dd$dd&t3|j%j1d#dd$dd&t3|j'j)dt.d!t-d d'dd| j)dt.d!t-d d'dd|dj)dt6d!t,d d'|dj)dt6d!t-d d'dd|S)(NrCr rXrer\z Custom Key Bindings z Key Set zAction - Key(s)rmr^rfzr]rgZxscrollcommandzGet New Keys for Selectionrc s.g|]$}tddddddqS)rTrXrVr r)r_).0i) frameKeySetsr@rA Fs z/ConfigDialog.CreatePageKeys..rrhrrjzUse a Built-in Key SetzUse a Custom Key SetzDelete Custom Key SetzSave as New Custom Key SetrFrTrrVrGrHweightrowcolumnZ columnspanstickyT)7r3rpZ bindingTarget builtinKeys customKeysrrkeysAreBuiltin keyBindingr<rxryrzr{r_r|rZ HORIZONTALr}r: listBindingsrKeyBindingSelectedrrZxviewrr` GetNewKeysr buttonNewKeysranger SetKeysTypeZradioKeysBuiltinradioKeysCustomroptMenuKeysBuiltinoptMenuKeysCustomDeleteCustomKeysbuttonDeleteCustomKeysSaveAsNewKeySetrIrSrKrLrracolumnconfigure rowconfiguregridrNSEWZNSZEWrJ) r?r3ryrZ frameTargetZlabelTargetTitleZ scrollTargetYZ scrollTargetXZframesZbuttonSaveCustomKeysr@)rrArO%s~      ("%("##%" &zConfigDialog.CreatePageKeysc Cs |j}t||_t||_t||_t||_t||_t||_ t||_ |j j dj }t|dddtdd}t|dddtdd}t|dddt}t|dddtdd}t|dd }t|d |jd d d |jdd}t|d |jd dd |jdd} t|dd} t|d |jd dd |jdd} t|d |jd d d |jdd} t|dd} t|dd}t|d|jdd}t|dd}t|d|jdd}t|}t|}t|}t|dddtdt|_|jd |jj|jjd|j|jjd|jt|dd d!tdd"d |j |_!t|dd#dd"d |j"|_#t|dd$d!tdd"d |j$|_%|j&d%t'd&dd'dd(t(|j&d%t'd&dd'dd(t(|j&d%t'd&dd'dd(t(|j&d%t'd&dd'dd)t)d(t*|j&d%t+d*t,d&dd'd| j&d%t-d*t,d&dd'd|j&d%t-d*t,d&dd'd| j&d%t+d*t,d&dd'd| j&d%t-d*t,d&dd'd| j&d%t-d*t,d&dd'd| j&d%t+d*t,d&dd'd|j&d%t-d*t.d&d+d'd|j&d%t-d*t.d'd|j&d%t-d*t.d&d+d'd|j&d%t-d*t.d'd|j&d%t-d&dd'dd(t/|j&d%t'd&dd'dd)t)d(t*|j&d%t-d*t,d(t/|jj&d%t+d*t.d)t)d(t*|j!j&d%t'd*t,d'd|j#j&d%t'd*t,|j%j&d%t'd*t,d'd|S),NrDr rXrer\z Startup Preferences z Autosave Preferences z Additional Help Sources z At Startuprhrrjr]zOpen Edit WindowrzOpen Shell WindowzAt Start of Run (F5) zPrompt to Savez No Promptz$Initial Window Size (in characters)ZWidth textvariabler0rWZHeightr/rr^rfrgzZEditrrZAddZRemoverFrTrVrHrGrord)0r3rpwinWidth winHeightru startupEditautoSaveencodingrrZuserHelpBrowserZ helpBrowserr<rxryrzr{r_r|rrEntryrr}r:listHelprrrrHelpSourceSelectedr`rHelpListItemEditbuttonHelpListEditHelpListItemAddZbuttonHelpListAddHelpListItemRemovebuttonHelpListRemoverIrJrrKrLrarrrr)r?r3ryZframeRunZ frameSaveZ frameWinSizeZ frameHelpZlabelRunChoiceTitleZradioStartupEditZradioStartupShellZlabelRunSaveTitleZ radioSaveAskZ radioSaveAutoZlabelWinSizeTitleZlabelWinWidthTitleZ entryWinWidthZlabelWinHeightTitleZentryWinHeightZ frameHelpListZframeHelpListButtonsZscrollHelpListr@r@rArPrs         """(""""""""""(%zConfigDialog.CreatePageGeneralcCs|jjd|j|jjd|j|jjd|j|jjd|j|jjd|j|j jd|j |j jd|j |j jd|j|jjd|j|jjd|j|jjd|j|jjd|j|jjd|j|jjd|j|jjd|j|jjd|j|jjd|j |j!jd|j"dS)Nw)#rqZtrace_variableVarChanged_fontrtrsrvVarChanged_spaceNumrVarChanged_colourrVarChanged_builtinThemerVarChanged_customThemerVarChanged_themeIsBuiltinrVarChanged_highlightTargetrVarChanged_keyBindingrVarChanged_builtinKeysrVarChanged_customKeysrVarChanged_keysAreBuiltinrVarChanged_winWidthrVarChanged_winHeightrVarChanged_startupEditrVarChanged_autoSaverVarChanged_encoding)r?r@r@rAr>s$zConfigDialog.AttachVarCallbackscCsx|j|j|j|j|j|j|j|j|j|j |j |j |j |j |j|j|j|jfD]$}|jd|jddqsWdS)z)Remove callbacks to prevent memory leaks.rrrjN)rqrtrsrvrrrrrrrrrrrrrrZ trace_vdeleteZ trace_vinfo)r?varr@r@rAremove_var_callbackssz!ConfigDialog.remove_var_callbackscGss|jj}|jddd||jj}|jddd||jj}|jddd|dS)zWhen one font attribute changes, save them all, as they are not independent from each other. In particular, when we are overriding the default font, we need to write out everything. main EditorWindowrlz font-sizez font-boldN)rtgetAddChangedItemrqrs)r?paramsrr@r@rArs zConfigDialog.VarChanged_fontcGs)|jj}|jddd|dS)Nr.Indentz num-spaces)rvr0r1)r?r2rr@r@rArsz ConfigDialog.VarChanged_spaceNumcGs|jdS)N)OnNewColourSet)r?r2r@r@rArszConfigDialog.VarChanged_colourcGs|jj}|dkr~tjddddkrL|jdddd|jddd||jjdd d d nE|jddd||jdddd |jjdd d d |jdS)Nz IDLE Darkr.ThemenamezIDLE Newz IDLE ClassicZname2r\zNew theme, see HelpZfgz#500000r Zblack)rr0r GetOptionr1rrPaintThemeSample)r?r2rr@r@rArs  z$ConfigDialog.VarChanged_builtinThemecGs?|jj}|dkr;|jddd||jdS)Nz- no custom themes -r.r5r6)rr0r1r8)r?r2rr@r@rAr s z#ConfigDialog.VarChanged_customThemecGsF|jj}|jddd||r8|jn |jdS)Nr.r5default)rr0r1rr )r?r2rr@r@rAr!s  z&ConfigDialog.VarChanged_themeIsBuiltincGs|jdS)N)SetHighlightTarget)r?r2r@r@rAr" sz'ConfigDialog.VarChanged_highlightTargetcGs|jj}|jj}|jjtjd}tj|rb|jd|||n/tj |}|d}|jd|||dS)NrkeysZ _cfgBindings extensions) rr0rrANCHORsplitrZ IsCoreBindingr1ZGetExtnNameForEvent)r?r2rkeySetrZextNameZextKeybindSectionr@r@rAr##s z"ConfigDialog.VarChanged_keyBindingcGs6|jj}|jddd||j|dS)Nr.rCr6)rr0r1 LoadKeysList)r?r2rr@r@rAr$/sz#ConfigDialog.VarChanged_builtinKeyscGsB|jj}|dkr>|jddd||j|dS)Nz- no custom keys -r.rCr6)rr0r1r@)r?r2rr@r@rAr%4s z"ConfigDialog.VarChanged_customKeyscGsF|jj}|jddd||r8|jn |jdS)Nr.rCr9)rr0r1r$r%)r?r2rr@r@rAr&:s  z&ConfigDialog.VarChanged_keysAreBuiltincGs)|jj}|jddd|dS)Nr.r/r0)rr0r1)r?r2rr@r@rAr'Bsz ConfigDialog.VarChanged_winWidthcGs)|jj}|jddd|dS)Nr.r/r/)rr0r1)r?r2rr@r@rAr(Fsz!ConfigDialog.VarChanged_winHeightcGs)|jj}|jddd|dS)Nr.rDzeditor-on-startup)rr0r1)r?r2rr@r@rAr)Jsz#ConfigDialog.VarChanged_startupEditcGs)|jj}|jddd|dS)Nr.rDautosave)rr0r1)r?r2rr@r@rAr*Nsz ConfigDialog.VarChanged_autoSavecGs)|jj}|jddd|dS)Nr.r/r)rr0r1)r?r2rr@r@rAr+Rsz ConfigDialog.VarChanged_encodingcCs%didididii|_dS)Nr. highlightr;r<) changedItems)r?r@r@rAr8VszConfigDialog.ResetChangedItemscCsIt|}||j|kr0i|j||<||j|||rrrrZGetCurrentKeySetrCrvaluesrresultGetNewKeysName select_set select_anchorCreateNewKeySetdeleterrr) r? listIndexbindingbindNameZcurrentKeySetNameZcurrentBindings keySetChangesrZcurrentKeySequencesnewKeysmessage newKeySetr@r@rArs<     zConfigDialog.GetNewKeyscCs>tjddtjdd}t|d||j}|S)Nuserr;r9zNew Custom Key Set)rrHrrR)r?r] usedNamesr^r@r@rArSs zConfigDialog.GetNewKeysNamecCs&|jd}|r"|j|dS)NzNew Key Set Name:)rSrV)r?Z newKeysNamer@r@rArszConfigDialog.SaveAsNewKeySetcCs|jjdtdS)Nr)rrrO)r?rr@r@rArszConfigDialog.KeyBindingSelectedc Cs#|jjr!|jj}n|jj}tj|}i}x;|D]3}|dd}dj||}|||tjddtjdd}t|d||j}|S)Nr_rBr9zNew Custom Theme)rrHrrR)r?r]r`rzr@r@rArwDs zConfigDialog.GetNewThemeNamecCs&|jd}|r"|j|dS)NzNew Theme Name:)rwrx)r? newThemeNamer@r@rArKszConfigDialog.SaveAsNewThemecCs|jjr'd}|jj}nd}|jj}tj||}||jdkr|jd|}x|D]}|||||jjdt|jjdtn^|jjrv|jjdt|jjdtn&|jjdt|jjdtdS)Nrjr)rsizerrrrrfrO)r?r@r@rArsz$ConfigDialog.SetHelpListButtonStatescCset|dj}|rW|jj|d|df|jjt|d|j|jdS)NzNew Help Sourcerrj) rrR userHelpListappendrrrUpdateUserHelpChangedItemsr)r? helpSourcer@r@rArs  zConfigDialog.HelpListItemAddcCs|jjt}|j|}t|dd|dd|dj}| sX||kr\dS||j|<|jj||jj||d|j|j dS)NzEdit Help SourceZmenuItemrZfilePathrj) rrPr=rrrRrWrrr)r? itemIndexrZ newHelpSourcer@r@rArs   zConfigDialog.HelpListItemEditcCsD|jjt}|j|=|jj||j|jdS)N)rrPr=rrWrr)r?rr@r@rArs   zConfigDialog.HelpListItemRemovec Csvi|jdd.789r(r*r,r.1416182022) rrrr(r*r,r.rrrrr)rrwZfamiliesrdr~rrrZGetFontrrtrrPrgrTrU ValueErrorrrersr) r?ZfontsrlZconfiguredFontrtrqrsZlc_fontsZcurrentFontIndexr@r@rA LoadFontCfgs*      zConfigDialog.LoadFontCfgcCs5tjddddddd}|jj|dS)Nr.r3z num-spacesr9rtypeint)rr7rvr)r?rvr@r@rA LoadTabCfgszConfigDialog.LoadTabCfgc sjjtjdddddddtj}jjrtjdd}|jjj ||tjdd}|j|sj j d t j jd q9jj ||d nbtjdd}|jjj ||tjdd}|jjj ||d jtjj}|jd fd djj ||d jjdS)Nr.r5r9rboolrjrBr_rz- no custom themes -rricsj|dS)Nrj)r7)x)r?r@rArsz+ConfigDialog.LoadThemeCfg..)rrrr7Z CurrentThemer0rHrdrrerrrrrrrr7r;rr8r:)r? currentOptionrsZ themeNamesr@)r?rA LoadThemeCfgs2       zConfigDialog.LoadThemeCfgc Cs`|jjtjdddddddtj}|jjrtjdd}|j|jj ||tjdd}|j|s|j j d t |j jd q9|jj ||d nbtjdd}|j|jj ||tjdd}|j|jj ||d |jtj}|j|dS) Nr.rCr9rrrjr;r_rz- no custom keys -r)rrrr7Z CurrentKeysr0rHrdrrerrrrrrr@)r?rrsrhr@r@rA LoadKeyCfgs,       zConfigDialog.LoadKeyCfgc Cs |jjtjddddddd|jjtjddddd dd|jjtjdd d dd |jjtjdd d dd |jjtjdd dddtj|_ x(|j D]}|j j t |d qW|j dS)Nr.rDzeditor-on-startupr9rjrrrArr/r0rr/rZnone)rrrr7rrrrZGetAllExtraHelpSourcesListrrrrr)r?ZhelpItemr@r@rALoadGeneralCfg2szConfigDialog.LoadGeneralCfgcCs6|j|j|j|j|jdS)z load configuration from default and user config files and populate the widgets on the config dialog pages. N)rrrrr)r?r@r@rAr=Gs     zConfigDialog.LoadConfigscCsctjdj|s*tjdj|x2|D]*}||}tjdj|||q1WdS)z save a newly created core key set. keySetName - string, the name of the new key set keySet - dictionary containing the new key set r;N)rrm has_section add_section SetOption)r?rhr?rrr@r@rArcWs   zConfigDialog.SaveNewKeySetcCsctjdj|s*tjdj|x2|D]*}||}tjdj|||q1WdS)z save a newly created theme. themeName - string, the name of the new theme theme - dictionary containing the new theme rBN)rrmrrr)r?rtrrrr@r@rArcs   zConfigDialog.SaveNewThemecCsitj|j||rOtj|j|||krOtj|j||Stj|j|||S)N)rrIZ has_optionrKrm RemoveOptionr)r?rLrFrGrr@r@rA SetUserValueoszConfigDialog.SetUserValuecCstjdjx|jD]}d}x|j|D]{}|dkratjdjdd}xL|j||D]9}|j|||}|j||||rsd}qsWq5W|rtj|jqWx%ddgD]}tj|jqW|j|jdS)z3Save configuration changes to the user config file.r.FrTr;rBN)rrmrorCrnrr8save_all_changed_extensions)r?rLZcfgTypeHasChangesrFrGrr@r@rArpws"  z"ConfigDialog.SaveAllChangedConfigscCs1|jjj}x|D]}|jqWdS)N)r3r4r;ZRemoveKeybindings)r? winInstancesinstancer@r@rArls z$ConfigDialog.DeactivateCurrentConfigcCsY|jjj}x@|D]8}|j|j|j|j|jqWdS)z'Dynamically apply configuration changesN)r3r4r;ZResetColorizerZ ResetFontZset_notabs_indentwidthZApplyKeybindingsZreset_help_menu_entries)r?rrr@r@rArqs     z"ConfigDialog.ActivateConfigChangescCs|jdS)N)destroy)r?r@r@rAr;szConfigDialog.CancelcCs|j|jdS)N)rZr)r?r@r@rArYs zConfigDialog.OkcCs"|j|j|jdS)N)rlrprq)r?r@r@rArZs  zConfigDialog.Applyc Cs6|jj}t|dddttj|ddS)Nr6zHelp for IDLE preferencesr\r )r<Z _current_pager help_common help_pagesr0)r?Zpager@r@rAr[s zConfigDialog.Helpc Cs|j}|jjdj}tjd|_tjd|_|j t |_ |j t ||_ |jddd|jdddt|d|j dd |_|jjd |jt|d |jj}|j|j_t|d d dd |_|jjdddddd|jdddddd|jjdddddddddg|jddddi|_d|_||_|j|_d}x6t |j!D]%}|j"||d|d}qW|j j||jj#d|jddS)aPart of the config dialog used for configuring IDLE extensions. This code is generic - it works for any and all IDLE extensions. IDLE extensions save their configuration options using idleConf. This code reads the current configuration using idleConf, supplies a GUI interface to change the configuration values, and saves the changes using idleConf. Not all changes take effect immediately - some may require restarting IDLE. This depends on each extension's implementation. All values are treated as text, and it is up to the user to supply reasonable values. The only exception to this are the 'enable*' options, which are boolean, and can be toggled with a True/False button. rEr<rrrjrXZ listvariableZ selectmodeZbrowsez<>r]r0r/rrrZnwsnsnsewrTrdrVNr {z} )$r3r<rxryrrIext_defaultCfgrm ext_userCfgregisteris_intload_extensionsrpZextension_namesr r r}extension_listrextension_selectedrrrrgrz details_framer r5 config_framecurrent_extensionZ outerframeZtabbed_page_setsortedr<create_extension_frameZ selection_set)r?r3ryZscrollZ ext_namesext_namer@r@rArQs<   +     z!ConfigDialog.CreatePageExtensionsc #Csi|_x'tjddD]}g|j|.rawTTrueFalserrNrr9r6rr,)r<rZ GetExtensionsrrrJremoverKKeyErrorrrrrprrDr) r?rZopt_listZenablesrZdef_strZdef_objZopt_typerr,r@r@rArsF               zConfigDialog.load_extensionscCs|jj}|r'|jj|}|dksB||jkr{|jr{|jjdd|j|jjd|_|r|jjd||j|jdddddd||_dS)Nr\r rrrrr) rrfr0rrrrZ grid_forgetr )r?rZnewselr@r@rArs  #zConfigDialog.extension_selectedcCs~t|jdddd}||j|<|j}xFt|j|D]1\}}t|d|d}|jd|ddd t|d }|d d krt |d |d|dddddt ddddjd|ddd t ddqE|d dkrHt |d |ddd|j dfjd|ddd tddqEt |d |jd|ddd tddqEWdS) z=Create a frame holding the widgets to configure one extensionr/rr0r\r6rrrrr,rrr rhrirrkrZ indicatoronZ selectcolorr rrjrTrZvalidateriZvalidatecommandz%PN)VerticalScrolledFramerrinterior enumerater<r|r NWrr:rrrr )r?rfZ entry_arearoptZlabelr,r@r@rArs&     z#ConfigDialog.create_extension_framecCsv|d}|d}|djjp-|}|dj|||kr`|jj||S|jj|||S)Nr6r9r,)r0striprrrr)r?rFrr6r9rr@r@rAset_extension_value9s   z ConfigDialog.set_extension_valuecCsgd}xG|jD]<}|j|}x&|D]}|j||r*d}q*WqW|rc|jjdS)z3Save configuration changes to the user config file.FTN)r<rrro)r?Z has_changesrrMrr@r@rArEs  z(ConfigDialog.save_all_changed_extensions)P__name__ __module__ __qualname__r2r9rRrMrNrOrPr>r-rrrrr r!r"r#r$r%r&r'r(r)r*r+r8r1rNrrrrSrrrVr@rrrr4rwrrxrrr:rrr8rrrrrrrrrrrr=rcrrrprlrqr;rYrZr[rQrrrrrr@r@r@rAr s 5  D o M `                 $                       !           5 -   r ahWhen you click either the Apply or Ok buttons, settings in this dialog that are different from IDLE's default are saved in a .idlerc directory in your home directory. Except as noted, these changes apply to all versions of IDLE installed on this machine. Some do not take affect until IDLE is restarted. [Cancel] only cancels changes made since the last save. rBz Highlighting: The IDLE Dark color theme is new in October 2015. It can only be used with older IDLE releases if it is saved as a custom theme, with a different name. c Cs9|s dSyt|dSWntk r4dSYnXdS)z(Return 's is blank or represents an int'TFN)rr)rr@r@rArcs  rc@s"eZdZdZddZdS)rzA pure Tkinter vertically scrollable frame. * Use the 'interior' attribute to place widgets inside the scrollable frame * Construct and pack/place/grid normally * This frame only allows vertical scrolling c s6tj||||t|dt}|jdtdtdtt|ddddd|j d d jdt dt dt |j d jjdjdt|_jddd d tfdd}jd|fdd}jd|dS)NrmrHrFrGrrrrgr0r]Zwindowrocs0jjf}jdd|dS)NZ scrollregionz 0 0 %s %s)winfo_reqwidthZwinfo_reqheightr)rr)canvasrr@rA_configure_interiorsz;VerticalScrolledFrame.__init__.._configure_interiorz cs5jjkr1jdjdS)Nr0)rZ winfo_widthZ itemconfigure)r)rr interior_idr@rA_configure_canvassz9VerticalScrolledFrame.__init__.._configure_canvas)r_r2rZVERTICALrIrrr:ZCanvasrrarLrKrrZ xview_movetoZ yview_movetorZ create_windowrr)r?r3rkwZ vscrollbarrrr@)rrrrAr2us   zVerticalScrolledFrame.__init__N)rrr__doc__r2r@r@r@rArns r__main__z#idlelib.idle_test.test_configdialog verbosityrXexitF)run)'rZtkinterZtkinter.messageboxZ messageboxrjZtkinter.colorchooserZ colorchooserrvZ tkinter.fontrlrwZidlelib.configHandlerrZidlelib.dynOptionMenuWidgetrZidlelib.keybindingDialogrZidlelib.configSectionNameDialogrZidlelib.configHelpSourceEditrZidlelib.tabbedpagesrZidlelib.textViewr Zidlelibr r1r rrrr_rrZunittestr.Zidlelib.idle_test.htestrr@r@r@rA s: C  +