AlkantarClanX12

Your IP : 3.138.135.201


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-1.pyc



��Yf%��@sVdZddlTddljZddljZddlj	Z
ddlmZddl
mZddlmZddlmZddlmZdd	lmZdd
lmZddlmZGdd
�d
e�ZdZddiZdd�ZGdd�de �Z!e"dkrRddl#Z#e#j$ddddd�ddl%m&Z&e&e�dS)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-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�dd6dd7dd8dd9dd: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�|j�d5S)Dz�
        _htest - bool, change box location when running htest
        _utest - bool, don't wait_window when running unittest
        �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_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_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/python35/lib64/python3.5/idlelib/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?r@r@rAr9Qs	




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�	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�rFrTrVrGrH�anchorr)rcrdr)+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�bdrFrTrrVrGrH��rWro)rcr�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�);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)rTrXrVr
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 SetrFrTrrVrGrH�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�textvariabler0rWZHeightr/rr^rfrgz<ButtonRelease-1>ZEditr�r�ZAddZRemoverFrTrVrHrGrord)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.AttachVarCallbackscCs�x�|j|j|j|j|j|j|j|j|j|j	|j
|j|j|j
|j|j|j|jfD]$}|jd|j�dd�qsWdS)z)Remove callbacks to prevent memory leaks.rrrjN)rqrtrsrvr�r�r�r�r�r�r�r�r�rrrrrZ
trace_vdeleteZtrace_vinfo)r?�varr@r@rA�remove_var_callbacks�sz!ConfigDialog.remove_var_callbackscGss|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)Nr.�Indentz
num-spaces)rvr0r1)r?r2r�r@r@rAr�sz ConfigDialog.VarChanged_spaceNumcGs|j�dS)N)�OnNewColourSet)r?r2r@r@rArszConfigDialog.VarChanged_colourcGs�|jj�}|dkr~tjddd�dkrL|jdddd�|jddd|�|jjdd	d
d�nE|jddd|�|jdddd�|jjddd
d
�|j�dS)Nz	IDLE Darkr.�Theme�namezIDLE NewzIDLE ClassicZname2r\zNew theme, see HelpZfgz#500000rZblack)r�r0r�	GetOptionr1r�r��PaintThemeSample)r?r2r�r@r@rArs
z$ConfigDialog.VarChanged_builtinThemecGs?|jj�}|dkr;|jddd|�|j�dS)Nz- no custom themes -r.r5r6)r�r0r1r8)r?r2r�r@r@rAr sz#ConfigDialog.VarChanged_customThemecGsF|jj�}|jddd|�|r8|j�n
|j�dS)Nr.r5�default)r�r0r1rr )r?r2r�r@r@rAr!s

z&ConfigDialog.VarChanged_themeIsBuiltincGs|j�dS)N)�SetHighlightTarget)r?r2r@r@rAr" sz'ConfigDialog.VarChanged_highlightTargetcGs�|jj�}|jj�}|jjt�j�d}tj|�rb|jd|||�n/tj	|�}|d}|jd|||�dS)Nr�keysZ_cfgBindings�
extensions)
r�r0r�r��ANCHOR�splitrZ
IsCoreBindingr1ZGetExtnNameForEvent)r?r2r��keySetr�ZextNameZextKeybindSectionr@r@rAr##s
z"ConfigDialog.VarChanged_keyBindingcGs6|jj�}|jddd|�|j|�dS)Nr.rCr6)r�r0r1�LoadKeysList)r?r2r�r@r@rAr$/sz#ConfigDialog.VarChanged_builtinKeyscGsB|jj�}|dkr>|jddd|�|j|�dS)Nz- no custom keys -r.rCr6)r�r0r1r@)r?r2r�r@r@rAr%4sz"ConfigDialog.VarChanged_customKeyscGsF|jj�}|jddd|�|r8|j�n
|j�dS)Nr.rCr9)r�r0r1r$r%)r?r2r�r@r@rAr&:s

z&ConfigDialog.VarChanged_keysAreBuiltincGs)|jj�}|jddd|�dS)Nr.r/r0)rr0r1)r?r2r�r@r@rAr'Bsz ConfigDialog.VarChanged_winWidthcGs)|jj�}|jddd|�dS)Nr.r/r/)rr0r1)r?r2r�r@r@rAr(Fsz!ConfigDialog.VarChanged_winHeightcGs)|jj�}|jddd|�dS)Nr.rDzeditor-on-startup)rr0r1)r?r2r�r@r@rAr)Jsz#ConfigDialog.VarChanged_startupEditcGs)|jj�}|jddd|�dS)Nr.rD�autosave)rr0r1)r?r2r�r@r@rAr*Nsz ConfigDialog.VarChanged_autoSavecGs)|jj�}|jddd|�dS)Nr.r/r)rr0r1)r?r2r�r@r@rAr+Rsz ConfigDialog.VarChanged_encodingcCs%didididii|_dS)Nr.�	highlightr;r<)�changedItems)r?r@r@rAr8VszConfigDialog.ResetChangedItemscCsIt|�}||j|kr0i|j||<||j|||<dS)N)�strrC)r?�typ�section�itemr�r@r@rAr1_szConfigDialog.AddChangedItemcCs�didididii}x�|D]�}tjd|�}xh|D]`}i|||<tj|j|�}x3|D]+}tj|j||�||||<quWqDWq%W|S)Nr.rBr;r<r9)r�GetSectionList�
defaultCfg�
GetOptionList�Get)r?ZdItems�
configTypeZsectionsrF�optionsZoptionr@r@rA�GetDefaultItemses


1zConfigDialog.GetDefaultItemscCs�|jj�rK|jjdt�|jjdt�|jjdt�nL|jjdt�|jjdt�|jjdt�|jjdt�dS)Nr�)	r�r0r�r��NORMALr�r�r�r�)r?r@r@rAr�qszConfigDialog.SetThemeTypecCs�|jj�rK|jjdt�|jjdt�|jjdt�nL|jjdt�|jjdt�|jjdt�|jjdt�dS)Nr�)	r�r0rr�rOrr�rr)r?r@r@rAr|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=r0r>r�r�r�rZGetCurrentKeySetrCr��valuesr�result�GetNewKeysName�
select_set�
select_anchor�CreateNewKeySet�deleter�r�r�)r?�	listIndex�binding�bindNameZcurrentKeySetNameZcurrentBindings�
keySetChangesr�ZcurrentKeySequences�newKeys�message�	newKeySetr@r@rAr��s<

zConfigDialog.GetNewKeyscCs>tjdd�tjdd�}t|d||�j}|S)N�userr;r9zNew Custom Key Set)rrHrrR)r?r]�	usedNamesr^r@r@rArS�s
zConfigDialog.GetNewKeysNamecCs&|jd�}|r"|j|�dS)NzNew Key Set Name:)rSrV)r?ZnewKeysNamer@r@rAr�szConfigDialog.SaveAsNewKeySetcCs|jjdt�dS)Nr�)rr�rO)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�W|j||�tj	dd�}	|	j
�|jj|	|�|jj
d�|j�dS)NrXr�r;r_r���)r�r0r�r�rZGetCoreKeys�joinrC�
SaveNewKeySetrH�sortr�SetMenur�r)
r?Z
newKeySetNameZprevKeySetNameZprevKeysr\r�Z	eventNamerYr[Z
customKeyListr@r@rArV�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)Nrrjr�rXr;z - ra)r��curselectionrPr=rZ	GetKeySetr�r;rdrWr�rbrCr��seerTrU)	r?�
keySetNameZreselectr^rXr?Z	bindNamesrZ�keyr@r@rAr@�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;r_r�z- no custom keys -rr.rCr9r6)r�r0�tkMessageBox�askyesno�DeactivateCurrentConfigr�userCfg�remove_sectionrC�SaverHrdrr�r�rrer�r�rIrKr��SaveAllChangedConfigs�ActivateConfigChangesr)r?rh�delmsg�itemListr@r@rAr�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 Themer3rBr_r�z- no custom themes -rr.r5r9r6)r�r0rjrkrlrrmrnrCrorHrdr�r�r�r�rer�r�rIrKr�rprqr�)r?�	themeNamerrrsr@r@rAr�	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�r0r�Zcget�tkColorChooserZaskcolorr��GetNewThemeName�CreateNewThemer�r�)r?�targetZ
prevColourZ	rgbTupletZcolourStringr]�newThemer@r@rAr�&s	
zConfigDialog.GetColourcCs�|jj�}|jjd|�|jj�r7dnd}|j|jj�d}|jj|||i�|j	j�}|d|}|j
d|||�dS)Nru�
foreground�
backgroundr�-rB)r�r0r�r�r�r7r�r��
tag_configr�r1)r?Z	newColour�planeZ
sampleElement�themeZthemeElementr@r@rAr4:szConfigDialog.OnNewColourSetcCs>tjdd�tjdd�}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@rAr�KszConfigDialog.SaveAsNewThemecCs�|jj�r'd}|jj�}nd}|jj�}tj||�}||jdkr�|jd|}x|D]}||||<qyW|j||�tjdd�}|j	�|j
j||�|jjd�|j
�dS)Nr9r_rBr)r�r0r�r�rZGetThemeDictrC�SaveNewThemerHrdr�rer�r�)r?r�Z	themeTypertrzZthemeChangesr�ZcustomThemeListr@r@rArxPs 

zConfigDialog.CreateNewThemecCs6|jjt�}|jj|j��|j�dS)N)r~r0r=rtr��lowerr�)r?r�rlr@r@rAr�hsz$ConfigDialog.OnListFontButtonReleaseNcCsr|jj�}|jj�r'tjntj}||jj�|f}|jjd|�|j	j
d|�dS)Nrl)rtr0rsrwZBOLDrOrqr�r�r�r5)r?r�rtZ
fontWeightZnewFontr@r@rAr�ms
!zConfigDialog.SetFontSamplecCs�|jj�dkrN|jjdt�|jjdt�|jjd�n6|jjdt�|jjdt�|jjd�|j	�dS)Nr"r�rj)
r�r0r�r�r�r�r�r�rO�SetColourSample)r?r@r@rAr:tszConfigDialog.SetHighlightTargetcGs|j�dS)N)r�)r?�argsr@r@rAr�sz#ConfigDialog.SetColourSampleBindingcCsa|j|jj�d}|jj�r/dnd}|jj||�}|jjd|�dS)Nrr{r|ru)r7r�r0r�r�Ztag_cgetr�r�)r?�tagrr�r@r@rAr��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#rZfgBgrur|rBz-foregroundr{z-background)r�r0r�r�r7rZGetHighlightrCr�r~r�)r?r�ZelementTitler�ZcoloursZ	themeDictr@r@rAr8�s"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�rrfrO)r?r@r@rAr��sz$ConfigDialog.SetHelpListButtonStatescCset|d�j}|rW|jj|d|df�|jjt|d�|j�|j�dS)NzNew Help Sourcerrj)	rrR�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)
rrPr=r�rrRrWr�r�r�)r?�	itemIndexr�Z
newHelpSourcer@r@rAr�s


zConfigDialog.HelpListItemEditcCsD|jjt�}|j|=|jj|�|j�|j�dS)N)rrPr=r�rWr�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.changedItemsr.�	HelpFilesrj�;NrX)rCr�lenr�r1rDrb)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)Nr.r/rrjrXZboldcSsg|]}|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�r(r*r,r.r�r�r�r�r�)r�rwZfamiliesrdr~r�r�rZGetFontr�rtr�rPrgrTrU�
ValueErrorr�rersr�)	r?ZfontsrlZconfiguredFontrtrqrsZlc_fontsZcurrentFontIndexr@r@rA�LoadFontCfg�s*



	
zConfigDialog.LoadFontCfgcCs5tjddddddd�}|jj|�dS)Nr.r3z
num-spacesr9r��type�int)rr7rvr�)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)Nr.r5r9r��boolrjrBr_r�z- no custom themes -rrics�j|dS)Nrj)r7)�x)r?r@rAr�sz+ConfigDialog.LoadThemeCfg.<locals>.<lambda>)r�r�rr7ZCurrentThemer0rHrdr�rer�r�r�r�r�r�r�r7r;r�r8r:)r?�
currentOptionrsZ
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)Nr.rCr9r�r�rjr;r_r�z- no custom keys -r)r�r�rr7ZCurrentKeysr0rHrdrrerr�r�r�rrr@)r?r�rsrhr@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)Nr.rDzeditor-on-startupr9rjr�r�rArr/r0r�r/rZnone)rr�rr7rrrrZGetAllExtraHelpSourcesListr�rr�r�r�)r?ZhelpItemr@r@rA�LoadGeneralCfg2szConfigDialog.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=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?r�r�r@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)rrmr�r�r�)r?rtr�r�r�r@r@rAr�cs


zConfigDialog.SaveNewThemecCsitj|j||�rOtj|j||�|krOtj|j||�Stj|j|||�S)N)rrIZ
has_optionrKrm�RemoveOptionr�)r?rLrFrGr�r@r@rA�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)z3Save configuration changes to the user config file.r.Fr�Tr;rBN)rrmrorCrnr�r8�save_all_changed_extensions)r?rLZcfgTypeHasChangesrFrGr�r@r@rArpws"
z"ConfigDialog.SaveAllChangedConfigscCs1|jjj�}x|D]}|j�qWdS)N)r3r4r;ZRemoveKeybindings)r?�winInstances�instancer@r@rArl�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@rArq�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)rlrprq)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_pagesr0)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 a True/False button.
        rEr<rr�rjrXZlistvariableZ
selectmodeZbrowsez<<ListboxSelect>>r]r0�r/r�r�r�Znws�ns�nsewrTrdrVNr�{z} )$r3r<rxryrrI�ext_defaultCfgrm�ext_userCfg�register�is_int�load_extensionsrpZextension_namesr
r	r}�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||}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)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�r9r6r�r,)r<rZ
GetExtensionsr�r�rJ�removerK�KeyErrorr�r�r�rpr�rDr�)
r?r�Zopt_listZenablesr�Zdef_strZdef_objZopt_typer�r,r@r@rAr��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�rfr0r�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\r6r�r�rr�r,r�r�r
rhrir�rkr�ZindicatoronZselectcolorrr�rjrT�r�ZvalidateriZvalidatecommandz%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)Nr6r9r,)r0�stripr�r�r�r�)r?rFr�r6r9r�r@r@rA�set_extension_value9s

z ConfigDialog.set_extension_valuecCsgd}xG|jD]<}|j|}x&|D]}|j||�r*d}q*WqW|rc|jj�dS)z3Save configuration changes to the user config file.FTN)r<r�r�ro)r?Zhas_changesr�rMr�r@r@rAr�Es

z(ConfigDialog.save_all_changed_extensions)P�__name__�
__module__�__qualname__r2r9rRrMrNrOrPr>r-rrrrr r!r"r#r$r%r&r'r(r)r*r+r8r1rNr�rr�rSrr�rVr@rr�r�r4rwr�rxr�r�r:r�r�r8rr�rrrr�r�r�r�r�r�r=rcr�r�rprlrqr;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.
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.
cCs9|s
dSyt|�dSWntk
r4dSYnXdS)z(Return 's is blank or represents an int'TFN)r�r�)r�r@r@rAr�cs

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>cs5�j��j�kr1�j�d�j��dS)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�rAr2us 

zVerticalScrolledFrame.__init__N)r�r�r��__doc__r2r@r@r@rAr�nsr��__main__z#idlelib.idle_test.test_configdialog�	verbosityrX�exitF)�run)'r�ZtkinterZtkinter.messageboxZ
messageboxrjZtkinter.colorchooserZcolorchooserrvZtkinter.fontrlrwZidlelib.configHandlerrZidlelib.dynOptionMenuWidgetrZidlelib.keybindingDialogrZidlelib.configSectionNameDialogrZidlelib.configHelpSourceEditrZidlelib.tabbedpagesrZidlelib.textViewr	Zidlelibr
r1rr�r�r�r_r�r�Zunittestr.Zidlelib.idle_test.htestr�r@r@r@rA�<module>s:
�����C	+