Hacked By AnonymousFox

Current Path : /opt/alt/python36/lib64/python3.6/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/idlelib/__pycache__/configdialog.cpython-36.opt-1.pyc

3

� f���@sJdZddlmZmZmZmZmZmZmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z ddl!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,ddl-j.Z/ddl0j1Z2ddlm3Z3ddl4m5Z5m6Z6ddl7m8Z8ddl9m:Z:dd	l;m<Z<dd
l=m>Z>m?Z?ddl@mAZAddlBmCZCdd
lDmEZEddlFmGZGddlHmIZIddlJmKZKe6�ZLeCeEeGeIeKfZMGdd�de�ZNdaOGdd�de%�ZPGdd�de%�ZQGdd�de%�ZRGdd�de%�ZSGdd�d�ZTeT�ZUdZVdd d!d"d#�ZWd$d%�ZXGd&d'�d'e%�ZYeZd(k�rFdd)l[m\Z\e\d*d+d,d-�dd.l]m^Z^e^eN�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.

�)�Toplevel�Listbox�Text�Scale�Canvas�	StringVar�
BooleanVar�IntVar�TRUE�FALSE�TOP�BOTTOM�RIGHT�LEFT�SOLID�GROOVE�NONE�BOTH�X�Y�W�E�EW�NS�NSEW�NW�
HORIZONTAL�VERTICAL�ANCHOR�ACTIVE�END)�Button�Checkbutton�Entry�Frame�Label�
LabelFrame�
OptionMenu�Notebook�Radiobutton�	Scrollbar�StyleN)�
messagebox)�idleConf�
ConfigChanges)�
GetKeysDialog)�
DynOptionMenu)�macosx)�SectionName�
HelpSource)�	view_text)�AutoComplete)�CodeContext)�
ParenMatch)�FormatParagraph)�Squeezercs�eZdZdZd%ddd�dd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	�fdd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Z�ZS)&�ConfigDialogzConfig dialog for IDLE.
    �F)�_htest�_utestcCs�tj||�||_|ri|_|s(|j�|jdd�|j|p>d�|j�d}|j�|s\dnd}|j	d|�d|���|j
�|jttd�|j
|�|jd	|j�|jjj�tj�|s�|j�|j�|j�d
S)a�Show the tabbed dialog for user configuration.

        Args:
            parent - parent of this dialog
            title - string which is the title of this popup dialog
            _htest - bool, change box location when running htest
            _utest - bool, don't wait_window when running unittest

        Note: Focus set on font page fontlist.

        Methods:
            create_widgets
            cancel: Bound to DELETE_WINDOW protocol.
        �)�borderwidthzIDLE Preferences����+)�height�widthZWM_DELETE_WINDOWN)r�__init__�parent�
instance_dictZwithdraw�	configure�titleZwinfo_rootxZwinfo_rootyZgeometry�create_widgetsZ	resizablerZ	transientZprotocol�cancel�fontpage�fontlistZ	focus_set�tracers�attachZgrab_setZwm_deiconifyZwait_window)�selfrGrJr<r=�x�y�rT�9/opt/alt/python36/lib64/python3.6/idlelib/configdialog.pyrF-s*
zConfigDialog.__init__cCs�t|�|_}t|�|_t||j�|_t|�|_t|�|_	|j
�|_|j|jdd�|j|jdd�|j|jdd�|j|j	dd�|j|jdd�|j
�|jtttd�|j�jtd�d	S)
a�Create and place widgets for tabbed dialog.

        Widgets Bound to self:
            note: Notebook
            highpage: HighPage
            fontpage: FontPage
            keyspage: KeysPage
            genpage: GenPage
            extpage: self.create_page_extensions

        Methods:
            create_action_buttons
            load_configs: Load pages except for extensions.
            activate_config_changes: Tell editors to reload.
        z
Fonts/Tabs)�text�
Highlightsz Keys z	 General Z
Extensions)�side�expand�fill)rXN)r(�note�HighPage�highpage�FontPagerM�KeysPageZkeyspage�GenPageZgenpage�create_page_extensionsZextpage�addZenable_traversal�packrr
r�create_action_buttonsr
)rQr[rTrTrUrK]s



zConfigDialog.create_widgetscCs�tj�ri}nddi}t|dd�}t|dd�}xRd|jfd|jfd|jfd	|jffD]*\}}t|f||td
�|��j	t
dd�qTWt|dd
d�j	td�|j	td�|S)a�Return frame of action buttons for dialog.

        Methods:
            ok
            apply
            cancel
            help

        Widget Structure:
            outer: Frame
                buttons: Frame
                    (no assignment): Button (ok)
                    (no assignment): Button (apply)
                    (no assignment): Button (cancel)
                    (no assignment): Button (help)
                (no assignment): Frame
        �padding���)reZOkZApplyZCancelZHelp)rV�command�	takefocusr>)rX�padxr)rDr?)rX)rfrg)
r1ZisAquaTkr$�ok�applyrL�helpr!rrcrrr
)rQZpadding_argsZouterZbuttonsZtxt�cmdrTrTrUrd|sz"ConfigDialog.create_action_buttonscCs|j�|j�dS)zvApply config changes, then dismiss dialog.

        Methods:
            apply
            destroy: inherited
        N)rm�destroy)rQrTrTrUrl�szConfigDialog.okcCs$|j�tj�|j�|j�dS)z�Apply config changes and leave dialog open.

        Methods:
            deactivate_current_config
            save_all_changed_extensions
            activate_config_changes
        N)�deactivate_current_config�changes�save_all�save_all_changed_extensions�activate_config_changes)rQrTrTrUrm�szConfigDialog.applycCs|j�dS)zPDismiss config dialog.

        Methods:
            destroy: inherited
        N)rp)rQrTrTrUrL�szConfigDialog.cancelcs&|jjjdd�a|j�t�j�dS)Nz1.0�end)rM�font_sample�get�font_sample_textZgrab_release�superrp)rQ)�	__class__rTrUrp�szConfigDialog.destroycCs8|jj|jj�dd�j�}t|dttj|d�d�dS)z�Create textview for config dialog help.

        Attrbutes accessed:
            note

        Methods:
            view_text: Method from textview module.
        rV)ZoptionzHelp for IDLE preferencesr;)rJrVN)r[ZtabZselect�stripr4�help_common�
help_pagesrx)rQZpagerTrTrUrn�s	zConfigDialog.helpcCs&|jjj�}x|D]}|j�qWdS)z�Remove current key bindings.
        Iterate over window instances defined in parent and remove
        the keybindings.
        N)rGrH�keysZRemoveKeybindings)rQ�
win_instances�instancerTrTrUrq�s
z&ConfigDialog.deactivate_current_configcCs\|jjj�}x4|D],}|j�|j�|j�|j�|j�qWxtD]}|j	�qHWdS)z�Apply configuration changes to current windows.

        Dynamically update the current parent window instances
        with some of the configuration changes.
        N)
rGrHrZResetColorizerZ	ResetFontZset_notabs_indentwidthZApplyKeybindingsZreset_help_menu_entries�reloadables�reload)rQr�r��klassrTrTrUru�s

z$ConfigDialog.activate_config_changescCsh|j}t|j�}tjd|_tjd|_|jt	�|_	|j
�t|�|_|j
ddd�|jddd�t||jdd�|_|jjd|j�t||jjd	�}|j|j_t|d
d
d�|_|jjdddd
�|jdddd
�|jjdddddgd�|jdd�i|_d|_||_|j|_d}x.t|j �D] }|j!|�|d|d}�qW|jj|�|jj"d�|jd�|S)a7Part 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.

        Methods:
            load_extensions:
            extension_selected: Handle selection from list.
            create_extension_frame: Hold widgets for one extension.
            set_extension_value: Set in userCfg['extensions'].
            save_all_changed_extensions: Call extension page Save().
        �
extensionsr�)�weightrhZbrowse)ZlistvariableZ
selectmodez<<ListboxSelect>>)ri�)rErDZnws)�column�row�sticky�ns�nsew�
)r�r�r�rk)reNr;�{z} )#rGr$r[r-�
defaultCfg�ext_defaultCfg�userCfg�ext_userCfg�register�is_int�load_extensionsrZextension_names�rowconfigure�columnconfigurer�extension_list�bind�extension_selectedr*�yview�set�yscrollcommandr&�
details_frame�gridrI�config_frame�current_extensionZ
outerframeZtabbed_page_set�sortedr��create_extension_frameZ
selection_set)rQrG�frameZscrollZ	ext_names�ext_namerTrTrUra�s>





z#ConfigDialog.create_page_extensionsc
Cs^i|_xtjdd�D]}g|j|<qW�x0|jD�]$}t|jj|��}dd�|D�}x|D]}|j|�qZW||}x�|D]�}|jj||dd�}yddd�|}d}WnBtk
r�yt	|�}d	}Wnt
k
r�|}d
}YnXYnXy|jj|||d|d�}Wnt
k
�r|}YnXt|�}	|	j
t|��|j|j|||||	d��qzWq0Wd
S)
zAFill self.extensions with data from the default and user configs.F)Zactive_onlycSsg|]}|jd�r|�qS)�enable)�
startswith)�.0�opt_namerTrTrU�
<listcomp>8sz0ConfigDialog.load_extensions.<locals>.<listcomp>T)�raw)�True�False�bool�intN)�typer��default)�namer�r��value�var)r�r-Z
GetExtensionsr�r�Z
GetOptionList�remove�Get�KeyErrorr��
ValueErrorr�rr��str�append)
rQr�Zopt_listZenablesr�Zdef_strZdef_objZopt_typer�r�rTrTrUr�-sF


zConfigDialog.load_extensionscCs�|jj�}|r|jj|�}|dks,||jkrV|jrV|jjdd�|j|jj�d|_|r�|jj|d�|j|jdddd�||_dS)z/Handle selection of an extension from the list.Nr;)rVrr�)r�r�r�)	r��curselectionrxr�r��configr�Zgrid_forgetr�)rQ�eventZnewselrTrTrUr�[s
zConfigDialog.extension_selectedcCs�t|jddd�}||j|<|j}x�t|j|�D]�\}}t||dd�}|j|dtd�|d}|dd	kr�t	||d
ddd
�j|dt
dd�q0|ddkr�t||d|jdfdd�j|dt
dd�q0t||dd�j|dt
dd�q0WdS)z=Create a frame holding the widgets to configure one extensionr�)rDrEr�)rVr)r�r�r�r�r�r�r�r��)�variable�onvalue�offvaluerEr��)r�r�r�rkr��keyz%Pr�)�textvariableZvalidateZvalidatecommandrE�)r�rEN)�VerticalScrolledFramer�r��interior�	enumerater�r%r�rr"rr#r�r)rQr��fZ
entry_arear��optZlabelr�rTrTrUr�js$
z#ConfigDialog.create_extension_framecCsX|d}|d}|dj�j�p"|}|dj|�||krH|jj||�S|jj|||�S)z�Return True if the configuration was added or changed.

        If the value is the same as the default, then remove it
        from user config file.
        r�r�r�)rxr|r�r�ZRemoveOption�	SetOption)rQZsectionr�r�r�r�rTrTrU�set_extension_value�sz ConfigDialog.set_extension_valuecCsNd}x6|jD],}|j|}x|D]}|j||�r d}q WqW|rJ|jj�dS)z�Save configuration changes to the user config file.

        Attributes accessed:
            extensions

        Methods:
            set_extension_value
        FTN)r�r�r�ZSave)rQZhas_changesr�Zoptionsr�rTrTrUrt�s	

z(ConfigDialog.save_all_changed_extensions)r;)�__name__�
__module__�__qualname__�__doc__rFrKrdrlrmrLrprnrqrurar�r�r�r�rt�
__classcell__rTrT)r{rUr:)s"0&


>.r:u^<ASCII/Latin1>
AaBbCcDdEeFfGgHhIiJj
1234567890#:+=(){}[]
¢£¥§©«®¶½ĞÀÁÂÃÄÅÇÐØß

<IPA,Greek,Cyrillic>
ɐɕɘɞɟɤɫɮɰɷɻʁʃʆʎʞʢʫʭʯ
ΑαΒβΓγΔδΕεΖζΗηΘθΙιΚκ
БбДдЖжПпФфЧчЪъЭэѠѤѬӜ

<Hebrew, Arabic>
אבגדהוזחטיךכלםמןנסעף
ابجدهوزحطي٠١٢٣٤٥٦٧٨٩

<Devanagari, Tamil>
०१२३४५६७८९अआइईउऊएऐओऔ
௦௧௨௩௪௫௬௭௮௯அஇஉஎ

<East Asian>
〇一二三四五六七八九
汉字漢字人木火土金水
가냐더려모뵤수유즈치
あいうえおアイウエオ
csVeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zddd
�Zdd�Z	dd�Z
�ZS)r^cs0t�j|�|j|_|j�|j�|j�dS)N)rzrF�highlight_sample�create_page_font_tab�
load_font_cfg�load_tab_cfg)rQ�masterr])r{rTrUrF�s
zFontPage.__init__c
Cs~tjt|�|j�|_tjt|�|j�|_tjt|�|j�|_tjt|�d.�|_	t
|dtdd�}t
|dtdd�}t
|dtdd�}t|�}t|�}t
|td	d
�}t|ddtd
�|_|jjd|j�|jjd|j�|jjd|j�t|�}|j|jjd�|jj|jd�t
|dd�}t||jd�|_t||jdddd�|_t|ddd�|_|jjtt �t
|tdd
�}	t!||j	ddddd�|_"|j#ddd �|j$ddd!d!d"�|j$dddd!d!d#d$�|j$ddd!d!d%d&�|j%t&d!d!t'd'�|j%t&d!d!t'd'�|j%t&t(d(�|jj%tt)t'd)�|j%tt*d*�|j%tt(d(�|jj%tt(d(�|jj%tt(dd+�|jj%t)t+d,�|	j%t&t(d!d+�|j"j%t&d!t'd-�dS)/a�Return frame of widgets for Font/Tabs tab.

        Fonts: Enable users to provisionally change font face, size, or
        boldness and to see the consequence of proposed choices.  Each
        action set 3 options in changes structuree and changes the
        corresponding aspect of the font sample on this page and
        highlight sample on highlight page.

        Function load_font_cfg initializes font vars and widgets from
        idleConf entries and tk.

        Fontlist: mouse button 1 click or up or down key invoke
        on_fontlist_select(), which sets var font_name.

        Sizelist: clicking the menubutton opens the dropdown menu. A
        mouse button 1 click or return key sets var font_size.

        Bold_toggle: clicking the box toggles var font_bold.

        Changing any of the font vars invokes var_changed_font, which
        adds all 3 font options to changes and calls set_samples.
        Set_samples applies a new font constructed from the font vars to
        font_sample and to highlight_sample on the highlight page.

        Tabs: Enable users to change spaces entered for indent tabs.
        Changing indent_scale value with the mouse sets Var space_num,
        which invokes the default callback to add an entry to
        changes.  Load_tab_cfg initializes space_num to default.

        Widgets for FontPage(Frame):  (*) widgets bound to self
            frame_font: LabelFrame
                frame_font_name: Frame
                    font_name_title: Label
                    (*)fontlist: ListBox - font_name
                    scroll_font: Scrollbar
                frame_font_param: Frame
                    font_size_title: Label
                    (*)sizelist: DynOptionMenu - font_size
                    (*)bold_toggle: Checkbutton - font_bold
            frame_sample: LabelFrame
                (*)font_sample: Label
            frame_indent: LabelFrame
                    indent_title: Label
                    (*)indent_scale: Scale - space_num
        �main�Indent�
num-spacesrhz Shell/Editor Font )r?�reliefrVz Font Sample (Editable) z Indentation Width zFont Face :)ZjustifyrVr�T)rDrj�exportselectionz<ButtonRelease-1>z<KeyRelease-Up>z<KeyRelease-Down>)ri)r�zSize :)rVNr�rZBold)r�r�r�rVr@)rErDzPython Standard: 4 Spaces!Z
horizontal�)r��orientZtickintervalZfrom_Zto)r�r>)r�r�rk�padyr�)r�r�Zrowspanrkr�r�Zew)r�r�rkr�r�)rXrkr�rZ)rX�anchor)rXrYrZ)rXrZ)rXr�rk)rYrZ)rXrkrZ)r�r�r�),rOrbr�var_changed_font�	font_name�	font_sizer�	font_boldr	�	space_numr&rr$r%rrrrNr��on_fontlist_selectr*r�r�r�r0�sizelistr"Zbold_togglerrw�insertr ryrZindent_scaler�r�rcrrrr
rr)
rQZ
frame_fontZframe_sampleZframe_indentZframe_font_nameZframe_font_paramZfont_name_titleZscroll_fontZfont_size_titleZindent_titlerTrTrUr��sh.zFontPage.create_page_font_tabc	Cs�tj|dd�}|dj�}|d}|ddk}ttj|��}|j�x|D]}|jjt	|�qJW|j
j|�dd�|D�}y>|j|�}|jj
|�|jj|�|jj|�|jj|�Wntk
r�YnX|jjd|�|jj|�|j�dS)aLoad current configuration settings for the font options.

        Retrieve current font with idleConf.GetFont and font families
        from tk. Setup fontlist and set font_name.  Setup sizelist,
        which sets font_size.  Set font_bold.  Call set_samples.
        r��EditorWindowrr�rhZboldcSsg|]}|j��qSrT)�lower)r��srTrTrUr�^sz*FontPage.load_font_cfg.<locals>.<listcomp>�7�8�9�10�11�12�13�14�16�18�20�22�25�29�34�40N)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�)r-ZGetFontr��list�tkFontZfamilies�sortrNr�r r�r��index�see�
select_set�
select_anchorZactivater�r��SetMenur��set_samples)	rQZconfigured_fontr�r�r�Zfonts�fontZlc_fontsZcurrent_font_indexrTrTrUr�Ls.

zFontPage.load_font_cfgcGsZ|jj�}tjddd|�|jj�}tjddd|�|jj�}tjddd|�|j�dS)z�Store changes to font attributes.

        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.
        r�r�rz	font-sizez	font-boldN)r�rxrr�
add_optionr�r�r)rQ�paramsr�rTrTrUr�os


zFontPage.var_changed_fontcCs0|jj|jjdkrtnt�}|jj|j��dS)z�Handle selecting a font from the list.

        Event can result from either mouse click or Up or Down key.
        Set font_name and example displays to selection.
        Z
KeyReleaseN)	rNrxr�r�rrr�r�r�)rQr�rrTrTrUr�~szFontPage.on_fontlist_selectNcCsH|jj�}|jj�rtjntj}||jj�|f}||jd<||jd<dS)z�Update update both screen samples with the font settings.

        Called on font initialization and change events.
        Accesses font_name, font_size, and font_bold Variables.
        Updates font_sample and highlight page highlight_sample.
        rN)	r�rxr�r�ZBOLDZNORMALr�rwr�)rQr�r�Zfont_weightZnew_fontrTrTrUr�s


zFontPage.set_samplescCs$tjdddddd�}|jj|�dS)z�Load current configuration settings for the tab options.

        Attributes updated:
            space_num: Set to value from idleConf.
        r�r�z
num-spaces�r�)r�r�N)r-�	GetOptionr�r�)rQr�rTrTrUr��szFontPage.load_tab_cfgcGs|jj�}tjddd|�dS)z!Store change to indentation size.r�r�z
num-spacesN)r�rxrrr)rQrr�rTrTrU�var_changed_space_num�s
zFontPage.var_changed_space_num)N)r�r�r�rFr�r�r�r�rr�r
r�rTrT)r{rUr^�sm#


r^cs�eZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Z�ZS)+r\cs2t�j|�|j|_t|�|_|j�|j�dS)N)rzrFr��cdr+�style�create_page_highlight�load_theme_cfg)rQr�)r{rTrUrF�s

zHighPage.__init__c
$s�dsdtdudvdwdxdydzd{d|d}d~dd�d�d��_tjt���j��_tjt���j��_t���_	tjt���j
��_tjt���j��_
tjt���j��_t�d td!d"�}t�d td#d"�}t|td$d�d(d)d*td+td,�
}�_|jd-d.d/��|jd0d1d/��d�}x$|D]}|jt|d+|d$��qWx8�jD].}|f�fdLdM�	}|j�j|d+dN|��q(WdO|dP<�jjdQd$dRdS�t|dQdT��_t|�}t�jdU�j dV��_!t"�j�jdWd+dX��_#t$|�j	d$dY�j%dZ��_&t$|�j	d+d[�j%dZ��_'�j	j(d$�t|d\�j)dV��_*t+|d]d^�}	t$|�j
d$�j,d_d`��_-t$|�j
d+�j,dad`��_.t"|�jdWdWdb��_/t"|�jdWdWdb��_0t|dc�j1dV��_2t+|d dd��_3|j4t5dedet6t7df�|j4t8dedet9dg��jj4t8dedet6t9df�|j4t8ded+dh��jj4t8dedet6t7df��j!j4t8t6t9didjdk��j#j4t8t6t9didldk��j&j4t5t:dm��j'j4t;t<dm��j*j4t=t9dededn�|	j4t8t<dededo��j-j4t8t<dedp��j.j4t8t<ded do��j/j4t8t9dededn��j0j4t8t9t<dededq��j2j4t8t9dededn��j3j4t8t9dedr�dWS)�a�Return frame of widgets for Highlighting tab.

        Enable users to provisionally change foreground and background
        colors applied to textual tags.  Color mappings are stored in
        complete listings called themes.  Built-in themes in
        idlelib/config-highlight.def are fixed as far as the dialog is
        concerned. Any theme can be used as the base for a new custom
        theme, stored in .idlerc/config-highlight.cfg.

        Function load_theme_cfg() initializes tk variables and theme
        lists and calls paint_theme_sample() and set_highlight_target()
        for the current theme.  Radiobuttons builtin_theme_on and
        custom_theme_on toggle var theme_source, which controls if the
        current set of colors are from a builtin or custom theme.
        DynOptionMenus builtinlist and customlist contain lists of the
        builtin and custom themes, respectively, and the current item
        from each list is stored in vars builtin_name and custom_name.

        Function paint_theme_sample() applies the colors from the theme
        to the tags in text widget highlight_sample and then invokes
        set_color_sample().  Function set_highlight_target() sets the state
        of the radiobuttons fg_on and bg_on based on the tag and it also
        invokes set_color_sample().

        Function set_color_sample() sets the background color for the frame
        holding the color selector.  This provides a larger visual of the
        color for the current tag and plane (foreground/background).

        Note: set_color_sample() is called from many places and is often
        called more than once when a change is made.  It is invoked when
        foreground or background is selected (radiobuttons), from
        paint_theme_sample() (theme is changed or load_cfg is called), and
        from set_highlight_target() (target tag is changed or load_cfg called).

        Button delete_custom invokes delete_custom() to delete
        a custom theme from idleConf.userCfg['highlight'] and changes.
        Button save_custom invokes save_as_new_theme() which calls
        get_new_theme_name() and create_new() to save a custom theme
        and its colors to idleConf.userCfg['highlight'].

        Radiobuttons fg_on and bg_on toggle var fg_bg_toggle to control
        if the current selected color for a tag is for the foreground or
        background.

        DynOptionMenu targetlist contains a readable description of the
        tags applied to Python source within IDLE.  Selecting one of the
        tags from this list populates highlight_target, which has a callback
        function set_highlight_target().

        Text widget highlight_sample displays a block of text (which is
        mock Python code) in which is embedded the defined tags and reflects
        the color attributes of the current theme and changes for those tags.
        Mouse button 1 allows for selection of a tag and updates
        highlight_target with that tag value.

        Note: The font in highlight_sample is set through the config in
        the fonts tab.

        In other words, a tag can be selected either from targetlist or
        by clicking on the sample text within highlight_sample.  The
        plane (foreground/background) is selected via the radiobutton.
        Together, these two (tag and plane) control what color is
        shown in set_color_sample() for the current theme.  Button set_color
        invokes get_color() which displays a ColorChooser to change the
        color for the selected tag/plane.  If a new color is picked,
        it will be saved to changes and the highlight_sample and
        frame background will be updated.

        Tk Variables:
            color: Color of selected target.
            builtin_name: Menu variable for built-in theme.
            custom_name: Menu variable for custom theme.
            fg_bg_toggle: Toggle for foreground/background color.
                Note: this has no callback.
            theme_source: Selector for built-in or custom theme.
            highlight_target: Menu variable for the highlight tag target.

        Instance Data Attributes:
            theme_elements: Dictionary of tags for text highlighting.
                The key is the display name and the value is a tuple of
                (tag name, display sort order).

        Methods [attachment]:
            load_theme_cfg: Load current highlight colors.
            get_color: Invoke colorchooser [button_set_color].
            set_color_sample_binding: Call set_color_sample [fg_bg_toggle].
            set_highlight_target: set fg_bg_toggle, set_color_sample().
            set_color_sample: Set frame background to target.
            on_new_color_set: Set new color and add option.
            paint_theme_sample: Recolor sample.
            get_new_theme_name: Get from popup.
            create_new: Combine theme with changes and save.
            save_as_new_theme: Save [button_save_custom].
            set_theme_type: Command for [theme_source].
            delete_custom: Activate default [button_delete_custom].
            save_new: Save to userCfg['theme'] (is function).

        Widgets of highlights page frame:  (*) widgets bound to self
            frame_custom: LabelFrame
                (*)highlight_sample: Text
                (*)frame_color_set: Frame
                    (*)button_set_color: Button
                    (*)targetlist: DynOptionMenu - highlight_target
                frame_fg_bg_toggle: Frame
                    (*)fg_on: Radiobutton - fg_bg_toggle
                    (*)bg_on: Radiobutton - fg_bg_toggle
                (*)button_save_custom: Button
            frame_theme: LabelFrame
                theme_type_title: Label
                (*)builtin_theme_on: Radiobutton - theme_source
                (*)custom_theme_on: Radiobutton - theme_source
                (*)builtinlist: DynOptionMenu - builtin_name
                (*)customlist: DynOptionMenu - custom_name
                (*)button_delete_custom: Button
                (*)theme_message: Label
        �normal�00�context�01�keyword�02�
definition�03�builtin�04�comment�05�string�06�hilite�07�hit�08�cursor�09�breakr��consoler��errorr��stdoutr��stderrr�)zNormal TextzCode ContextzPython KeywordszPython DefinitionszPython BuiltinszPython CommentszPython Stringsz
Selected Textz
Found Text�CursorzEditor BreakpointzShell Normal TextzShell Error TextzShell Stdout TextzShell Stderr Textrhz Custom Highlighting )r?r�rVz Highlighting Theme r��courier�r;Zhand2��
r)	r�r?rr!rErDrj�highlightthicknessZwrapz<Double-Button-1>cSsdS)Nr#rT)�erTrTrU�<lambda>Lsz0HighPage.create_page_highlight.<locals>.<lambda>z<B1-Motion>cSsdS)Nr#rT)r.rTrTrUr/Ms�
�#you can click here�#to choose items�code context section�

�def� �func�(param):
  �"""string"""�

  var0 = �'string'�

  var1 = �
'selected'�

  var2 = �'found'�

  var3 = r��(�None�)
�  breakpoint("line")� error �cursor |�
 �shellcs�jj|�dS)N)�highlight_targetr�)r��elem)rQrTrU�temdsz+HighPage.create_page_highlight.<locals>.temz<ButtonPress-1>�disabled�statezframe_color_set.TFrameZsolid)r?r�)rzChoose Color for :)rVriN)r-Z
Foreground)r�r�rVriZ
BackgroundzSave as New Custom Themez	Select : )rVza Built-in Theme)r�r�rirVza Custom Theme)rizDelete Custom Theme)r?r>)rXrkr�rYrZ)rXrkr�rZ)rXrkr�r�r)rXrYrZrkr�rg)rXr�)rXrZrkr�)rXr�rkr�)rXr�rk)rXrZr�rkr�)rXrZr�)rr)rr)rr)rr)rr)rr)rr)rr)rr )r!r")r#r�)r$r�)r%r�)r&r�)r'r�)r)r*r;�r0r�r1r�r0r�r2r�r0r�r3r�r4r�r5r�r6r�r7r�r8r�r9r�r:r�r;r�r<r�r=r�r>r�r?r�r@r�r�r�rAr�rBr�rCr�rDr#�r4r�rEr%�r6r�rFr!�rGr�rHr$�r6r�r&r&�r6r�r'r'�r4r)#rNrOrPrQrRrSrTrUrVrWrXrYrZr[r\r]r^r_r`rarbrcrdrerfrgrhrirjrkrlrmrnrorp)>�theme_elementsrOrbr�var_changed_builtin_name�builtin_name�var_changed_custom_name�custom_namer�fg_bg_toggle�var_changed_color�color�var_changed_theme_source�theme_source�var_changed_highlight_targetrIr&rrrrrr�r�r�r Ztag_bindrrIr$�frame_color_setr!�	get_colorZbutton_set_colorr0�
targetlistr)�set_color_sample_binding�fg_on�bg_onr��save_as_new_themeZbutton_save_customr%�set_theme_typeZbuiltin_theme_on�custom_theme_on�builtinlist�
customlist�
delete_custom�button_delete_custom�
theme_messagercrr
rrrrrrr
)
rQ�frame_customZframe_themerVZ
text_and_tagsZtexttag�elementrKZframe_fg_bg_toggleZtheme_type_titlerT)rQrUr
�s�v





zHighPage.create_page_highlightcs.�jjtjdddddd��tj�}�jj�r�tjdd�}|j��jj	||�tjdd�}|j�|s��j
jd��jjd
�qވj
j	||d�nHtjdd�}|j��j
j	||�tjdd�}|j��jj	||d��j�t�jj��}|j�fdd
�d��jj	||d��j��j�dS)a�Load current configuration settings for the theme options.

        Based on the theme_source toggle, the theme is set as
        either builtin or custom and the initial widget values
        reflect the current settings from idleConf.

        Attributes updated:
            theme_source: Set from idleConf.
            builtinlist: List of default themes from idleConf.
            customlist: List of custom themes from idleConf.
            custom_theme_on: Disabled if there are no custom themes.
            custom_theme: Message with additional information.
            targetlist: Create menu from self.theme_elements.

        Methods:
            set_theme_type
            paint_theme_sample
            set_highlight_target
        r��Themer�r�r�)r�r��	highlight�userrLz- no custom themes -rcs�j|dS)Nr�)rq)rR)rQrTrUr/�sz)HighPage.load_theme_cfg.<locals>.<lambda>)r�N)rL)rzr�r-r	ZCurrentThemerx�GetSectionListr�r�rr�rMrur�r�r�rqrr~�paint_theme_sample�set_highlight_target)rQ�current_option�	item_listZtheme_namesrT)rQrUr�s2

zHighPage.load_theme_cfgcGs�d}|jj�}||krXtjddd�|kr<tjddd|d�tjddd|�d|jd	<n*tjddd|�tjdddd
�d
|jd	<|j�dS)
z�Process new builtin theme selection.

        Add the changed theme's name to the changed_items and recreate
        the sample with the values from the selected theme.
        �IDLE Classic�IDLE Newr�r�r�r�name2zNew theme, see HelprVr;N)r�r�)rsrxr-r	rrrr�r�)rQrZ
old_themesr�rTrTrUrr�s

z!HighPage.var_changed_builtin_namecGs.|jj�}|dkr*tjddd|�|j�dS)z�Process new custom theme selection.

        If a new custom theme is selected, add the name to the
        changed_items and apply the theme to the sample.
        z- no custom themes -r�r�r�N)rurxrrrr�)rQrr�rTrTrUrt�s
z HighPage.var_changed_custom_namecGs4|jj�}tjddd|�|r(|j�n|j�dS)z�Process toggle between builtin and custom theme.

        Update the default toggle value and apply the newly
        selected theme type.
        r�r�r�N)rzrxrrrrrrt)rQrr�rTrTrUry�s


z!HighPage.var_changed_theme_sourcecGs|j�dS)zProcess change to color choice.N)�on_new_color_set)rQrrTrTrUrwszHighPage.var_changed_colorcGs|j�dS)z5Process selection of new target tag for highlighting.N)r�)rQrrTrTrUr{sz%HighPage.var_changed_highlight_targetcCs\|jj�r,d|jd<d|jd<|jjd�n,d|jd<|jjd�d|jd<|jjd�dS)	a�Set available screen options based on builtin or custom theme.

        Attributes accessed:
            theme_source

        Attributes updated:
            builtinlist
            customlist
            button_delete_custom
            custom_theme_on

        Called from:
            handler for builtin_theme_on and custom_theme_on
            delete_custom
            create_new
            load_theme_cfg
        rrMrL�	!disabledN)rL)r�)r�)rzrxr�r�r�rMr�)rQrTrTrUr�s




zHighPage.set_theme_typecCs�|jj�}|jj|jdd�}tj|d||d�\}}|r�||kr�|jj�rzd}|j|�}|sbdS|j	|�|j
j|�n|j
j|�dS)a�Handle button to select a new color for the target tag.

        If a new color is selected while using a builtin theme, a
        name must be supplied to create a custom theme.

        Attributes accessed:
            highlight_target
            frame_color_set
            theme_source

        Attributes updated:
            color

        Methods:
            get_new_theme_name
            create_new
        r�
backgroundzPick new color for : )rGrJZinitialcolorz_Your changes will be saved as a new Custom Theme. Enter a name for your new Custom Theme below.N)rIrxr�lookupr|�tkColorChooserZaskcolorrz�get_new_theme_name�
create_newrxr�)rQ�targetZ
prev_colorZ	rgbTupletZcolor_string�message�	new_themerTrTrUr}(s



zHighPage.get_colorcCs~|jj�}|jjd|d�|jj�r(dnd}|j|jj�d}|jj|f||i�|j	j�}|d|}t
jd|||�dS)	z4Display sample of new color selection on the dialog.zframe_color_set.TFrame)r��
foregroundr�r�-r�N)rxrxrrIrvrqrIr��
tag_configrurrr)rQZ	new_color�planeZsample_element�themeZ
theme_elementrTrTrUr�Ns

zHighPage.on_new_color_setcCs,tjdd�tjdd�}t|d||�j}|S)z*Return name of new theme from query popup.r�r�r�zNew Custom Theme)r-r�r2�result)rQr��
used_namesr�rTrTrUr�Ys

zHighPage.get_new_theme_namecCs|jd�}|r|j|�dS)z�Prompt for new theme name and create the theme.

        Methods:
            get_new_theme_name
            create_new
        zNew Theme Name:N)r�r�)rQ�new_theme_namerTrTrUr�as
zHighPage.save_as_new_themecCs�|jj�rd}|jj�}nd}|jj�}tj||�}|tdkrftd|}x|D]}||||<qRW|j||�tjdd�}|j	�|j
j||�|jjd�|j
�dS)a�Create a new custom theme with the given name.

        Create the new theme based on the previously active theme
        with the current changes applied.  Once it is saved, then
        activate the new theme.

        Attributes accessed:
            builtin_name
            custom_name

        Attributes updated:
            customlist
            theme_source

        Method:
            save_new
            set_theme_type
        r�r�r�rN)rzrxrsrur-ZGetThemeDictrr�save_newr�r�r�rr�r�)rQr�Z
theme_type�
theme_namer�Z
theme_changesr�Zcustom_theme_listrTrTrUr�ls 


zHighPage.create_newcCsd|jj�dkr4|jjd�|jjd�|jjd�n$|jjd�|jjd	�|jjd�|j�dS)
ahSet fg/bg toggle and color based on highlight tag target.

        Instance variables accessed:
            highlight_target

        Attributes updated:
            fg_on
            bg_on
            fg_bg_toggle

        Methods:
            set_color_sample

        Called from:
            var_changed_highlight_target
            load_theme_cfg
        r(rLr��	!disabledN)rL)rL)r�)r�)rIrxr�rMr�rvr��set_color_sample)rQrTrTrUr��szHighPage.set_highlight_targetcGs|j�dS)zrChange color sample based on foreground/background toggle.

        Methods:
            set_color_sample
        N)r�)rQ�argsrTrTrUr�sz!HighPage.set_color_sample_bindingcCsH|j|jj�d}|jj�r"dnd}|jj||�}|jjd|d�dS)aSet the color of the frame background to reflect the selected target.

        Instance variables accessed:
            theme_elements
            highlight_target
            fg_bg_toggle
            highlight_sample

        Attributes updated:
            frame_color_set
        rr�r�zframe_color_set.TFrame)r�N)rqrIrxrvr�Ztag_cgetrrI)rQ�tagr�rxrTrTrUr��s
zHighPage.set_color_samplecCs�|jj�r|jj�}n
|jj�}x�|jD]�}|j|d}tj||�}|dkrbtj|ddd�|d<|tdkr�td|}|d|kr�||d|d	<|d
|kr�||d
|d<|jj	|f|�q(W|j
�dS)a�Apply the theme colors to each element tag in the sample text.

        Instance attributes accessed:
            theme_elements
            theme_source
            builtin_name
            custom_name

        Attributes updated:
            highlight_sample: Set the tag elements to the theme.

        Methods:
            set_color_sample

        Called from:
            var_changed_builtin_name
            var_changed_custom_name
            load_theme_cfg
        rr!rZbg)ZfgBgr�r�z-foregroundr�z-backgroundN)rzrxrsrurqr-ZGetHighlightrrr�r�r�)rQr�Z
element_titler�ZcolorsZ
theme_dictrTrTrUr��s"

zHighPage.paint_theme_samplecCsNtjdj|�s tjdj|�x(|D] }||}tjdj|||�q&WdS)z�Save a newly created theme to idleConf.

        theme_name - string, the name of the new theme
        theme - dictionary containing the new theme
        r�N)r-r��has_section�add_sectionr�)rQr�r�r�r�rTrTrUr��s

zHighPage.save_newcOstj||�S)N)r,�askyesno)rQr��kwargsrTrTrUr��szHighPage.askyesnocCs�|jj�}d}|jd|||d�s&dS|jj�tjd|�tjdd�}|j	�|sp|j
jd�|jj
|d�n|jj
||d	�|jjtjd
jdd��|jjtjd
jdd
��tj�|jj�|jj�|j�dS)a!Handle event to delete custom theme.

        The current theme is deactivated and the default theme is
        activated.  The custom theme is permanently removed from
        the config file.

        Attributes accessed:
            custom_name

        Attributes updated:
            custom_theme_on
            customlist
            theme_source
            builtin_name

        Methods:
            deactivate_current_config
            save_all_changed_extensions
            activate_config_changes
            set_theme_type
        z.Are you sure you wish to delete the theme %r ?zDelete Theme)rGNr�r�rLz- no custom themes -rr�r�r�r�)rL)rurxr�rrqrr�delete_sectionr-r�r�r�rMr�rrzr�r�r�rsrsrtrur�)rQr��delmsgr�rTrTrUr�s&



zHighPage.delete_custom)r�r�r�rFr
rrrrtryrwr{r�r}r�r�r�r�r�rr�r�r�r�r�r�rTrT)r{rUr\�s,w4
&((r\cs�eZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zedd��Zdd �Zd!d"�Z�ZS)#r_cs(t�j|�|j|_|j�|j�dS)N)rzrFr�r�create_page_keys�load_key_cfg)rQr�)r{rTrUrF4szKeysPage.__init__cs"tjt|�|j�|_tjt|�|j�|_tjt|�|j�|_	tjt|�|j
�|_t|dt
dd�}t|dt
dd��t|�}t|dd�}t|�}t|td�}t|ttd�|_|jjd	|j�|jj|d
<|jj|d
<|j|jd<|j|jd<t|d
|jdd�|_�fdd�td�D�}t|d|j	d|jdd�|_ t|d|j	d|jdd�|_!t"|d|jddd�|_#t"|d|jddd�|_$t|dd|j%d�|_&t|dd|j'd�|_(t|ddd�|_)|j*t+ddt,t-d��j*t+ddt-d�|jj*t+t.ddd �|j*t/ddt,t-d�|j0ddd!�|j1ddd!�|j2dddt3d"�|jj2ddt4d#�|j2ddt5d#�|j2ddt6d#�|j j2ddt3t5d#�|j!j2ddt3t5d#�|j#j2ddt4d#�|j$j2ddt4d#�|j)j2ddt4ddd$�|j&j*t/t.d%dd&�|j(j*t/t.d%dd&�|dj*t7t-d%d'�|dj*t7t.d%dd(�dS))a�Return frame of widgets for Keys tab.

        Enable users to provisionally change both individual and sets of
        keybindings (shortcut keys). Except for features implemented as
        extensions, keybindings are stored in complete sets called
        keysets. Built-in keysets in idlelib/config-keys.def are fixed
        as far as the dialog is concerned. Any keyset can be used as the
        base for a new custom keyset, stored in .idlerc/config-keys.cfg.

        Function load_key_cfg() initializes tk variables and keyset
        lists and calls load_keys_list for the current keyset.
        Radiobuttons builtin_keyset_on and custom_keyset_on toggle var
        keyset_source, which controls if the current set of keybindings
        are from a builtin or custom keyset. DynOptionMenus builtinlist
        and customlist contain lists of the builtin and custom keysets,
        respectively, and the current item from each list is stored in
        vars builtin_name and custom_name.

        Button delete_custom_keys invokes delete_custom_keys() to delete
        a custom keyset from idleConf.userCfg['keys'] and changes.  Button
        save_custom_keys invokes save_as_new_key_set() which calls
        get_new_keys_name() and create_new_key_set() to save a custom keyset
        and its keybindings to idleConf.userCfg['keys'].

        Listbox bindingslist contains all of the keybindings for the
        selected keyset.  The keybindings are loaded in load_keys_list()
        and are pairs of (event, [keys]) where keys can be a list
        of one or more key combinations to bind to the same event.
        Mouse button 1 click invokes on_bindingslist_select(), which
        allows button_new_keys to be clicked.

        So, an item is selected in listbindings, which activates
        button_new_keys, and clicking button_new_keys calls function
        get_new_keys().  Function get_new_keys() gets the key mappings from the
        current keyset for the binding event item that was selected.  The
        function then displays another dialog, GetKeysDialog, with the
        selected binding event and current keys and allows new key sequences
        to be entered for that binding event.  If the keys aren't
        changed, nothing happens.  If the keys are changed and the keyset
        is a builtin, function get_new_keys_name() will be called
        for input of a custom keyset name.  If no name is given, then the
        change to the keybinding will abort and no updates will be made.  If
        a custom name is entered in the prompt or if the current keyset was
        already custom (and thus didn't require a prompt), then
        idleConf.userCfg['keys'] is updated in function create_new_key_set()
        with the change to the event binding.  The item listing in bindingslist
        is updated with the new keys.  Var keybinding is also set which invokes
        the callback function, var_changed_keybinding, to add the change to
        the 'keys' or 'extensions' changes tracker based on the binding type.

        Tk Variables:
            keybinding: Action/key bindings.

        Methods:
            load_keys_list: Reload active set.
            create_new_key_set: Combine active keyset and changes.
            set_keys_type: Command for keyset_source.
            save_new_key_set: Save to idleConf.userCfg['keys'] (is function).
            deactivate_current_config: Remove keys bindings in editors.

        Widgets for KeysPage(frame):  (*) widgets bound to self
            frame_key_sets: LabelFrame
                frames[0]: Frame
                    (*)builtin_keyset_on: Radiobutton - var keyset_source
                    (*)custom_keyset_on: Radiobutton - var keyset_source
                    (*)builtinlist: DynOptionMenu - var builtin_name,
                            func keybinding_selected
                    (*)customlist: DynOptionMenu - var custom_name,
                            func keybinding_selected
                    (*)keys_message: Label
                frames[1]: Frame
                    (*)button_delete_custom_keys: Button - delete_custom_keys
                    (*)button_save_custom_keys: Button -  save_as_new_key_set
            frame_custom: LabelFrame
                frame_target: Frame
                    target_title: Label
                    scroll_target_y: Scrollbar
                    scroll_target_x: Scrollbar
                    (*)bindingslist: ListBox - on_bindingslist_select
                    (*)button_new_keys: Button - get_new_keys & ..._name
        rhz Custom Key Bindings )r?r�rVz	 Key Set zAction - Key(s))rV)r�)rjr�z<ButtonRelease-1>rir�ZxscrollcommandzGet New Keys for SelectionrL)rVrirMcsg|]}t�ddd��qS)rhr)rer?)r$)r��i)�frame_key_setsrTrUr��sz-KeysPage.create_page_keys.<locals>.<listcomp>rr�zUse a Built-in Key Set)r�r�rirVzUse a Custom Key SetN)rizDelete Custom Key Set)rVrizSave as New Custom Key Set)r?r>)rXrkr�rYrZ)rXrkr�rZ)rXrZrkr�)r�)r�r�Z
columnspanr�)r�r�r�)r�r�r�rkr�T)rXrZrYrk)rXrZrY)rXrZrYr�)8rOrbrrrrsrtrur�var_changed_keyset_source�
keyset_source�var_changed_keybinding�
keybindingr&rr$r%r*rrr�bindingslistr��on_bindingslist_selectr�Zxviewr�r!�get_new_keys�button_new_keys�ranger)�
set_keys_typeZbuiltin_keyset_on�custom_keyset_onr0r�r��delete_custom_keys�button_delete_custom_keys�save_as_new_key_setZbutton_save_custom_keys�keys_messagercr
r
rrrr�r�r�rrrrr)rQr�Zframe_targetZtarget_titleZscroll_target_yZscroll_target_xZframesrT)r�rUr�:s�R
zKeysPage.create_page_keyscCs�|jjtjdddddd��tj�}|jj�r�tjdd�}|j�|jj	||�tjdd�}|j�|s�|j
jd
�|jjd
�q�|j
j	||d�nHtjdd�}|j�|j
j	||�tjdd�}|j�|jj	|tj��|j�tj�}|j|�dS)z?Load current configuration settings for the keybinding options.r��Keysr�r�r�)r�r�rr�rLz- no custom keys -rN)rL)r�r�r-r	ZCurrentKeysrxr�r�r�rr�rMrur��default_keysr��load_keys_list)rQr�r��keyset_namerTrTrUr��s,

zKeysPage.load_key_cfgcGs�d}|jj�}||krXtjddd�|kr<tjddd|d�tjddd	|�d
|jd<n*tjddd|�tjddd	d�d|jd<|j|�d
S)z%Process selection of builtin key set.�IDLE Classic Windows�IDLE Classic Unix�IDLE Classic Mac�IDLE Classic OSXr�r�r�rr�zNew key set, see HelprVr;N)r�r�r�r�)rsrxr-r	rrrr�r�)rQrZold_keysr�rTrTrUrr�s

z!KeysPage.var_changed_builtin_namecGs0|jj�}|dkr,tjddd|�|j|�dS)z$Process selection of custom key set.z- no custom keys -r�r�r�N)rurxrrrr�)rQrr�rTrTrUrt
s
z KeysPage.var_changed_custom_namecGs4|jj�}tjddd|�|r(|j�n|j�dS)z:Process toggle between builtin key set and custom key set.r�r�r�N)r�rxrrrrrrt)rQrr�rTrTrUr�s


z"KeysPage.var_changed_keyset_sourcecGsj|jj�}|jj�}|jjt�j�d}tj|�rDtj	d|||�n"tj
|�}|d}tj	d|||�dS)zStore change to a keybinding.rrZ_cfgBindingsr�N)r�rxrur�r�splitr-Z
IsCoreBindingrrrZGetExtnNameForEvent)rQrr�Zkey_setr�r�Zext_keybind_sectionrTrTrUr�s



zKeysPage.var_changed_keybindingcCs\|jj�r,d|jd<d|jd<|jjd�n,d|jd<|jjd�d|jd<|jjd�dS)	z@Set available screen options based on builtin or custom key set.rrMrL�	!disabledN)rL)r�)r�)r�rxr�r�r�rMr�)rQrTrTrUr�)s




zKeysPage.set_keys_typecCsJ|jjt�}|jj|�}|j�d}|jj�r:|jj�}n
|jj�}tj	�}|t
dkr�t
d|}x|D]}||j�||<qjWt|j��}t
|d||�j}	|	�r.|jj�r�d}
|j|
�}|s�|jj|�|jj|�dS|j|�|jj|�|jj||d|	�|jj|�|jj|�|jj|	�n|jj|�|jj|�dS)a^Handle event to change key binding for selected line.

        A selection of a key/binding in the list of current
        bindings pops up a dialog to enter a new binding.  If
        the current key set is builtin and a binding has
        changed, then a name for a custom key set needs to be
        entered for the change to be applied.
        rrzGet New KeyszcYour changes will be saved as a new Custom Key Set. Enter a name for your new Custom Key Set below.Nz - )r�r�rrxr�r�rsrur-ZGetCurrentKeySetrrr��valuesr/r��get_new_keys_namerr�create_new_key_set�deleter�r�r�)rQ�
list_index�binding�	bind_nameZcurrent_key_set_nameZcurrent_bindings�key_set_changesr�Zcurrent_key_sequences�new_keysr��
new_keysetrTrTrUr�5s<	





zKeysPage.get_new_keyscCs,tjdd�tjdd�}t|d||�j}|S)z)Return new key set name from query popup.r�rr�zNew Custom Key Set)r-r�r2r�)rQr�r�r�rTrTrUr�as

zKeysPage.get_new_keys_namecCs|jd�}|r|j|�dS)z@Prompt for name of new key set and save changes using that name.zNew Key Set Name:N)r�r�)rQZ
new_keys_namerTrTrUr�is
zKeysPage.save_as_new_key_setcCs|jjd�dS)z6Activate button to assign new keys to selected action.�	!disabledN)r�)r�rM)rQr�rTrTrUr�oszKeysPage.on_bindingslist_selectc
Cs�|jj�r|jj�}n
|jj�}tj|�}i}x.|D]&}|dd�}dj||�}|||<q4W|tdkr�td|}x|D]}||||<q|W|j||�tj	dd�}	|	j
�|jj|	|�|jj
d�|j�dS)z�Create a new custom key set with the given name.

        Copy the bindings/keys from the previously active keyset
        to the new keyset and activate the new custom keyset.
        rhr6rr�rN���)r�rxrsrur-ZGetCoreKeys�joinrr�save_new_key_setr�r�r�rr�r�)
rQZnew_key_set_nameZprev_key_set_nameZ	prev_keysr�r�Z
event_namer�r�Zcustom_key_listrTrTrUr�ss&




zKeysPage.create_new_key_setcCs�d}|jj�rd}|jjt�}tj|�}t|j��}|j�|jj	dt
�xh|D]`}dj||�}|dd	�}|tdkr�|td|kr�td||}|jj
t
|d|�qPW|r�|jj|�|jj|�|jj|�dS)
z�Reload the list of action/key binding pairs for the active key set.

        An action/key binding can be selected to change the key binding.
        FTrr6rhrz - Nr�)r�r�r�rr-Z	GetKeySetr�rr�r�r r�rrr�rrr)rQr�Zreselectr��keysetZ
bind_namesr�r�rTrTrUr��s&


zKeysPage.load_keys_listcCsNtjdj|�s tjdj|�x(|D] }||}tjdj|||�q&WdS)aQSave a newly created core key set.

        Add keyset to idleConf.userCfg['keys'], not to disk.
        If the keyset doesn't exist, it is created.  The
        binding/keys are taken from the keyset argument.

        keyset_name - string, the name of the new key set
        keyset - dictionary containing the new keybindings
        rN)r-r�r�r�r�)r�r�r�r�rTrTrUr��s

zKeysPage.save_new_key_setcOstj||�S)N)r,r�)rQr�r�rTrTrUr��szKeysPage.askyesnocCs�|jj�}d}|jd|||d�s&dS|jj�tjd|�tjdd�}|j	�|sp|j
jd�|jj
|d�n|jj
||d	�|jjtjd
jdd��|jjtjd
jdd
�p�tj��tj�|jj�|jj�|j�dS)z�Handle event to delete a custom key set.

        Applying the delete deactivates the current configuration and
        reverts to the default.  The custom key set is permanently
        deleted from the config file.
        z0Are you sure you wish to delete the key set %r ?zDelete Key Set)rGNrr�rLz- no custom keys -rr�r�r�r�)rL)rurxr�rrqrrr�r-r�r�r�rMr�rr�r�r�r�rsr�rsrtrur�)rQr�r�r�rTrTrUr��s*





zKeysPage.delete_custom_keys)r�r�r�rFr�r�rrrtr�r�r�r�r�r�r�r�r��staticmethodr�r�r�r�rTrT)r{rUr_2s$!	,r_cs\eZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Z�ZS)r`cs t�j|�|j�|j�dS)N)rzrF�create_page_general�load_general_cfg)rQr�)r{rTrUrF�szGenPage.__init__cCs�tjt|�dR�|_tjt|�dS�|_tjt|�dT�|_tjt|�dU�|_tjt|�dV�|_tjt|�dW�|_	tjt
|�dX�|_tjt|�dY�|_tjt|�dZ�|_
tjt|�d[�|_tjt|�d\�|_t|dtdd�}t|dtdd�}t|dtdd�}t|dtdd�}t|dd�}t|dd�}t||jdd d!�|_t||jdd"d!�|_t|dd�}t|d#d�}t|d$d�}	t||jd%d&�|_t|d'd�}
t||jd%d&�|_t|dd�}t|d(d�}t|d)|jd*�|_t|dd�}
t|
d+d�}t|
|jd,d-d.d,�|_t|dd�}t|d/d�}t||j	d)d&�|_t|d0|jd1�|_t|dd�}t|d2d�}t||j
dd3d!�|_ t||j
dd4d!�|_!t|dd�}t|d5d�}t||jd6d&�|_"t|dd�}t|d7d�}t||jd%d&�|_#t|dd�}t|d8d�}t|d6|jd*�|_$t|�}t|�}t%|d9d:t&d;�|_'t(|�}|j'j)|d<<|j*|j'd=<|j'j+d>|j,�t-|d?d@dA|j.dB�|_/t-|dCdA|j0dD�|_1t-|dEd@dA|j2dB�|_3|j4t5d9d9t6t7dF�|j4t5d9d9t6t7dF�|j4t5d9d9t6t7dF�|j4t5d9d9t6t7dF�|j4t5d9dt8dG�|j4t9t:d9d9dH�|jj4t;t:d9d9dH�|jj4t;t:d9d9dH�|j4t5d9dt8dG�|j4t9t:d9d9dH�|jj4t;t<dId9dH�|
j4t;t<d9dJ�|jj4t;t<dId9dH�|	j4t;t<d9dJ�|j4t5d9dt8dG�|j4t9t:d9d9dH�|jj4t5dId9dK�|
j4t5d9dt8dG�|j4t9t:d9d9dH�|jj4t5dId9dK�|j4t5d9dt8dG�|j4t9t:d9dL�|jj4t;t<dMd9dH�|jj4t5t:dMd9dH�|j4t5d9dt8dG�|j4t9t:d9d9dH�|j!j4t;t:d9d9dH�|j j4t;t:d9d9dH�|j4t5d9dt8dG�|j4t9t:d9d9dH�|j"j4t5dId9dK�|j4t5d9dt8dG�|j4t9t:d9d9dH�|j#j4t5d9d9dK�|j4t5d9dt8dG�|j4t9t:d9d9dH�|j$j4t5d9d9dK�|j4t;d9d9t=dG�|j4t5d9d9t6t7dF�|j4t;t:t=dN�|j'j4t9t<t6t7dO�|j/j4t5t:d9dJ�|j1j4t5t:dP�|j3j4t5t:d9dJ�dQS)]aLReturn frame of widgets for General tab.

        Enable users to provisionally change general options. Function
        load_general_cfg intializes tk variables and helplist using
        idleConf.  Radiobuttons startup_shell_on and startup_editor_on
        set var startup_edit. Radiobuttons save_ask_on and save_auto_on
        set var autosave. Entry boxes win_width_int and win_height_int
        set var win_width and win_height.  Setting var_name invokes the
        default callback that adds option to changes.

        Helplist: load_general_cfg loads list user_helplist with
        name, position pairs and copies names to listbox helplist.
        Clicking a name invokes help_source selected. Clicking
        button_helplist_name invokes helplist_item_name, which also
        changes user_helplist.  These functions all call
        set_add_delete_state. All but load call update_help_changes to
        rewrite changes['main']['HelpFiles'].

        Widgets for GenPage(Frame):  (*) widgets bound to self
            frame_window: LabelFrame
                frame_run: Frame
                    startup_title: Label
                    (*)startup_editor_on: Radiobutton - startup_edit
                    (*)startup_shell_on: Radiobutton - startup_edit
                frame_win_size: Frame
                    win_size_title: Label
                    win_width_title: Label
                    (*)win_width_int: Entry - win_width
                    win_height_title: Label
                    (*)win_height_int: Entry - win_height
                frame_autocomplete: Frame
                    auto_wait_title: Label
                    (*)auto_wait_int: Entry - autocomplete_wait
                frame_paren1: Frame
                    paren_style_title: Label
                    (*)paren_style_type: OptionMenu - paren_style
                frame_paren2: Frame
                    paren_time_title: Label
                    (*)paren_flash_time: Entry - flash_delay
                    (*)bell_on: Checkbutton - paren_bell
            frame_editor: LabelFrame
                frame_save: Frame
                    run_save_title: Label
                    (*)save_ask_on: Radiobutton - autosave
                    (*)save_auto_on: Radiobutton - autosave
                frame_format: Frame
                    format_width_title: Label
                    (*)format_width_int: Entry - format_width
                frame_context: Frame
                    context_title: Label
                    (*)context_int: Entry - context_lines
            frame_shell: LabelFrame
                frame_auto_squeeze_min_lines: Frame
                    auto_squeeze_min_lines_title: Label
                    (*)auto_squeeze_min_lines_int: Entry - auto_squeeze_min_lines
            frame_help: LabelFrame
                frame_helplist: Frame
                    frame_helplist_buttons: Frame
                        (*)button_helplist_edit
                        (*)button_helplist_add
                        (*)button_helplist_remove
                    (*)helplist: ListBox
                    scroll_helplist: Scrollbar
        r��General�editor-on-startupr�rErDr�r5�	popupwaitr7r�flash-delay�bell�PyShell�auto-squeeze-min-lines�autosaver8�	max-widthr6�maxlinesrhz Window Preferences)r?r�rVz Editor Preferencesz Shell Preferencesz Additional Help Sources r)r?z
At Startup)rVr�zOpen Edit Window)r�r�rVzOpen Shell Windowz$Initial Window Size  (in characters)ZWidthrg)r�rEZHeightz%Completions Popup Wait (milliseconds)rf)rEr�zParen Match StyleZ
expression�openerZparensz;Time Match Displayed (milliseconds)
(0 is until next input)zBell on Mismatch)rVr�zAt Start of Run (F5)  zPrompt to Savez	No PromptzFormat Paragraph Max WidthrzMax Context Lines :zAuto-Squeeze Min. Lines:r>T)rDrjr�rir�z<ButtonRelease-1>ZEditrLr�)rVrMrEriZAdd)rVrEriZRemove)rXrkr�rYrZ)rXrkr�rZ)rXr�rkr�r�)rXr�r�)rXrkr�)rXr�rkr�)rXr�rZ)rXr�rYrZ)rXr�N)r�r�r�)r�r�rE)r�r�rD)r�r5r�)r�r7r)r�r7r�)r�r7r�)r�r�r�)r�r�r�)r�r8r�)r�r6r�)>rOrbr	�startup_editr�	win_width�
win_height�autocomplete_wait�paren_style�flash_delayr�
paren_bell�auto_squeeze_min_linesr��format_width�
context_linesr&rr$r%r)Zstartup_editor_onZstartup_shell_onr#Z
win_width_intZwin_height_intZ
auto_wait_intr'Zparen_style_typeZparen_flash_timer"Zbell_onZsave_ask_onZsave_auto_onZformat_width_intZcontext_intZauto_squeeze_min_lines_intrr�helplistr*r�r�r��help_source_selectedr!�helplist_item_edit�button_helplist_edit�helplist_item_addZbutton_helplist_add�helplist_item_remove�button_helplist_removercrr
rrrrrrr)rQZframe_windowZframe_editorZframe_shellZ
frame_helpZ	frame_runZ
startup_titleZframe_win_sizeZwin_size_titleZwin_width_titleZwin_height_titleZframe_autocompleteZauto_wait_titleZframe_paren1Zparen_style_titleZframe_paren2Zparen_time_titleZ
frame_saveZrun_save_titleZframe_formatZformat_width_titleZ
frame_contextZ
context_titleZframe_auto_squeeze_min_linesZauto_squeeze_min_lines_titleZframe_helplistZframe_helplist_buttonsZscroll_helplistrTrTrUr��s*B






zGenPage.create_page_generalcCs`|jjtjddddd��|jjtjddddd��|jjtjddd	dd��|jjtjd
dddd��|jjtjd
d
d��|jjtjd
d
ddd��|j	jtjd
d
d��|j
jtjdddddd��|jjtjd
dddd��|jjtjd
dddd��|j
jtjddddd��tj�|_|jjdd�x"|jD]}|jjt|d��q8W|j�dS)z<Load current configuration settings for the general options.r�r�zeditor-on-startupr�)r�r�rEr�rDr�r5r�r7rzflash-delayr�r�r)r�r�r8z	max-widthr6r�r�zauto-squeeze-min-linesrvN)r�r�r-r	r�r�r�r�r�r�r�r�r�r�ZGetAllExtraHelpSourcesList�
user_helplistr�r�r�r �set_add_delete_state)rQZ	help_itemrTrTrUr��s6











zGenPage.load_general_cfgcCs|j�dS)z+Handle event for selecting additional help.N)r)rQr�rTrTrUr�szGenPage.help_source_selectedcCsh|jj�dkr(|jjd�|jjd�n<|jj�rL|jjd�|jjd�n|jjd	�|jjd
�dS)zAToggle the state for the help list buttons based on list entries.r�rL�	!disabledN)rL)rL)r)r)rL)rL)r��sizer�rMr�r�)rQrTrTrUrs
zGenPage.set_add_delete_statecCs:t|d�j}|r6|jj|�|jjt|d�|j�dS)z�Handle add button for the help list.

        Query for name and location of new help sources and add
        them to the list.
        zNew Help SourcerN)r3r�rr�r�r�r �update_help_changes)rQ�help_sourcerTrTrUr�s
zGenPage.helplist_item_addcCsx|jjt�}|j|}t|d|d|dd�j}|rt||krt||j|<|jj|�|jj||d�|j�|j	�dS)z�Handle edit button for the help list.

        Query with existing help source information and update
        config if the values are changed.
        zEdit Help Sourcerr�)Zmenuitem�filepathN)
r�r�rrr3r�r�r�rr)rQ�
item_indexrZnew_help_sourcerTrTrUr�%s

zGenPage.helplist_item_editcCs4|jjt�}|j|=|jj|�|j�|j�dS)z`Handle remove button for the help list.

        Delete the help list item from config.
        N)r�r�rrr�rr)rQrrTrTrUr�9s
zGenPage.helplist_item_removec	CsZitdd<xHtdt|j�d�D]0}tjddt|�dj|j|ddd���q"WdS)z2Clear and rebuild the HelpFiles section in changesr�Z	HelpFilesr��;Nrh)rrr��lenrrr�r�)rQZnumrTrTrUrDs

zGenPage.update_help_changes)
r�r�r�rFr�r�r�rr�r�r�rr�rTrT)r{rUr`�sz%
r`c@sDeZdZdZdd�Zdd�Zdd�Zedd	��Zd
d�Z	dd
�Z
dS)�VarTracez"Maintain Tk variables trace state.cCsg|_g|_dS)aStore Tk variables and callbacks.

        untraced: List of tuples (var, callback)
            that do not have the callback attached
            to the Tk var.
        traced: List of tuples (var, callback) where
            that callback has been attached to the var.
        N)�untraced�traced)rQrTrTrUrFPs	zVarTrace.__init__cCs|jj�|jj�dS)zClear lists (for tests).N)r�clearr)rQrTrTrUr
\s
zVarTrace.clearcCs*t|t�r|j||�}|jj||f�|S)a_Add (var, callback) tuple to untraced list.

        Args:
            var: Tk variable instance.
            callback: Either function name to be used as a callback
                or a tuple with IdleConf config-type, section, and
                option names used in the default callback.

        Return:
            Tk variable instance.
        )�
isinstance�tuple�
make_callbackrr�)rQr��callbackrTrTrUrbbs
zVarTrace.addcs��fdd�}|S)zCReturn default callback function to add values to changes instance.cstj��j�f��dS)z&Add config values to changes instance.N)rrrrx)r)r�r�rTrU�default_callbackvsz0VarTrace.make_callback.<locals>.default_callbackrT)r�r�rrT)r�r�rUrsszVarTrace.make_callbackcCs:x4|jr4|jj�\}}|jd|�|jj||f�qWdS)z0Attach callback to all vars that are not traced.�writeN)r�popZ	trace_addrr�)rQr�rrTrTrUrP{szVarTrace.attachcCsFx@|jr@|jj�\}}|jd|j�dd�|jj||f�qWdS)z!Remove callback from traced vars.rrr�N)rrZtrace_removeZ
trace_inforr�)rQr�rrTrTrU�detach�szVarTrace.detachN)r�r�r�r�rFr
rbr�rrPrrTrTrTrUr
Msr
a7When 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. [Cancel] only cancels changes made since the last save.
u
Font sample: This shows what a selection of Basic Multilingual Plane
unicode characters look like for the current font selection.  If the
selected font does not define a character, Tk attempts to find another
font that does.  Substitute glyphs depend on what is available on a
particular system and will not necessarily have the same size as the
font selected.  Line contains 20 characters up to Devanagari, 14 for
Tamil, and 10 for East Asia.

Hebrew and Arabic letters should display right to left, starting with
alef, א and ا.  Arabic digits display left to right.  The
Devanagari and Tamil lines start with digits.  The East Asian lines
are Chinese digits, Chinese Hanzi, Korean Hangul, and Japanese
Hiragana and Katakana.

You can edit the font sample. Changes remain until IDLE is closed.
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.
z�
Keys:
The IDLE Modern Unix key set is new in June 2016.  It can only
be used with older IDLE releases if it is saved as a custom
key set, with a different name.
a_
General:

AutoComplete: Popupwait is milleseconds to wait after key char, without
cursor movement, before popping up completion box.  Key char is '.' after
identifier or a '/' (or '\' on Windows) within a string.

FormatParagraph: Max-width is max chars in lines after re-formatting.
Use with paragraphs in both strings and comment blocks.

ParenMatch: Style indicates what is highlighted when closer is entered:
'opener' - opener '({[' corresponding to closer; 'parens' - both chars;
'expression' (default) - also everything in between.  Flash-delay is how
long to highlight if cursor is not moved (0 means forever).

CodeContext: Maxlines is the maximum number of code context lines to
display when Code Context is turned on for an editor window.

Shell Preferences: Auto-Squeeze Min. Lines is the minimum number of lines
of output to automatically "squeeze".
)z
Fonts/TabsrWr�r�cCs.|sdSyt|�dStk
r(dSXdS)z(Return 's is blank or represents an int'TFN)r�r�)r�rTrTrUr��sr�c@seZdZdZdd�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
    cs�tj||f|�|�t|td�}|jtttd�t|dd|j	dd���jt
ttd�|j
�jd��jd��jd�t��|_��jdd�td����fd	d
�}�jd|����fdd
�}�jd|�dS)N)r�)rZrXrYr��)r?r-r�rE)rXrZrY)ri)Zwindowr�cs$�j��j�f}�jd|d�dS)Nz	0 0 %s %s)Zscrollregion)�winfo_reqwidthZwinfo_reqheightr�)r�r)�canvasr�rTrU�_configure_interior�sz;VerticalScrolledFrame.__init__.<locals>._configure_interiorz<Configure>cs&�j��j�kr"�j��j�d�dS)N)rE)rZwinfo_widthZ
itemconfigure)r�)rr��interior_idrTrU�_configure_canvas�sz9VerticalScrolledFrame.__init__.<locals>._configure_canvas)r$rFr*rrcrrrrr�rrr
r�r�Zxview_movetoZyview_movetor�Z
create_windowrr�)rQrGr��kwZ
vscrollbarrrrT)rr�rrUrF�s 

zVerticalScrolledFrame.__init__N)r�r�r�r�rFrTrTrTrUr��sr��__main__)r�z#idlelib.idle_test.test_configdialogrhF)�	verbosity�exit)�run)_r�Ztkinterrrrrrrrr	r
rrr
rrrrrrrrrrrrrrrrrrr Ztkinter.ttkr!r"r#r$r%r&r'r(r)r*r+Ztkinter.colorchooserZcolorchooserr�Ztkinter.fontrr�r,Zidlelib.configr-r.Zidlelib.config_keyr/Zidlelib.dynoptionr0Zidlelibr1Z
idlelib.queryr2r3Zidlelib.textviewr4Zidlelib.autocompleter5Zidlelib.codecontextr6Zidlelib.parenmatchr7Zidlelib.paragraphr8Zidlelib.squeezerr9rrr�r:ryr^r\r_r`r
rOr}r~r�r�r�Zunittestr�Zidlelib.idle_test.htestr rTrTrTrU�<module>sj�4

Q4l=+


Hacked By AnonymousFox1.0, Coded By AnonymousFox