Your IP : 3.15.18.73


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

�
e f�%�@sNdZddlmZddlmZmZmZmZmZddl	m
Z
mZmZm
Z
mZmZmZddl	mZddlmZdZer�ddlmZnGd	d
�d
e�ZGdd�de
�ZGd
d�de�ZGdd�de�Zdd�Zdd�ZedkrJddlmZee�ndS)a help.py: Implement the Idle help menu.
Contents are subject to revision at any time, without notice.


Help => About IDLE: diplay About Idle dialog

<to be moved here from aboutDialog.py>


Help => IDLE Help: Display help.html with proper formatting.
Doc/library/idle.rst (Sphinx)=> Doc/build/html/library/idle.html
(help.copy_strip)=> Lib/idlelib/help.html

HelpParser - Parse help.html and and render to tk Text.

HelpText - Display formatted help.html.

HelpFrame - Contain text, scrollbar, and table-of-contents.
(This will be needed for display in a future tabbed window.)

HelpWindow - Display HelpFrame in a standalone window.

copy_strip - Copy idle.html to help.html, rstripping each line.

show_idlehelp - Create HelpWindow.  Called in EditorWindow.help_dialog.
�)�
HTMLParser)�abspath�dirname�isdir�isfile�join)�Tk�Toplevel�Frame�Text�	Scrollbar�Menu�
Menubutton)�font)�idleConfF)rc@sUeZdZdZdd�Zddd�Zdd�Zd	d
�Zdd�Zd
S)�
HelpParserz�Render help.html into a text widget.

    The overridden handle_xyz methods handle a subset of html tags.
    The supplied text should have the needed tag configurations.
    The behavior for unsupported tags, such as table, is undefined.
    cCs�tj|dd�||_d|_d|_d|_d|_d|_d|_d|_	d|_
d|_g|_d|_
dS)NZconvert_charrefsT�Fr)r�__init__�text�tags�chartags�show�hdrlink�level�pre�hprefix�	nested_dl�
simplelist�toc�header)�selfr�r!�1/opt/alt/python34/lib64/python3.4/idlelib/help.pyr1s											zHelpParser.__init__�cCs>|j|7_|jdkr$dndt|j�|_dS)Nrr�l)r�strr)r �amtr!r!r"�indent@szHelpParser.indentcCs�d}x)|D]!\}}|dkr
|}q
q
Wd}|dkr\|dkr\d|_nD|dkr�|dkr�d|_n |dkr�|d	kr�d
}n�|dkr�|dkr�d|_n�|dkr�|d
kr�d|_n�|dkrd|_n�|d#krJ|jd�d$kr4d}d|_n	d|_|j�nV|dkrt|jdkr�d|_q�n,|dkr�|jr�dnd}n|dkr�|js�d
nd}d|_n�|dkr�|j�d}n�|dkr$d|_|jr|jj	dd
�nd|_
n||dkrH|dkrHd|_nX|dkr`||_
n@|d%kr�|jr�d|_|jj	dd
�n||_
n|jr�|jj	d||j
|jf�nd"S)&zHandle starttags in help.html.r�classZdivZsectionTZ
sphinxsidebarF�p�firstz

�spanrZversionmodified�em�ul�olZsimpler#�
ZdlrZliz
* z

* Zdt�dd�end�preblock�aZ
headerlink�h1�h2�h3N)r-r.���)r5r6)
rr�findrr'rrrr�insertrrr)r �tag�attrsZclass_r3�v�sr!r!r"�handle_starttagDsd
		

						zHelpParser.handle_starttagcCs�|dkrM|jd�|jr�|jj|j|jjd�f�q�np|dkred|_nX|d	kr}d
|_n@|dkr�d
|_	d|_
n|dkr�|jdd�ndS)zHandle endtags in help.html.r4r5r6rr9r+r,rr3Frr-r0r.r&r#N)zh1zh2zh3)zspanzem)zulzddzolr7)r'rr�appendrr�indexrrrr)r r:r!r!r"�
handle_endtagzs
	+	zHelpParser.handle_endtagcCs�|jr�|jr�|jr"|n|jdd�}|jdkrb|d|jd��|_n|jd
kr�|jdkr�|dt|j��|jkr�|t|j�d�j�}n|j	|7_	n|j
jd	||j|jf�ndS)z"Handle date segments in help.html.r/� r4rr5r6rNr1)zh1zh2zh3)
rrr�replacerr@r�len�striprrr9r)r �data�dr!r!r"�handle_data�s!""zHelpParser.handle_dataN)	�__name__�
__module__�__qualname__�__doc__rr'r>rArHr!r!r!r"r*s6rc@s.eZdZdZdd�Zdd�ZdS)�HelpTextzDisplay help.html.c	Cs0tjddddd�}tjddddd�}d|d}tj||d	d
ddd
dddd|d|�|jdddg�}|jdddg�}|df|d<|jdd|ddf�|jdd|ddf�|jdd|ddf�|jdd|d df�|jd!d|dfd"d#�|jd$d|d%fd&d'dd(d)d*d"d+�|jd,d&d'd-d'�|jd.d&d/d-d/�|jd0d&d1d-d1�|jd2d&d3d-d3�t|�|_t|d4d5��}|j	�}Wd6QX|jj
|�d7|d8<d6S)9z'Configure tags and feed file to parser.�mainZEditorWindow�width�type�intZheight��ZwrapZwordZhighlightthicknessrZpadx�ZborderwidthZ
TkDefaultFontZarialZ	helveticaZTkFixedFontZmonacoZcourier�rr,Zitalicr4�Zboldr5�r6�r�
backgroundz#f6f6ffr2�
Zlmargin1�r#ZreliefZsolidz#eeffcc�l1Zlmargin2�l2�2�l3�K�l4�d�encodingzutf-8NZdisabled�state)rZ	GetOptionrr�findfontZ
tag_configurer�parser�open�readZfeed)	r �parent�filenameZuwideZuhighZ
normalfontZ	fixedfont�f�contentsr!r!r"r�s0zHelpText.__init__cCs�x�|D]�}|j�dd�tjd|�D�krdtjd|ddd|�}|j�dS|j�dd�tjd|�D�kr|SqWd	S)
z4Return name of first font family derived from names.css|]}|j�VqdS)N)�lower)�.0�xr!r!r"�	<genexpr>�sz$HelpText.findfont.<locals>.<genexpr>�root�name�existsTZfamilycss|]}|j�VqdS)N)rm)rnror!r!r"rp�sN)rm�tkfont�namesZFontZactualZfamilies)r rurrrr!r!r"re�s
+zHelpText.findfontN)rIrJrKrLrrer!r!r!r"rM�srMc@s.eZdZdZdd�Zdd�ZdS)�	HelpFramez&Display html text, scrollbar, and toc.cCs�tj||�t||�}|d|d<t|d|j�}|j|d<|jddd�|jddd�|j|�j	ddddd	d
�|j	ddddd	d�|j	ddddd	d
�dS)NrY�commandZyscrollcommandr�weightr#�column�row�stickyZnw�nsew��ns)
r
rrMr�yview�setZrowconfigureZcolumnconfigure�toc_menu�grid)r rirjrZscrollr!r!r"r�s
%zHelpFrame.__init__c	stt|dd�}t|dd�}x?�jjD]1\}}|jd|d|�fdd��q1W||d	<|S)
z+Create table of contents as drop-down menu.rZTOCZtearoffFZlabelrwcs
�j|�S)N)r)�dex)rr!r"�<lambda>�sz$HelpFrame.toc_menu.<locals>.<lambda>Zmenu)rr
rfrZadd_command)r rrZdropZlblr�r!)rr"r��s)
zHelpFrame.toc_menuN)rIrJrKrLrr�r!r!r!r"rv�srvc@s"eZdZdZdd�ZdS)�
HelpWindowz!Display frame with rendered html.cCstj||�|j|�|jd|j�t||�jdddddd�|jddd�|jddd�dS)	NZWM_DELETE_WINDOWryrrzr{r|rxr#)	r	rZwm_titleZprotocolZdestroyrvr�Zgrid_columnconfigureZgrid_rowconfigure)r rirj�titler!r!r"r�s
%zHelpWindow.__init__N)rIrJrKrLrr!r!r!r"r��sr�cCs�tttttt����ddddd�}tttt��d�}t|d��G}t|d��/}x%|D]}|j|j�d	�qyWWd
QXWd
QXtd�d
S)zCCopy idle.html to idlelib/help.html, stripping trailing whitespace.ZDocZbuildZhtmlZlibraryz	idle.htmlz	help.html�rb�wbs
Nzidle.html copied to help.html)rrr�__file__rg�write�rstrip�print)�srcZdstZinn�out�liner!r!r"�
copy_strip�s
'r�cCs?tttt��d�}t|�s+dSt||d�dS)z7Create HelpWindow; called from Idle Help event handler.z	help.htmlNz	IDLE Help)rrrr�rr�)rirjr!r!r"�
show_idlehelp�sr��__main__)�runN) rLZhtml.parserrZos.pathrrrrrZtkinterrr	r
rrr
rrrtZidlelib.configHandlerrZuse_ttkZtkinter.ttkrrMrvr�r�r�rIZidlelib.idle_test.htestr�r!r!r!r"�<module>s"(4m*

?>