Your IP : 3.135.206.19


Current Path : /opt/alt/python34/lib64/python3.4/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/idlelib/__pycache__/configDialog.cpython-34.pyo

�
e f1��@sZdZddlTddljZddljZddlj	Z
ddlmZddl
mZddlmZddlmZddlmZdd	lmZdd
lmZddlmZGdd
�d
e�ZdZidd6Zdd�ZGdd�de �Z!e"dkrVddl#Z#e#j$ddddd�ddl%m&Z&e&e�ndS)a�IDLE 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@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-dYdZd[�Z.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��ZNdYS)��ConfigDialog�FcCs�tj||�||_|r+i|_n|j�|jdd�|j|pTd�|jd|j�d|j	�|s�dndf�id6d
6d7d
6d8d6d9d6d:d6d;d6d<d6d=d6d>d"6d?d%6d@d(6dAd+6dBd.6dCd16|_
|j�|j�|j
d2td3t�|j|�|j�|jd4|j�|jj�|j�|j�|s�|j�|j�nd5S)Dz�
        _htest - bool, change box location when running htest
        _utest - bool, don't wait_window when running unittest
        �borderwidth�zIDLE Preferencesz+%d+%d����normal�00zNormal Text�keyword�01zPython Keywords�
definition�02zPython Definitions�builtin�03zPython Builtins�comment�04zPython Comments�string�05zPython Strings�hilite�06z
Selected Text�hit�07z
Found Text�cursor�08�Cursor�break�09zEditor Breakpoint�console�10zShell Normal Text�error�11zShell Error Text�stdout�12zShell Stdout Text�stderr�13zShell Stderr Text�height�widthZWM_DELETE_WINDOWN)rr)zkeywordr)rr)rr)rr)zstringr)rr)r r!)zcursorr#)zbreakr&)r'r()zerrorr*)zstdoutr,)zstderrr.)�Toplevel�__init__�parent�
instance_dictZwm_withdraw�	configure�titleZgeometryZwinfo_rootxZwinfo_rooty�
themeElements�ResetChangedItems�
CreateWidgetsZ	resizable�FALSEZ	transientZgrab_setZprotocol�Cancel�tabPagesZ	focus_set�LoadConfigs�AttachVarCallbacksZwm_deiconifyZwait_window)�selfr3r6Z_htestZ_utest�r@�9/opt/alt/python34/lib64/python3.4/idlelib/configDialog.pyr2sJ	
!








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?r@r@rAr9Qs	




zConfigDialog.CreateWidgetsc
Cs�tj�ri}nidd6dd6}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�	takefocusrFrr/r
r)
r
ZisAquaTk�FramerYrZr;r[�Buttonr:rI�LEFTrJrS)r?ZpaddingArgsZouterZbuttonsZtxt�cmdr@r@rArR]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
rX�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�rFrUrWrGrH�anchorr)rcrdznormal)+r3�	StringVar�fontSize�
BooleanVar�fontBold�fontName�IntVar�spaceNum�tkFontZFontZeditFontr<�pages�frame�
LabelFrame�GROOVEr_�Labelra�Listboxr:�listFontName�bind�OnListFontButtonRelease�	Scrollbar�config�yview�setr�
SetFontSample�optMenuFontSize�Checkbutton�SOLID�labelFontSampleZScaleZ
scaleSpaceNumrIrKrL�YrJ�X�W)r?r3ryZ	frameFontZframeIndentZ
frameFontNameZframeFontParamZlabelFontNameTitleZ
scrollFontZlabelFontSizeTitleZ
checkFontBoldZframeFontSampleZframeIndentSizeZlabelSpaceNumTitler@r@rArMrsn		
	("""(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)~NrBr
rXrer\z Custom Highlighting z Highlighting Theme rjrlrc�rr"Zhand2r0�r/�r^�highlightthicknessrZwrapz<Double-Button-1>cSsdS)Nr%r@)�er@r@rA�<lambda>�sz2ConfigDialog.CreatePageHighlight.<locals>.<lambda>z<B1-Motion>cSsdS)Nr%r@)r�r@r@rAr��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�elemr@r@rA�tem�sz-ConfigDialog.CreatePageHighlight.<locals>.temz<ButtonPress-1>�statezChoose Colour for :r]rh�valueZ
ForegroundZ
BackgroundzSave as New Custom Themez	Select : za Built-in Themeza Custom ThemezDelete Custom Theme�bdrFrUrrWrGrH��rVro)zcourierr�r�r��comment�r��normal�r�r��r�r��zdef�keyword�r�r��zfuncz
definition�r�r��r��string�r�r��r�r��r�r��r�zhilite�r�r��r�zhit�r�r��zlistzbuiltin�r�r��zNoner��r�r��r�zbreak�r�r��r�zerror�r�r��r�r"�r�r��zshellzconsole�r�r���stdoutr��r�r���stderrr��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�);r3rp�builtinTheme�customThemerr�fgHilite�colourrt�themeIsBuiltinr�r<rxryrzr{ZTextr�r:ZNONE�textHighlightSampler�insert�ENDr7Ztag_bindr��DISABLEDr_�frameColourSetr`�	GetColourr�optMenuHighlightTarget�Radiobutton�SetColourSampleBinding�radioFg�radioBgr��SaveAsNewThemer|�SetThemeTypeZradioThemeBuiltin�radioThemeCustom�optMenuThemeBuiltin�optMenuThemeCustom�DeleteCustomTheme�buttonDeleteCustomTheme�new_custom_themerIrarKrLr�rJr��E�RIGHTr�rS)r?r3ry�frameCustomZ
frameThemer\ZtextAndTagsZtxTa�elementr�Z	frameFgBgZbuttonSetColourZbuttonSaveCustomThemeZlabelTypeTitler@r@rArN�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)(NrCr
rXrer\z Custom Key Bindings z	 Key Set zAction - Key(s)rmr^rfz<ButtonRelease-1>r]rgZxscrollcommandzGet New Keys for Selectionr�c
s.g|]$}t�dddddd��qS)rUrXrWr
r)r_)�.0�i)�frameKeySetsr@rA�
<listcomp>Fs	z/ConfigDialog.CreatePageKeys.<locals>.<listcomp>rrhr�rjzUse a Built-in Key SetzUse a Custom Key SetzDelete Custom Key SetzSave as New Custom Key SetrFrUrrWrGrH�weight�row�columnZ
columnspan�stickyT)7r3rpZ
bindingTarget�builtinKeys�
customKeysrr�keysAreBuiltin�
keyBindingr<rxryrzr{r_r|r�Z
HORIZONTALr}r:�listBindingsr�KeyBindingSelectedr�r�Zxviewr�r`�
GetNewKeysr��
buttonNewKeys�ranger��SetKeysTypeZradioKeysBuiltin�radioKeysCustomr�optMenuKeysBuiltin�optMenuKeysCustom�DeleteCustomKeys�buttonDeleteCustomKeys�SaveAsNewKeySetrIrSrKrLr�ra�columnconfigure�rowconfigure�gridr��NSEWZNSZEWrJ)
r?r3ryr�ZframeTargetZlabelTargetTitleZ
scrollTargetYZ
scrollTargetXZframesZbuttonSaveCustomKeysr@)r�rArO%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),NrDr
rXrer\z Startup Preferences z Autosave Preferences z Additional Help Sources z
At Startuprhr�rjr]zOpen Edit WindowrzOpen Shell WindowzAt Start of Run (F5)  zPrompt to Savez	No Promptz$Initial Window Size  (in characters)ZWidth�textvariabler0rVZHeightr/rr^rfrgz<ButtonRelease-1>ZEditr�r�ZAddZRemoverFrUrWrHrGrord)0r3rp�winWidth�	winHeightru�startupEdit�autoSave�encodingrrZuserHelpBrowserZhelpBrowserr<rxryrzr{r_r|r�r�Entryr�r}r:�listHelpr�r�r�r�HelpSourceSelectedr`r��HelpListItemEdit�buttonHelpListEdit�HelpListItemAddZbuttonHelpListAdd�HelpListItemRemove�buttonHelpListRemoverIrJr�rKrLrar�r�r�r�)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
�|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)#rqZtrace_variable�VarChanged_fontrtrsrv�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?r@r@rAr>�s$zConfigDialog.AttachVarCallbackscGss|jj�}|jddd|�|jj�}|jddd|�|jj�}|jddd|�dS)z�When 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)rt�get�AddChangedItemrqrs)r?�paramsr�r@r@rAr"�szConfigDialog.VarChanged_fontcGs)|jj�}|jddd|�dS)Nr2�Indentz
num-spaces)rvr4r5)r?r6r�r@r@rAr#�sz ConfigDialog.VarChanged_spaceNumcGs|j�dS)N)�OnNewColourSet)r?r6r@r@rAr$�szConfigDialog.VarChanged_colourcGs�|jj�}|dkr�tjddd�dkrO|jdddd�n|jddd|�|jjdd	d
d�nE|jddd|�|jdddd�|jjddd
d
�|j�dS)Nz	IDLE Darkr2�Theme�namezIDLE NewzIDLE ClassicZname2r\zNew theme, see HelpZfgz#500000rZblack)r�r4r�	GetOptionr5r�r��PaintThemeSample)r?r6r�r@r@rAr%�s
z$ConfigDialog.VarChanged_builtinThemecGsB|jj�}|dkr>|jddd|�|j�ndS)Nz- no custom themes -r2r9r:)r�r4r5r<)r?r6r�r@r@rAr&sz#ConfigDialog.VarChanged_customThemecGsF|jj�}|jddd|�|r8|j�n
|j�dS)Nr2r9�default)r�r4r5r%r&)r?r6r�r@r@rAr'
s

z&ConfigDialog.VarChanged_themeIsBuiltincGs|j�dS)N)�SetHighlightTarget)r?r6r@r@rAr(sz'ConfigDialog.VarChanged_highlightTargetcGs�|jj�}|jj�}|jjt�j�d}tj|�rb|jd|||�n/tj	|�}|d}|jd|||�dS)Nr�keysZ_cfgBindings�
extensions)
rr4rr�ANCHOR�splitrZ
IsCoreBindingr5ZGetExtnNameForEvent)r?r6r��keySetr�ZextNameZextKeybindSectionr@r@rAr)s
z"ConfigDialog.VarChanged_keyBindingcGs6|jj�}|jddd|�|j|�dS)Nr2rCr:)r�r4r5�LoadKeysList)r?r6r�r@r@rAr*$sz#ConfigDialog.VarChanged_builtinKeyscGsE|jj�}|dkrA|jddd|�|j|�ndS)Nz- no custom keys -r2rCr:)rr4r5rD)r?r6r�r@r@rAr+)sz"ConfigDialog.VarChanged_customKeyscGsF|jj�}|jddd|�|r8|j�n
|j�dS)Nr2rCr=)rr4r5r*r+)r?r6r�r@r@rAr,/s

z&ConfigDialog.VarChanged_keysAreBuiltincGs)|jj�}|jddd|�dS)Nr2r3r0)rr4r5)r?r6r�r@r@rAr-7sz ConfigDialog.VarChanged_winWidthcGs)|jj�}|jddd|�dS)Nr2r3r/)rr4r5)r?r6r�r@r@rAr.;sz!ConfigDialog.VarChanged_winHeightcGs)|jj�}|jddd|�dS)Nr2rDzeditor-on-startup)rr4r5)r?r6r�r@r@rAr/?sz#ConfigDialog.VarChanged_startupEditcGs)|jj�}|jddd|�dS)Nr2rD�autosave)rr4r5)r?r6r�r@r@rAr0Csz ConfigDialog.VarChanged_autoSavecGs)|jj�}|jddd|�dS)Nr2r3r)rr4r5)r?r6r�r@r@rAr1Gsz ConfigDialog.VarChanged_encodingcCs)iid6id6id6id6|_dS)Nr2�	highlightr?r@)�changedItems)r?r@r@rAr8KszConfigDialog.ResetChangedItemscCsLt|�}||j|kr3i|j||<n||j|||<dS)N)�strrG)r?�typ�section�itemr�r@r@rAr5TszConfigDialog.AddChangedItemcCs�iid6id6id6id6}x�|D]�}tjd|�}xh|D]`}i|||<tj|j|�}x3|D]+}tj|j||�||||<qyWqHWq)W|S)Nr2rFr?r@r=)r�GetSectionList�
defaultCfg�
GetOptionList�Get)r?ZdItems�
configTypeZsectionsrJ�optionsZoptionr@r@rA�GetDefaultItemsZs"


1zConfigDialog.GetDefaultItemscCs�|jj�rK|jjdt�|jjdt�|jjdt�nL|jjdt�|jjdt�|jjdt�|jjdt�dS)Nr�)	r�r4r�r��NORMALr�r�r�r�)r?r@r@rAr�fszConfigDialog.SetThemeTypecCs�|jj�rK|jjdt�|jjdt�|jjdt�nL|jjdt�|jjdt�|jjdt�|jjdt�dS)Nr�)	rr4r
r�rSrr�r
r	)r?r@r@rArqszConfigDialog.SetKeysTypecCs�|jjt�}|jj|�}|j�d}|jj�rU|jj�}n|jj�}tj	�}||j
dkr�|j
d|}x%|D]}||j�||<q�Wnt|j��}t
|d||�j}	|	r�|jj�rJd}
|j|
�}|s:|jj|�|jj|�dS|j|�n|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�indexrAr4rBrr�rrZGetCurrentKeySetrGr��valuesr�result�GetNewKeysName�
select_set�
select_anchor�CreateNewKeySet�deleter�rr�)r?�	listIndex�binding�bindNameZcurrentKeySetNameZcurrentBindings�
keySetChangesr�ZcurrentKeySequences�newKeys�message�	newKeySetr@r@rAr|s<
zConfigDialog.GetNewKeyscCs>tjdd�tjdd�}t|d||�j}|S)N�userr?r=zNew Custom Key Set)rrLrrV)r?ra�	usedNamesrbr@r@rArW�s
zConfigDialog.GetNewKeysNamecCs)|jd�}|r%|j|�ndS)NzNew Key Set Name:)rWrZ)r?ZnewKeysNamer@r@rAr�szConfigDialog.SaveAsNewKeySetcCs|jjdt�dS)Nr�)rr�rS)r?r�r@r@rAr�szConfigDialog.KeyBindingSelectedc
Cs&|jj�r!|jj�}n|jj�}tj|�}i}x;|D]3}|dd�}dj||�}|||<qLW||jdkr�|jd|}x|D]}||||<q�Wn|j||�tj	dd�}	|	j
�|jj|	|�|jj
d�|j�dS)NrXr�r?rcr���)rr4r�rrZGetCoreKeys�joinrG�
SaveNewKeySetrL�sortr�SetMenur�r)
r?Z
newKeySetNameZprevKeySetNameZprevKeysr`r�Z	eventNamer]r_Z
customKeyListr@r@rArZ�s&


zConfigDialog.CreateNewKeySetc	CsEd}d}|jj�r6d}|jjt�}ntj|�}t|j��}|j�|jj	dt
�x�|D]�}dj||�}|dd�}||jdkr�||jd|kr�|jd||}q�n|jj
t
|d|�q{W|rA|jj|�|jj|�|jj|�ndS)Nrrjr�rXr?z - re)r�curselectionrTrArZ	GetKeySetr�r?rhr[r�rfrGr��seerXrY)	r?�
keySetNameZreselectrbr\rCZ	bindNamesr^�keyr@r@rArD�s(

zConfigDialog.LoadKeysListcCs>|jj�}d}tjd||d|�s5dStjdj|�||jdkrm|jd|=ntjdj�tj	dd�}|j
�|s�|jjdt
�|jj|d�n|jj||d�|jjtjd	jd
d��|jjtjd	jd
d��|j�|j�dS)
Nz0Are you sure you wish to delete the key set %r ?zDelete Key Setr3r?rcr�z- no custom keys -rr2rCr=r:)rr4�tkMessageBox�askyesnor�userCfg�remove_sectionrG�SaverLrhr	r�r�rrirr�rMrOr�rZr)r?rl�delmsg�itemListr@r@rAr�s&
##
zConfigDialog.DeleteCustomKeyscCs>|jj�}d}tjd||d|�s5dStjdj|�||jdkrm|jd|=ntjdj�tj	dd�}|j
�|s�|jjdt
�|jj|d�n|jj||d�|jjtjd	jd
d��|jjtjd	jd
d��|j�|j�dS)
Nz.Are you sure you wish to delete the theme %r ?zDelete Themer3rFrcr�z- no custom themes -rr2r9r=r:)r�r4rnrorrprqrGrrrLrhr�r�r�r�rir�r�rMrOr�rZr�)r?�	themeNamersrtr@r@rAr��s&
##
zConfigDialog.DeleteCustomThemecCs�|jj�}|jjd�}tjd|dd|d|�\}}|r�||kr�|jj�r�d}|j|�}|s�dS|j|�|j	j
|�q�|j	j
|�ndS)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�r4r�Zcget�tkColorChooserZaskcolorr��GetNewThemeName�CreateNewThemer�r�)r?�targetZ
prevColourZ	rgbTupletZcolourStringra�newThemer@r@rAr�s	
zConfigDialog.GetColourcCs�|jj�}|jjd|�|jj�r7dnd}|j|jj�d}|jj|i||6�|j	j�}|d|}|j
d|||�dS)Nrv�
foreground�
backgroundr�-rF)r�r4r�r�r�r7r�r��
tag_configr�r5)r?Z	newColour�planeZ
sampleElement�themeZthemeElementr@r@rAr8+szConfigDialog.OnNewColourSetcCs>tjdd�tjdd�}t|d||�j}|S)NrcrFr=zNew Custom Theme)rrLrrV)r?rardr{r@r@rArx5s
zConfigDialog.GetNewThemeNamecCs)|jd�}|r%|j|�ndS)NzNew Theme Name:)rxry)r?�newThemeNamer@r@rAr�<szConfigDialog.SaveAsNewThemecCs�|jj�r'd}|jj�}nd}|jj�}tj||�}||jdkr�|jd|}x|D]}||||<qyWn|j||�tjdd�}|j	�|j
j||�|jjd�|j
�dS)Nr=rcrFr)r�r4r�r�rZGetThemeDictrG�SaveNewThemerLrhr�rir�r�)r?r�Z	themeTyperur{ZthemeChangesr�ZcustomThemeListr@r@rAryAs 

zConfigDialog.CreateNewThemecCs6|jjt�}|jj|j��|j�dS)N)r~r4rArtr��lowerr�)r?r�rlr@r@rAr�Ysz$ConfigDialog.OnListFontButtonReleaseNcCsr|jj�}|jj�r'tjntj}||jj�|f}|jjd|�|j	j
d|�dS)Nrl)rtr4rsrwZBOLDrSrqr�r�r�r5)r?r�rtZ
fontWeightZnewFontr@r@rAr�^s
!zConfigDialog.SetFontSamplecCs�|jj�dkrN|jjdt�|jjdt�|jjd�n6|jjdt�|jjdt�|jjd�|j	�dS)Nr$r�rj)
r�r4r�r�r�r�r�r�rS�SetColourSample)r?r@r@rAr>eszConfigDialog.SetHighlightTargetcGs|j�dS)N)r�)r?�argsr@r@rAr�psz#ConfigDialog.SetColourSampleBindingcCsa|j|jj�d}|jj�r/dnd}|jj||�}|jjd|�dS)Nrr|r}rv)r7r�r4r�r�Ztag_cgetr�r�)r?�tagr�r�r@r@rAr�sszConfigDialog.SetColourSamplecCs$|jj�r!|jj�}n|jj�}x�|jD]�}|j|d}tj||�}|dkr�tj|ddd�|d<n||jdkr�|jd|}|d|kr�||d|d	<n|d
|kr�||d
|d<q�n|jj	||�q:W|j
�dS)Nrr"rZfgBgrvr}rFz-foregroundr|z-background)r�r4r�r�r7rZGetHighlightrGr�rr�)r?r�ZelementTitler�ZcoloursZ	themeDictr@r@rAr<zs"zConfigDialog.PaintThemeSamplecCs|j�dS)N)�SetHelpListButtonStates)r?r�r@r@rAr�szConfigDialog.HelpSourceSelectedcCs�|jj�dkr>|jjdt�|jjdt�n^|jj�rv|jjdt�|jjdt�n&|jjdt�|jjdt�dS)Nrjr�)r�sizerr�r�r rjrS)r?r@r@rAr��sz$ConfigDialog.SetHelpListButtonStatescCsht|d�j}|rZ|jj|d|df�|jjt|d�|j�n|j�dS)NzNew Help Sourcerrj)	rrV�userHelpList�appendrr�r��UpdateUserHelpChangedItemsr�)r?�
helpSourcer@r@rAr�s
zConfigDialog.HelpListItemAddcCs�|jjt�}|j|}t|dd|dd|d�j}|sX||kr\dS||j|<|jj|�|jj||d�|j�|j	�dS)NzEdit Help SourceZmenuItemrZfilePathrj)
rrTrAr�rrVr[r�r�r�)r?�	itemIndexr�Z
newHelpSourcer@r@rAr�s


zConfigDialog.HelpListItemEditcCsD|jjt�}|j|=|jj|�|j�|j�dS)N)rrTrAr�r[r�r�)r?r�r@r@rAr�s


zConfigDialog.HelpListItemRemovec	Csvi|jdd<x^tdt|j�d�D]@}|jddt|�dj|j|ddd���q.WdS)z<Clear and rebuild the HelpFiles section in self.changedItemsr2�	HelpFilesrj�;NrX)rGr�lenr�r5rHrf)r?Znumr@r@rAr��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)Nr2r3rrjrXZboldcSsg|]}|j��qSr@)r�)r��sr@r@rAr��s	z,ConfigDialog.LoadFontCfg.<locals>.<listcomp>�7�8�9r(r*r,r.�14�16�18�20�22)r�r�r�z10z11z12z13r�r�r�r�r�)r�rwZfamiliesrhr~r�r�rZGetFontr�rtr�rTrkrXrY�
ValueErrorr�rirsr�)	r?ZfontsrlZconfiguredFontrtrqrsZlc_fontsZcurrentFontIndexr@r@rA�LoadFontCfg�s*



	
zConfigDialog.LoadFontCfgcCs5tjddddddd�}|jj|�dS)Nr2r7z
num-spacesr=r��type�int)rr;rvr�)r?rvr@r@rA�
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)Nr2r9r=r��boolrjrFrcr�z- no custom themes -rrmcs�j|dS)Nrj)r7)�x)r?r@rAr�sz+ConfigDialog.LoadThemeCfg.<locals>.<lambda>)r�r�rr;ZCurrentThemer4rLrhr�rir�r�r�r�r�r�r�r7r?r�r<r>)r?�
currentOptionrtZ
themeNamesr@)r?rA�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)Nr2rCr=r�r�rjr?rcr�z- no custom keys -r)rr�rr;ZCurrentKeysr4rLrhr
rir	r�r�rrrrD)r?r�rtrlr@r@rA�
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)Nr2rDzeditor-on-startupr=rjr�r�rErr3r0r�r/rZnone)rr�rr;rrrrZGetAllExtraHelpSourcesListr�rr�r�r�)r?ZhelpItemr@r@rA�LoadGeneralCfg#szConfigDialog.LoadGeneralCfgcCs6|j�|j�|j�|j�|j�dS)z�
        load configuration from default and user config files and populate
        the widgets on the config dialog pages.
        N)r�r�r�r�r�)r?r@r@rAr=8s




zConfigDialog.LoadConfigscCsftjdj|�s-tjdj|�nx2|D]*}||}tjdj|||�q4WdS)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)rrp�has_section�add_section�	SetOption)r?rlrCr�r�r@r@rArgHs


zConfigDialog.SaveNewKeySetcCsftjdj|�s-tjdj|�nx2|D]*}||}tjdj|||�q4WdS)z�
        save a newly created theme.
        themeName - string, the name of the new theme
        theme - dictionary containing the new theme
        rFN)rrpr�r�r�)r?rur�r�r�r@r@rAr�Ts


zConfigDialog.SaveNewThemecCsltj|j||�rRtj|j||�|krRtj|j||�Sntj|j|||�S)N)rrMZ
has_optionrOrp�RemoveOptionr�)r?rPrJrKr�r@r@rA�SetUserValue`szConfigDialog.SetUserValuecCstjdj�x�|jD]�}d}x�|j|D]�}|dkrdtjdjd�d}nxO|j||D]<}|j|||}|j||||�rvd}qvqvWq5W|rtj|j�qqWx%ddgD]}tj|j�q�W|j�|j�dS)z3Save configuration changes to the user config file.r2Fr�Tr?rFN)rrprrrGrqr�r8�save_all_changed_extensions)r?rPZcfgTypeHasChangesrJrKr�r@r@rA�SaveAllChangedConfigshs"	
z"ConfigDialog.SaveAllChangedConfigscCs1|jjj�}x|D]}|j�qWdS)N)r3r4r?ZRemoveKeybindings)r?�winInstances�instancer@r@rA�DeactivateCurrentConfig~s
z$ConfigDialog.DeactivateCurrentConfigcCsY|jjj�}x@|D]8}|j�|j�|j�|j�|j�qWdS)z'Dynamically apply configuration changesN)r3r4r?ZResetColorizerZ	ResetFontZset_notabs_indentwidthZApplyKeybindingsZreset_help_menu_entries)r?r�r�r@r@rA�ActivateConfigChanges�s




z"ConfigDialog.ActivateConfigChangescCs|j�dS)N)�destroy)r?r@r@rAr;�szConfigDialog.CancelcCs|j�|j�dS)N)rZr�)r?r@r@rArY�s
zConfigDialog.OkcCs"|j�|j�|j�dS)N)r�r�r�)r?r@r@rArZ�s

zConfigDialog.Applyc	Cs6|jj}t|dddttj|d��dS)Nr6zHelp for IDLE preferencesr\r)r<Z
_current_pager	�help_common�
help_pagesr4)r?Zpager@r@rAr[�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)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 an True/False button.
        rEr@rr�rjrXZlistvariableZ
selectmodeZbrowsez<<ListboxSelect>>r]r0�r/r�r�r�Znws�ns�nsewrUrdrWNr�{z} )$r3r<rxryrrM�ext_defaultCfgrp�ext_userCfg�register�is_int�load_extensionsrpZextension_namesrrr}�extension_listr�extension_selectedr�r�r�rgrz�
details_framerr5�config_frame�current_extensionZ
outerframeZtabbed_page_set�sortedr@�create_extension_frameZ
selection_set)r?r3ryZscrollZ	ext_names�ext_namer@r@rArQ�s<	
+			
z!ConfigDialog.CreatePageExtensionsc
Cs�i|_x'tjdd�D]}g|j|<qWx�|jD]�}t|jj|��}dd�|D�}x|D]}|j|�quW||}x3|D]+}|jj||dd�}y"idd6dd6|}d	}WnItk
r+yt	|�}d
}Wnt
k
r&|}d}YnXYnXy+|jj||d|ddd
|�}Wnt
k
rq|}YnXt|�}	|	j
t|��|j|ji|d6|d6|d
6|d6|	d6�q�Wq=WdS)zAFill self.extensions with data from the default and user configs.Zactive_onlyFcSs%g|]}|jd�r|�qS)�enable)�
startswith)r��opt_namer@r@rAr��s	z0ConfigDialog.load_extensions.<locals>.<listcomp>�rawT�True�Falser�r�Nr�r=r:r��var)r@rZ
GetExtensionsr�r�rN�removerO�KeyErrorr�r�r�rpr�rHr�)
r?r�Zopt_listZenablesr�Zdef_strZdef_objZopt_typer�r�r@r@rAr��sF	


	



	

zConfigDialog.load_extensionscCs�|jj�}|r*|jj|�}n|dksE||jkr�|jr�|jjdd�|j|jj�d|_q�n|r�|jjd|�|j|jdddddd�||_ndS)Nr\rr�rr�r�r�)	r�rjr4r�r�r�r�Zgrid_forgetr)r?r�Znewselr@r@rAr�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) z=Create a frame holding the widgets to configure one extensionr/r�r0r\r:r�r�rr�r�r�r�rrhrir�rkr�ZindicatoronZselectcolorrr�rjrU�r�ZvalidatermZvalidatecommandz%PN)�VerticalScrolledFramer�r��interior�	enumerater@r|r�NWr�r:r�rr�r)r?r��fZ
entry_arear��optZlabelr�r@r@rAr�s&
	 
z#ConfigDialog.create_extension_framecCsv|d}|d}|dj�j�p-|}|dj|�||kr`|jj||�S|jj|||�S)Nr:r=r�)r4�stripr�r�r�r�)r?rJr�r:r=r�r@r@rA�set_extension_value*s

z ConfigDialog.set_extension_valuecCsmd}xJ|jD]?}|j|}x)|D]!}|j||�r*d}q*q*WqW|ri|jj�ndS)z3Save configuration changes to the user config file.FTN)r@r�r�rr)r?Zhas_changesr�rQr�r@r@rAr�6s

z(ConfigDialog.save_all_changed_extensions)O�__name__�
__module__�__qualname__r2r9rRrMrNrOrPr>r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r8r5rRr�rrrWrrrZrDrr�r�r8rxr�ryr�r�r>r�r�r<rr�rrrr�r�r�r�r�r�r=rgr�r�r�r�r�r;rYrZr[rQr�r�r�r�r�r@r@r@rArs�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.
z�
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.
rBcCs9|s
dSyt|�dSWntk
r4dSYnXdS)z(Return 's is blank or represents an int'TFN)r�r�)r�r@r@rAr�Ts

r�c@s"eZdZdZdd�ZdS)r�z�A 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�}|jdtdtdt�t|ddddd|j	d	d
���jdt
dtdt�|j
d�j��jd��jd�t��|_��jddd�d
t����fdd�}�jd|����fdd�}�jd|�dS)NrmrHrFrGr�rr�rgr0��r]Zwindowrocs0�j��j�f}�jdd|�dS)NZscrollregionz	0 0 %s %s)�winfo_reqwidthZwinfo_reqheightr�)r�r�)�canvasr�r@rA�_configure_interior{sz;VerticalScrolledFrame.__init__.<locals>._configure_interiorz<Configure>cs8�j��j�kr4�j�d�j��ndS)Nr0)r�Zwinfo_widthZ
itemconfigure)r�)r�r��interior_idr@rA�_configure_canvas�sz9VerticalScrolledFrame.__init__.<locals>._configure_canvas)r_r2r�ZVERTICALrIr�r�r:ZCanvasr�rarLrKr�r�Zxview_movetoZyview_movetor�Z
create_windowr�r)r?r3r��kwZ
vscrollbarr�r�r@)r�r�r�rAr2fs 

zVerticalScrolledFrame.__init__N)r�r�r��__doc__r2r@r@r@rAr�_sr��__main__z#idlelib.idle_test.test_configdialog�	verbosityrX�exitF)�run)'r�ZtkinterZtkinter.messageboxZ
messageboxrnZtkinter.colorchooserZcolorchooserrwZtkinter.fontrlrwZidlelib.configHandlerrZidlelib.dynOptionMenuWidgetrZidlelib.keybindingDialogrZidlelib.configSectionNameDialogrZidlelib.configHelpSourceEditrZidlelib.tabbedpagesrZidlelib.textViewr	Zidlelibr
r1rr�r�r�r_r�r�Zunittestr2Zidlelib.idle_test.htestr�r@r@r@rA�<module>s:
�����4
+


?>