Your IP : 3.147.205.114


Current Path : /opt/alt/python35/lib64/python3.5/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/idlelib/__pycache__/configDialog.cpython-35.opt-2.pyc



���]%��@sPddlTddljZddljZddljZ	ddl
mZddlm
Z
ddlmZddlmZddlmZddlmZdd	lmZdd
lmZGdd�de�Zd
ZddiZdd�ZGdd�de�Z e!dkrLddl"Z"e"j#ddddd�ddl$m%Z%e%e�dS)�)�*N)�idleConf)�
DynOptionMenu)�
GetKeysDialog)�GetCfgSectionNameDialog)�GetHelpSourceDialog)�
TabbedPageSet)�	view_text)�
macosxSupportc@s�eZdZddddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Z d?d@�Z!dAdB�Z"dCdD�Z#dEdF�Z$dGdH�Z%dIdJ�Z&dKdL�Z'dMdN�Z(dOdP�Z)dQdR�Z*dSdT�Z+dUdV�Z,dWdX�Z-dYdZ�Z.d[d\d]�Z/d^d_�Z0d`da�Z1dbdc�Z2ddde�Z3dfdg�Z4dhdi�Z5djdk�Z6dldm�Z7dndo�Z8dpdq�Z9drds�Z:dtdu�Z;dvdw�Z<dxdy�Z=dzd{�Z>d|d}�Z?d~d�Z@d�d��ZAd�d��ZBd�d��ZCd�d��ZDd�d��ZEd�d��ZFd�d��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd[S)��ConfigDialog�FcCs|tj||�||_|r(i|_|j�|jdd�|j|pQd�|jd|j�d|j	�|s�dndf�dd5dd6dd7dd8dd9dd:dd;dd<d d=d#d>d&d?d)d@d,dAd/dBi|_
|j�|j�|j
d2td3t�|j|�|j�|jd4|j�|jj�|j�|j�|sx|j�|j�dS)CN�borderwidth�zIDLE Preferencesz+%d+%d���zNormal Text�normal�00zPython Keywords�keyword�01zPython Definitions�
definition�02zPython Builtins�builtin�03zPython Comments�comment�04zPython Strings�string�05z
Selected Text�hilite�06z
Found Text�hit�07�Cursor�cursor�08zEditor Breakpoint�break�09zShell Normal Text�console�10zShell Error Text�error�11zShell Stdout Text�stdout�12zShell Stderr Text�stderr�13�height�widthZWM_DELETE_WINDOW)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_dictZwm_withdraw�	configure�titleZgeometryZwinfo_rootxZwinfo_rooty�
themeElements�ResetChangedItems�
CreateWidgetsZ	resizable�FALSEZ	transientZgrab_set�protocol�Cancel�tabPagesZ	focus_set�LoadConfigs�AttachVarCallbacksZwm_deiconifyZwait_window)�selfr3r6Z_htestZ_utest�rA�1/opt/alt/python35/lib64/python3.5/configDialog.pyr2sH		
!







zConfigDialog.__init__cCs�t|ddddddg�|_|jjdtdtd	t�|j�|j�|j�|j	�|j
�|j�jdt�dS)
NZ
page_namesz
Fonts/Tabs�Highlighting�Keys�General�
Extensions�side�expand�fill)
rr=�pack�TOP�TRUE�BOTH�CreatePageFontTab�CreatePageHighlight�CreatePageKeys�CreatePageGeneral�CreatePageExtensions�create_action_buttons�BOTTOM)r@rArArBr9Qs	




zConfigDialog.CreateWidgetsc
Cs�tj�ri}nddddi}t|dd�}t|dd�}xud|jfd|jfd|jfd	|jffD]=\}}t|d
|d|dt|�j	d
t
dd�q�Wt|dddd�j	d
t�|j	d
t�|S)N�padx��pady���Ok�Applyr<�Help�text�command�	takefocusrGrr/r
r)
r
ZisAquaTk�FramerZr[r<r\�Buttonr:rJ�LEFTrKrT)r@ZpaddingArgsZouterZbuttonsZtxt�cmdrArArBrS]s	"z"ConfigDialog.create_action_buttonscCs�|j}t|�|_t|�|_t|�|_t|�|_tj	|d+�|_
|jjdj
}t|dddtdd	�}t|dddtdd
�}t|�}t|�}t|dtdd�}t|d
ddtdt�|_|jjd|j�t|�}|jd|jj�|jjd|j�t|dd�}	t||jdd|j�|_t|d|jddddddd|j�}
t|dt dd�}t|dtd|j
dd�|_!t|�}t|dtdd�}
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),N�courier�
rz
Fonts/Tabsr
rY�reliefr]z Base Editor Font z Indentation Width ZjustifyzFont Face :r/rr_�exportselectionz<ButtonRelease-1>r^�yscrollcommandzSize :�variable�onvalue��offvaluerZBold�fontz,AaBbCcDdEe
FfGgHhIiJjK
1234567890
#:+=(){}[]zPython Standard: 4 Spaces!�orientZ
horizontalZtickintervalZfrom_Zto�rGrUrWrHrI�anchorr)rdrer)+r3�	StringVar�fontSize�
BooleanVar�fontBold�fontName�IntVar�spaceNum�tkFontZFontZeditFontr=�pages�frame�
LabelFrame�GROOVEr`�Labelrb�Listboxr:�listFontName�bind�OnListFontButtonRelease�	Scrollbar�config�yview�setr�
SetFontSample�optMenuFontSize�Checkbutton�SOLID�labelFontSampleZScaleZ
scaleSpaceNumrJrLrM�YrK�X�W)r@r3rzZ	frameFontZframeIndentZ
frameFontNameZframeFontParamZlabelFontNameTitleZ
scrollFontZlabelFontSizeTitleZ
checkFontBoldZframeFontSampleZframeIndentSizeZlabelSpaceNumTitlerArArBrNrsn		
	("""(zConfigDialog.CreatePageFontTabc!Cs�|j}t|�|_t|�|_t|�|_t|�|_t|�|_t|�|_t|�|_	|j
jdj}t
|dddtdd�}t
|dddtdd�}t|dtddd	d\d
ddddddtdddt�	|_|j}|jddd��|jddd��d}}x)|D]!}|jt|d|d�qHWx>|jD]3}|dBdC�}	|j|j|ddD|	�qwW|jdEt�t|dtdd�|_t|�}
t|jddFdG|jdd�}t|j|j	ddd�|_ t!|
dH|jdIdddJdG|j"�|_#t!|
dH|jdIdddKdG|j"�|_$|jj%d�t|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)~NrCr
rYrfr]z Custom Highlighting z Highlighting Theme rkrmrd�rr#Zhand2r0�r/�r_�highlightthicknessr�wrapz<Double-Button-1>cSsdS)Nr%rA)�erArArB�<lambda>�sz2ConfigDialog.CreatePageHighlight.<locals>.<lambda>z<B1-Motion>cSsdS)Nr%rA)r�rArArBr��s�#you can click herer�
r�#to choose items�defr� �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|jj�jj|�dS)N)ZwidgetZwinfo_toplevel�highlightTargetr�)�event�elemrArArB�tem�sz-ConfigDialog.CreatePageHighlight.<locals>.temz<ButtonPress-1>�statezChoose Colour for :r^ri�valueZ
ForegroundZ
BackgroundzSave as New Custom Themez	Select : za Built-in Themeza Custom ThemezDelete Custom Theme�bdrGrUrrWrHrI��rXrp)rdr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r �r�r�r�r�r�r�r�r�r�r�r�r%�r�r�r�r)�r�r�r�r#�r�r�r�r'�r�r�r+r+�r�r�r-r-�r�r) r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�);r3rq�builtinTheme�customThemers�fgHilite�colourru�themeIsBuiltinr�r=ryrzr{r|ZTextr�r:�NONE�textHighlightSampler��insert�ENDr7Ztag_bindr��DISABLEDr`�frameColourSetra�	GetColourr�optMenuHighlightTarget�Radiobutton�SetColourSampleBinding�radioFg�radioBgr��SaveAsNewThemer}�SetThemeTypeZradioThemeBuiltin�radioThemeCustom�optMenuThemeBuiltin�optMenuThemeCustom�DeleteCustomTheme�buttonDeleteCustomTheme�new_custom_themerJrbrLrMr�rKr��E�RIGHTr�rT)r@r3rz�frameCustomZ
frameThemer]ZtextAndTagsZtxTa�elementr�Z	frameFgBgZbuttonSetColourZbuttonSaveCustomThemeZlabelTypeTitlerArArBrO�s�				
("+(""%%+%z ConfigDialog.CreatePageHighlightc
s�|j}t|�|_t|�|_t|�|_t|�|_t|�|_|jj	dj
}t|dddtdd�}t|dddtdd��t
|�}t|dd�}t|�}t|d	t�}t|d
tdt�|_|jjd|j�|jd
|jj�|jd
|jj�|jjd|j�|jjd|j�t|ddd
|jdt�|_�fdd�td�D�}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)(NrDr
rYrfr]z Custom Key Bindings z	 Key Set zAction - Key(s)rnr_rgz<ButtonRelease-1>r^rhZxscrollcommandzGet New Keys for Selectionr�c
s.g|]$}t�dddddd��qS)rUrYrWr
r)r`)�.0�i)�frameKeySetsrArB�
<listcomp>Fs	z/ConfigDialog.CreatePageKeys.<locals>.<listcomp>rrir�rkzUse a Built-in Key SetzUse a Custom Key SetzDelete Custom Key SetzSave as New Custom Key SetrGrUrrWrHrI�weight�row�columnZ
columnspan�stickyT)7r3rqZ
bindingTarget�builtinKeys�
customKeysrs�keysAreBuiltin�
keyBindingr=ryrzr{r|r`r}r�Z
HORIZONTALr~r:�listBindingsr��KeyBindingSelectedr�r�Zxviewr�ra�
GetNewKeysr��
buttonNewKeys�ranger��SetKeysTypeZradioKeysBuiltin�radioKeysCustomr�optMenuKeysBuiltin�optMenuKeysCustom�DeleteCustomKeys�buttonDeleteCustomKeys�SaveAsNewKeySetrJrTrLrMr�rb�columnconfigure�rowconfigure�gridr��NSEWZNSZEWrK)
r@r3rzr�ZframeTargetZlabelTargetTitleZ
scrollTargetYZ
scrollTargetXZframesZbuttonSaveCustomKeysrA)r�rBrP%s~		("%("##%" &zConfigDialog.CreatePageKeyscCs|j}t|�|_t|�|_t|�|_t|�|_t|�|_t|�|_	t|�|_
|jjdj
}t|dddtdd�}t|dddtdd�}t|dddt�}t|dddtdd�}t|dd	�}t|d
|jddd
|jdd�}t|d
|jddd
|jdd�}	t|dd�}
t|d
|jddd
|jdd�}t|d
|jddd
|jdd�}t|dd�}
t|dd�}t|d|jdd�}t|dd�}t|d|jdd�}t|�}t|�}t|�}t|dddtdt�|_|jd
|jj�|jjd|j�|jjd|j�t|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),NrEr
rYrfr]z Startup Preferences z Autosave Preferences z Additional Help Sources z
At Startuprir�rkr^zOpen Edit WindowrzOpen Shell WindowzAt Start of Run (F5)  zPrompt to Savez	No Promptz$Initial Window Size  (in characters)ZWidth�textvariabler0rXZHeightr/rr_rgrhz<ButtonRelease-1>ZEditr�r�ZAddZRemoverGrUrWrIrHrpre)0r3rq�winWidth�	winHeightrv�startupEdit�autoSave�encodingrsZuserHelpBrowserZhelpBrowserr=ryrzr{r|r`r}r�r�Entryr�r~r:�listHelpr�r�r�r��HelpSourceSelectedrar��HelpListItemEdit�buttonHelpListEdit�HelpListItemAddZbuttonHelpListAdd�HelpListItemRemove�buttonHelpListRemoverJrKr�rLrMrbr�r�r�r�)r@r3rzZframeRunZ	frameSaveZframeWinSizeZ	frameHelpZlabelRunChoiceTitleZradioStartupEditZradioStartupShellZlabelRunSaveTitleZradioSaveAskZ
radioSaveAutoZlabelWinSizeTitleZlabelWinWidthTitleZ
entryWinWidthZlabelWinHeightTitleZentryWinHeightZ
frameHelpListZframeHelpListButtonsZscrollHelpListrArArBrQrs�				"""(""""""""""(%zConfigDialog.CreatePageGeneralcCs�|jjd|j�|jjd|j�|jjd|j�|jjd|j�|jjd|j�|j	jd|j
�|jjd|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)N�w)#rrZtrace_variable�VarChanged_fontrurtrw�VarChanged_spaceNumr��VarChanged_colourr��VarChanged_builtinThemer��VarChanged_customThemer��VarChanged_themeIsBuiltinr��VarChanged_highlightTargetr��VarChanged_keyBindingr��VarChanged_builtinKeysr��VarChanged_customKeysr��VarChanged_keysAreBuiltinr�VarChanged_winWidthr�VarChanged_winHeightr�VarChanged_startupEditr�VarChanged_autoSaver�VarChanged_encoding)r@rArArBr?�s$zConfigDialog.AttachVarCallbackscCs�x�|j|j|j|j|j|j|j|j|j|j	|j
|j|j|j
|j|j|j|jfD]$}|jd|j�dd�qsWdS)Nrrrk)rrrurtrwr�r�r�r�r�r�r�r�r�rrrrrZ
trace_vdeleteZtrace_vinfo)r@�varrArArB�remove_var_callbacks�sz!ConfigDialog.remove_var_callbackscGss|jj�}|jddd|�|jj�}|jddd|�|jj�}|jddd|�dS)N�main�EditorWindowrmz	font-sizez	font-bold)ru�get�AddChangedItemrrrt)r@�paramsr�rArArBr�szConfigDialog.VarChanged_fontcGs)|jj�}|jddd|�dS)Nr1�Indentz
num-spaces)rwr3r4)r@r5r�rArArBr �sz ConfigDialog.VarChanged_spaceNumcGs|j�dS)N)�OnNewColourSet)r@r5rArArBr!szConfigDialog.VarChanged_colourcGs�|jj�}|dkr~tjddd�dkrL|jdddd�|jddd|�|jjdd	d
d�nE|jddd|�|jdddd�|jjddd
d
�|j�dS)Nz	IDLE Darkr1�Theme�namezIDLE NewzIDLE ClassicZname2r]zNew theme, see HelpZfgz#500000rZblack)r�r3r�	GetOptionr4r�r��PaintThemeSample)r@r5r�rArArBr"s
z$ConfigDialog.VarChanged_builtinThemecGs?|jj�}|dkr;|jddd|�|j�dS)Nz- no custom themes -r1r8r9)r�r3r4r;)r@r5r�rArArBr#sz#ConfigDialog.VarChanged_customThemecGsF|jj�}|jddd|�|r8|j�n
|j�dS)Nr1r8�default)r�r3r4r"r#)r@r5r�rArArBr$s

z&ConfigDialog.VarChanged_themeIsBuiltincGs|j�dS)N)�SetHighlightTarget)r@r5rArArBr% sz'ConfigDialog.VarChanged_highlightTargetcGs�|jj�}|jj�}|jjt�j�d}tj|�rb|jd|||�n/tj	|�}|d}|jd|||�dS)Nr�keysZ_cfgBindings�
extensions)
r�r3r�r�ANCHOR�splitrZ
IsCoreBindingr4ZGetExtnNameForEvent)r@r5r��keySetr�ZextNameZextKeybindSectionrArArBr&#s
z"ConfigDialog.VarChanged_keyBindingcGs6|jj�}|jddd|�|j|�dS)Nr1rDr9)r�r3r4�LoadKeysList)r@r5r�rArArBr'/sz#ConfigDialog.VarChanged_builtinKeyscGsB|jj�}|dkr>|jddd|�|j|�dS)Nz- no custom keys -r1rDr9)r�r3r4rC)r@r5r�rArArBr(4sz"ConfigDialog.VarChanged_customKeyscGsF|jj�}|jddd|�|r8|j�n
|j�dS)Nr1rDr<)r�r3r4r'r()r@r5r�rArArBr):s

z&ConfigDialog.VarChanged_keysAreBuiltincGs)|jj�}|jddd|�dS)Nr1r2r0)rr3r4)r@r5r�rArArBr*Bsz ConfigDialog.VarChanged_winWidthcGs)|jj�}|jddd|�dS)Nr1r2r/)rr3r4)r@r5r�rArArBr+Fsz!ConfigDialog.VarChanged_winHeightcGs)|jj�}|jddd|�dS)Nr1rEzeditor-on-startup)rr3r4)r@r5r�rArArBr,Jsz#ConfigDialog.VarChanged_startupEditcGs)|jj�}|jddd|�dS)Nr1rE�autosave)rr3r4)r@r5r�rArArBr-Nsz ConfigDialog.VarChanged_autoSavecGs)|jj�}|jddd|�dS)Nr1r2r)rr3r4)r@r5r�rArArBr.Rsz ConfigDialog.VarChanged_encodingcCs%didididii|_dS)Nr1�	highlightr>r?)�changedItems)r@rArArBr8VszConfigDialog.ResetChangedItemscCsIt|�}||j|kr0i|j||<||j|||<dS)N)�strrF)r@�typ�section�itemr�rArArBr4_szConfigDialog.AddChangedItemcCs�didididii}x�|D]�}tjd|�}xh|D]`}i|||<tj|j|�}x3|D]+}tj|j||�||||<quWqDWq%W|S)Nr1rEr>r?r<)r�GetSectionList�
defaultCfg�
GetOptionList�Get)r@ZdItems�
configTypeZsectionsrI�options�optionrArArB�GetDefaultItemses


1zConfigDialog.GetDefaultItemscCs�|jj�rK|jjdt�|jjdt�|jjdt�nL|jjdt�|jjdt�|jjdt�|jjdt�dS)Nr�)	r�r3r�r��NORMALr�r�r�r�)r@rArArBr�qszConfigDialog.SetThemeTypecCs�|jj�rK|jjdt�|jjdt�|jjdt�nL|jjdt�|jjdt�|jjdt�|jjdt�dS)Nr�)	r�r3rr�rSrr�r
r)r@rArArBr|szConfigDialog.SetKeysTypecCs�|jjt�}|jj|�}|j�d}|jj�rU|jj�}n|jj�}tj	�}||j
dkr�|j
d|}x"|D]}||j�||<q�Wt|j��}t
|d||�j}	|	r�|jj�rDd}
|j|
�}|s7|jj|�|jj|�dS|j|�|jj|�|jj||d|	�|jj|�|jj|�|jj|	�n |jj|�|jj|�dS)Nrr>zGet New KeyszcYour changes will be saved as a new Custom Key Set. Enter a name for your new Custom Key Set below.z - )r�indexr@r3rAr�r�r�rZGetCurrentKeySetrFr��valuesr�result�GetNewKeysName�
select_set�
select_anchor�CreateNewKeySet�deleter�r�r�)r@�	listIndex�binding�bindNameZcurrentKeySetNameZcurrentBindings�
keySetChangesr�ZcurrentKeySequences�newKeys�message�	newKeySetrArArBr�s<

zConfigDialog.GetNewKeyscCs>tjdd�tjdd�}t|d||�j}|S)N�userr>r<zNew Custom Key Set)rrKrrV)r@ra�	usedNamesrbrArArBrW�s
zConfigDialog.GetNewKeysNamecCs&|jd�}|r"|j|�dS)NzNew Key Set Name:)rWrZ)r@ZnewKeysNamerArArBr�szConfigDialog.SaveAsNewKeySetcCs|jjdt�dS)Nr�)rr�rS)r@r�rArArBr�szConfigDialog.KeyBindingSelectedc
Cs#|jj�r!|jj�}n|jj�}tj|�}i}x;|D]3}|dd�}dj||�}|||<qLW||jdkr�|jd|}x|D]}||||<q�W|j||�tj	dd�}	|	j
�|jj|	|�|jj
d�|j�dS)NrYr�r>rcr���)r�r3r�r�rZGetCoreKeys�joinrF�
SaveNewKeySetrK�sortr�SetMenur�r)
r@Z
newKeySetNameZprevKeySetNameZprevKeysr`r�Z	eventNamer]r_Z
customKeyListrArArBrZ�s&


zConfigDialog.CreateNewKeySetc	Cs9d}d}|jj�r3d}|jjt�}tj|�}t|j��}|j�|jj	dt
�x�|D]�}dj||�}|dd�}||jdkr�||jd|kr�|jd||}|jj
t
|d|�qxW|r5|jj|�|jj|�|jj|�dS)Nrrkr�rYr>z - re)r�curselectionrTr@rZ	GetKeySetr�r>rhr[r�rfrFr��seerXrY)	r@�
keySetNameZreselectrbr\rBZ	bindNamesr^�keyrArArBrC�s(

zConfigDialog.LoadKeysListcCsO|jj�}d}tjd||d|�s5dS|j�tjdj|�||jdkrt|jd|=tjdj	�tj
dd�}|j�|s�|jj
dt�|jj|d�n|jj||d�|jjtjd	jd
d��|jjtjd	jd
d��|j�|j�|j�dS)
Nz0Are you sure you wish to delete the key set %r ?zDelete Key Setr3r>rcr�z- no custom keys -rr1rDr<r9)r�r3�tkMessageBox�askyesno�DeactivateCurrentConfigr�userCfg�remove_sectionrF�SaverKrhrr�r�rrir�r�rLrNr��SaveAllChangedConfigs�ActivateConfigChangesr)r@rl�delmsg�itemListrArArBr	�s*

##

zConfigDialog.DeleteCustomKeyscCsO|jj�}d}tjd||d|�s5dS|j�tjdj|�||jdkrt|jd|=tjdj	�tj
dd�}|j�|s�|jj
dt�|jj|d�n|jj||d�|jjtjd	jd
d��|jjtjd	jd
d��|j�|j�|j�dS)
Nz.Are you sure you wish to delete the theme %r ?zDelete Themer3rErcr�z- no custom themes -rr1r8r<r9)r�r3rnrorprrqrrrFrsrKrhr�r�r�r�rir�r�rLrNr�rtrur�)r@�	themeNamervrwrArArBr�	s*

##

zConfigDialog.DeleteCustomThemecCs�|jj�}|jjd�}tjd|dd|d|�\}}|r�||kr�|jj�r�d}|j|�}|s�dS|j|�|j	j
|�n|j	j
|�dS)N�bgr3r6zPick new colour for : Zinitialcolorz_Your changes will be saved as a new Custom Theme. Enter a name for your new Custom Theme below.)r�r3r�Zcget�tkColorChooserZaskcolorr��GetNewThemeName�CreateNewThemer�r�)r@�targetZ
prevColourZ	rgbTupletZcolourStringra�newThemerArArBr�&s	
zConfigDialog.GetColourcCs�|jj�}|jjd|�|jj�r7dnd}|j|jj�d}|jj|||i�|j	j�}|d|}|j
d|||�dS)Nry�
foreground�
backgroundr�-rE)r�r3r�r�r�r7r�r��
tag_configr�r4)r@Z	newColour�planeZ
sampleElement�themeZthemeElementrArArBr7:szConfigDialog.OnNewColourSetcCs>tjdd�tjdd�}t|d||�j}|S)NrcrEr<zNew Custom Theme)rrKrrV)r@rardr~rArArBr{Ds
zConfigDialog.GetNewThemeNamecCs&|jd�}|r"|j|�dS)NzNew Theme Name:)r{r|)r@�newThemeNamerArArBr�KszConfigDialog.SaveAsNewThemecCs�|jj�r'd}|jj�}nd}|jj�}tj||�}||jdkr�|jd|}x|D]}||||<qyW|j||�tjdd�}|j	�|j
j||�|jjd�|j
�dS)Nr<rcrEr)r�r3r�r�rZGetThemeDictrF�SaveNewThemerKrhr�rir�r�)r@r�Z	themeTyperxr~ZthemeChangesr�ZcustomThemeListrArArBr|Ps 

zConfigDialog.CreateNewThemecCs6|jjt�}|jj|j��|j�dS)N)rr3r@rur��lowerr�)r@r�rmrArArBr�hsz$ConfigDialog.OnListFontButtonReleaseNcCsr|jj�}|jj�r'tjntj}||jj�|f}|jjd|�|j	j
d|�dS)Nrm)rur3rtrxZBOLDrSrrr�r�r�r5)r@r�ruZ
fontWeightZnewFontrArArBr�ms
!zConfigDialog.SetFontSamplecCs�|jj�dkrN|jjdt�|jjdt�|jjd�n6|jjdt�|jjdt�|jjd�|j	�dS)Nr"r�rk)
r�r3r�r�r�r�r�r�rS�SetColourSample)r@rArArBr=tszConfigDialog.SetHighlightTargetcGs|j�dS)N)r�)r@�argsrArArBr�sz#ConfigDialog.SetColourSampleBindingcCsa|j|jj�d}|jj�r/dnd}|jj||�}|jjd|�dS)Nrrr�ry)r7r�r3r�r�Ztag_cgetr�r�)r@�tagr�r�rArArBr��szConfigDialog.SetColourSamplecCs|jj�r!|jj�}n|jj�}x�|jD]�}|j|d}tj||�}|dkr�tj|ddd�|d<||jdkr�|jd|}|d|kr�||d|d	<|d
|kr�||d
|d<|jj	||�q:W|j
�dS)Nrr#rZfgBgryr�rEz-foregroundrz-background)r�r3r�r�r7rZGetHighlightrFr�r�r�)r@r�ZelementTitler�ZcoloursZ	themeDictrArArBr;�s"zConfigDialog.PaintThemeSamplecCs|j�dS)N)�SetHelpListButtonStates)r@r�rArArBr�szConfigDialog.HelpSourceSelectedcCs�|jj�dkr>|jjdt�|jjdt�n^|jj�rv|jjdt�|jjdt�n&|jjdt�|jjdt�dS)Nrkr�)r�sizerr�r�rrjrS)r@rArArBr��sz$ConfigDialog.SetHelpListButtonStatescCset|d�j}|rW|jj|d|df�|jjt|d�|j�|j�dS)NzNew Help Sourcerrk)	rrV�userHelpList�appendrr�r��UpdateUserHelpChangedItemsr�)r@�
helpSourcerArArBr�s
zConfigDialog.HelpListItemAddcCs�|jjt�}|j|}t|dd|dd|d�j}|sX||kr\dS||j|<|jj|�|jj||d�|j�|j	�dS)NzEdit Help SourceZmenuItemrZfilePathrk)
rrTr@r�rrVr[r�r�r�)r@�	itemIndexr�Z
newHelpSourcerArArBr�s


zConfigDialog.HelpListItemEditcCsD|jjt�}|j|=|jj|�|j�|j�dS)N)rrTr@r�r[r�r�)r@r�rArArBr�s


zConfigDialog.HelpListItemRemovec	Csvi|jdd<x^tdt|j�d�D]@}|jddt|�dj|j|ddd���q.WdS)Nr1�	HelpFilesrk�;rY)rFr�lenr�r4rGrf)r@�numrArArBr��s
#z'ConfigDialog.UpdateUserHelpChangedItemsc	Cs.ttj|��}|j�x!|D]}|jjt|�q&Wtj|dd�}|dj	�}|d}|ddk}|j
j|�dd�|D�}yC|j|�}|jj
|�|jj|�|jj|�Wntk
r�YnX|jjd|�|jj|�|j�dS)Nr1r2rrkrYZboldcSsg|]}|j��qSrA)r�)r��srArArBr��s	z,ConfigDialog.LoadFontCfg.<locals>.<listcomp>�7�8�9r(r*r,r.�14�16�18�20�22)r�r�r�r(r*r,r.r�r�r�r�r�)r�rx�familiesrhrr�r�rZGetFontr�rur�rTrkrXrY�
ValueErrorr�rirtr�)	r@ZfontsrmZconfiguredFontrurrrtZlc_fontsZcurrentFontIndexrArArB�LoadFontCfg�s*



	
zConfigDialog.LoadFontCfgcCs5tjddddddd�}|jj|�dS)Nr1r6z
num-spacesr<r��type�int)rr:rwr�)r@rwrArArB�
LoadTabCfg�szConfigDialog.LoadTabCfgc	s��jjtjddddddd��tj�}�jj�r�tjdd�}|j��jj	||�tjdd�}|j�|s��j
jd	t��j
jd
�q9�jj	||d�nbtjdd�}|j��jj	||�tjdd�}|j��jj	||d��j�t�jj��}|jd�fd
d���jj	||d��j��j�dS)Nr1r8r<r��boolrkrErcr�z- no custom themes -rrmcs�j|dS)Nrk)r7)�x)r@rArBr�sz+ConfigDialog.LoadThemeCfg.<locals>.<lambda>)r�r�rr:ZCurrentThemer3rKrhr�rir�r�r�r�r�r�r�r7r>r�r;r=)r@�
currentOptionrwZ
themeNamesrA)r@rB�LoadThemeCfg�s2





zConfigDialog.LoadThemeCfgc	Cs`|jjtjddddddd��tj�}|jj�r�tjdd�}|j�|jj	||�tjdd�}|j�|s�|j
jd	t�|j
jd
�q9|jj	||d�nbtjdd�}|j�|jj	||�tjdd�}|j�|jj	||d�|j�tj�}|j|�dS)Nr1rDr<r�r�rkr>rcr�z- no custom keys -r)r�r�rr:ZCurrentKeysr3rKrhrrirr�r�r�rrrC)r@r�rwrlrArArB�
LoadKeyCfgs,




zConfigDialog.LoadKeyCfgc	Cs
|jjtjddddddd��|jjtjddddd	dd��|jjtjdd
ddd��|jjtjdd
d
dd��|jjtjdd
ddd��tj�|_	x(|j	D]}|j
jt|d	�q�W|j
�dS)Nr1rEzeditor-on-startupr<rkr�r�rDrr2r0r�r/rZnone)rr�rr:rrrrZGetAllExtraHelpSourcesListr�rr�r�r�)r@ZhelpItemrArArB�LoadGeneralCfg2szConfigDialog.LoadGeneralCfgcCs6|j�|j�|j�|j�|j�dS)N)r�r�r�r�r�)r@rArArBr>Gs




zConfigDialog.LoadConfigscCsctjdj|�s*tjdj|�x2|D]*}||}tjdj|||�q1WdS)Nr>)rrq�has_section�add_section�	SetOption)r@rlrBr�r�rArArBrgWs


zConfigDialog.SaveNewKeySetcCsctjdj|�s*tjdj|�x2|D]*}||}tjdj|||�q1WdS)NrE)rrqr�r�r�)r@rxr�r�r�rArArBr�cs


zConfigDialog.SaveNewThemecCsitj|j||�rOtj|j||�|krOtj|j||�Stj|j|||�S)N)rrLZ
has_optionrNrq�RemoveOptionr�)r@rOrIrJr�rArArB�SetUserValueoszConfigDialog.SetUserValuecCstjdj�x�|jD]�}d}x�|j|D]{}|dkratjdjd�d}xL|j||D]9}|j|||}|j||||�rsd}qsWq5W|rtj|j�qWx%ddgD]}tj|j�q�W|j�|j�dS)Nr1Fr�Tr>rE)rrqrsrFrrr�r8�save_all_changed_extensions)r@rOZcfgTypeHasChangesrIrJr�rArArBrtws"
z"ConfigDialog.SaveAllChangedConfigscCs1|jjj�}x|D]}|j�qWdS)N)r3r4r>ZRemoveKeybindings)r@�winInstances�instancerArArBrp�s
z$ConfigDialog.DeactivateCurrentConfigcCsY|jjj�}x@|D]8}|j�|j�|j�|j�|j�qWdS)N)r3r4r>ZResetColorizerZ	ResetFontZset_notabs_indentwidthZApplyKeybindingsZreset_help_menu_entries)r@r�r�rArArBru�s




z"ConfigDialog.ActivateConfigChangescCs|j�dS)N)�destroy)r@rArArBr<�szConfigDialog.CancelcCs|j�|j�dS)N)r[r�)r@rArArBrZ�s
zConfigDialog.OkcCs"|j�|j�|j�dS)N)rprtru)r@rArArBr[�s

zConfigDialog.Applyc	Cs6|jj}t|dddttj|d��dS)Nr6zHelp for IDLE preferencesr]r)r=Z
_current_pager	�help_common�
help_pagesr3)r@ZpagerArArBr\�szConfigDialog.Helpc
Cs|j}|jjdj}tjd|_tjd|_|j	t
�|_
|j�t|�|_
|jddd�|jddd�t|d|j
dd	�|_|jjd
|j�t|d|jj�}|j|j_t|dd
dd
�|_|jjdddddd�|jdddddd�|jjdddddddddg�|jdddd�i|_d|_||_|j|_d}x6t |j!�D]%}|j"|�|d|d}q�W|j
j|�|jj#d�|jd�dS)NrFr?rr�rkrYZlistvariableZ
selectmodeZbrowsez<<ListboxSelect>>r^r0�r/r�r�r�Znws�ns�nsewrUrerWr�{z} )$r3r=ryrzrrL�ext_defaultCfgrq�ext_userCfg�register�is_int�load_extensionsrqZextension_namesr
rr~�extension_listr��extension_selectedr�r�r�rhr{�
details_framerr5�config_frame�current_extensionZ
outerframeZtabbed_page_set�sortedr?�create_extension_frameZ
selection_set)r@r3rzZscrollZ	ext_names�ext_namerArArBrR�s<	
+			
z!ConfigDialog.CreatePageExtensionsc
#Cs�i|_x'tjdd�D]}g|j|<qWx�|jD]�}t|jj|��}dd�|D�}x|D]}|j|�quW||}x,|D]$}|jj||dd�}y ddddi|}d	}WnItk
r)yt	|�}d
}Wnt
k
r$|}d}YnXYnXy+|jj||d|ddd|�}Wnt
k
ro|}YnXt|�}	|	j
t|��|j|jd
|d|d|d|d|	i�q�Wq=WdS)NZactive_onlyFcSs%g|]}|jd�r|�qS)�enable)�
startswith)r��opt_namerArArBr��s	z0ConfigDialog.load_extensions.<locals>.<listcomp>�rawT�True�Falser�r�r�r<r9r�r/)r?rZ
GetExtensionsr�r�rM�removerN�KeyErrorr�r�r�rqr�rGr�)
r@r�Zopt_listZenablesr�Zdef_strZdef_objZopt_typer�r/rArArBr��sF	


	



	

zConfigDialog.load_extensionscCs�|jj�}|r'|jj|�}|dksB||jkr{|jr{|jjdd�|j|jj�d|_|r�|jjd|�|j|jdddddd�||_dS)Nr]rr�rr�r�r�)	r�rjr3r�r�r�r�Zgrid_forgetr)r@r�ZnewselrArArBr�s		#zConfigDialog.extension_selectedcCs~t|jdddd�}||j|<|j}xFt|j|�D]1\}}t|d|d�}|jd|ddd	t�|d
}|ddkr�t	|d
|d|dddddt
dddd�jd|ddd	tdd�qE|ddkrHt|d
|ddd|j
df�jd|ddd	tdd�qEt|d
|�jd|ddd	tdd�qEWdS)Nr/r�r0r]r9r�r�rr�r/r�r�rrirjr�rlr�ZindicatoronZselectcolorrr�rkrU�r�ZvalidatermZvalidatecommandz%P)�VerticalScrolledFramer�r��interior�	enumerater?r}r�NWr�r:r�rr�r)r@r��fZ
entry_arear��optZlabelr/rArArBr�s&
	 
z#ConfigDialog.create_extension_framecCsv|d}|d}|dj�j�p-|}|dj|�||kr`|jj||�S|jj|||�S)Nr9r<r/)r3�stripr�r�r�r�)r@rIr�r9r<r�rArArB�set_extension_value9s

z ConfigDialog.set_extension_valuecCsgd}xG|jD]<}|j|}x&|D]}|j||�r*d}q*WqW|rc|jj�dS)NFT)r?r�r�rs)r@Zhas_changesr�rPr�rArArBr�Es

z(ConfigDialog.save_all_changed_extensions)P�__name__�
__module__�__qualname__r2r9rSrNrOrPrQr?r0rr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r8r4rRr�rrrWrrrZrCr	r�r�r7r{r�r|r�r�r=r�r�r;rr�rrrr�r�r�r�r�r�r>rgr�r�rtrprur<rZr[r\rRr�r�r�r�r�rArArArBrs�5DoM`	$
!
5-rahWhen 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.
rCz�
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.
cCs9|s
dSyt|�dSWntk
r4dSYnXdS)NTF)r�r�)r�rArArBr�cs

r�c@seZdZdd�ZdS)r�c
s6tj||||�t|dt�}|jdtdtdt�t|ddddd|j	d	d
���jdt
dtdt�|j
d�j��jd��jd�t��|_��jddd�d
t����fdd�}�jd|����fdd�}�jd|�dS)NrnrIrGrHr�rr�rhr0��r^Zwindowrpcs0�j��j�f}�jdd|�dS)NZscrollregionz	0 0 %s %s)�winfo_reqwidthZwinfo_reqheightr�)r�r�)�canvasr�rArB�_configure_interior�sz;VerticalScrolledFrame.__init__.<locals>._configure_interiorz<Configure>cs5�j��j�kr1�j�d�j��dS)Nr0)r�Zwinfo_widthZ
itemconfigure)r�)r�r��interior_idrArB�_configure_canvas�sz9VerticalScrolledFrame.__init__.<locals>._configure_canvas)r`r2r�ZVERTICALrJr�r�r:ZCanvasr�rbrMrLr�r�Zxview_movetoZyview_movetor�Z
create_windowr�r�)r@r3r��kwZ
vscrollbarr�r�rA)r�r�r�rBr2us 

zVerticalScrolledFrame.__init__N)r�r�r�r2rArArArBr�nsr��__main__z#idlelib.idle_test.test_configdialog�	verbosityrY�exitF)�run)&�tkinterZtkinter.messageboxZ
messageboxrnZtkinter.colorchooserZcolorchooserrzZtkinter.fontrmrxZidlelib.configHandlerrZidlelib.dynOptionMenuWidgetrZidlelib.keybindingDialogrZidlelib.configSectionNameDialogrZidlelib.configHelpSourceEditrZidlelib.tabbedpagesrZidlelib.textViewr	Zidlelibr
r1rr�r�r�r`r�r�Zunittestr1Zidlelib.idle_test.htestr�rArArArB�<module>s8
�����C	+


?>