Your IP : 216.73.216.213


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



���]�7�@s�ddlZddlZddlTddlmZmZddlmZddlm	Z	ddl
mZddl
Z
ddlZejjejje��ZejdkZdZd	Zd
ZdZdZd
defZd(ZdddgZdZdZ dddddddddddgZ!dd�Z"d efd!efd"e
jffZ#Gd#d$�d$e$�Z%d%d&�Z&e'd'kr�e&�dS))�N)�*)�ColorDelegator�color_config)�
Percolator)�	view_text)�__doc__�darwin������Arial��boldzLucida Console�
�normal��d��	�������cCsdd�tjt�D�S)NcSs?g|]5}|jd�r|ddkr|dd��qS)z.pyr�_Nr���)�endswith)�.0�entry�r#�-/opt/alt/python35/lib64/python3.5/__main__.py�
<listcomp>vs	z%getExampleEntries.<locals>.<listcomp>)�os�listdir�demo_dirr#r#r#r$�getExampleEntriesusr)zTurtledemo helpzAbout turtledemozAbout turtle modulec@s�eZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zddd
�Zddd�Z	dd�Z
dddd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�ZdS)(�
DemoWindowNcCs�t�|_}t_|jd�|jd|j�tr�ddl}|j	dddddj
tj��ddgd	|j
d
|j
�}|jddd�|jddd�|jdd
ddd�|jdd
ddd�|jdd
ddd�t|dtdd�|_|jjd|j|j�dddd�|jjd|j|j�dddd�|jjd|j|j�dddd�|j|d<tdtdddtdd�}|j|j|��|j|j|��|jddd d!d"d#�t|d$dd%d&dd'd(d:dddt�|_ t!|d%d,d(t"d-d.d/d0d1|j#�|_$t!|d%d2d(t"d-d.d/d0d1|j%�|_&t!|d%d3d(t"d-d.d/d0d1|j'�|_(|j jddd4dd"d#d5d;�|j$jddd4dd"d6�|j&jddd4dd"d6�|j(jddd4dd"d6�t)|j*�j+t,��d7|_-d7|_.|r�|j/|�|j0t1t1t1d8d9�t2|_3dS)<NzPython turtle-graphics examplesZWM_DELETE_WINDOWrZ	osascriptz-ez tell application "System Events"z>set frontmost of the first process whose unix id is {} to truezend tell�stderr�stdoutZweightr	Zminsize�Zr
rZrelief�borderwidth�menu�labelZExamples�	underlineZFontsizeZHelp�orientZ	sashwidthr
Z
sashrelief�bgz#ddd�rowZ
columnspanrZstickyZnewsZheight�textz --- z#ddf�fontr�rz START �fgZwhiteZdisabledforegroundz#fed�commandz STOP z CLEAR �column�padxZewFzChoose example from menu�black)rr7r)rr
)4ZTk�root�turtle�_root�titleZwm_protocol�_destroyr�
subprocess�Popen�formatr&�getpid�DEVNULLZgrid_rowconfigureZgrid_columnconfigure�MenuZRAISEDZmBarZadd_cascade�makeLoadDemoMenu�makeFontMenu�makeHelpMenuZPanedWindow�
HORIZONTALZSOLID�add�
makeTextFrame�makeGraphFrameZgridZLabelZRIDGE�
output_lblZButton�btnfont�	startDemo�	start_btn�stopIt�stop_btn�clearCanvas�	clear_btnrr5Zinsertfilterr�dirty�exitflag�loadfile�	configGUI�DISABLED�STARTUP�state)�self�filenamer=rB�pZpaner#r#r$�__init__�sn
		



%		

zDemoWindow.__init__cCsf|jj�}|jj�}|jjd|j||j�|jjd|j||j�dS)Ng�?)�_canvasZwinfo_widthZwinfo_heightZxview_moveto�	canvwidthZyview_moveto�
canvheight)r^�eventZcwidthZcheightr#r#r$�onResize�s"zDemoWindow.onResizec
Cs�t|�|_}t|dddddddd�|_}t|�t|dd	�|_}|j|d
<|jdt	dt
�t|dd
dt�|_}|j
|d
<|jdtdt�|j|d<|j|d<tt�|d<tr�dnd}|jd||j�|jd||j�|jd||j�|jd||j�|jd|j�|jd|j�|jd|j�|jdt	dtdd�|S)N�namer5r;r
�wrapZnone�width�-�vbarr9Zside�fill�hbarr2ZyscrollcommandZxscrollcommandr6ZCommandZControlz
<%s-minus>z<%s-underscore>z
<%s-equal>z	<%s-plus>z<Control-MouseWheel>z<Control-Button-4>z<Control-Button-5>�expandr	)ZFrame�
text_frameZTextr5rZ	ScrollbarrkZyview�packZLEFT�YrKrmZxviewZBOTTOM�X�set�tuple�txtfontrZbind_all�
decrease_size�
increase_size�bind�update_mousewheelZBOTH)r^r=ror5rkrmZshortcutr#r#r$rM�s.




zDemoWindow.makeTextFramecCs�|tj_d|_d|_tj|dd|j|j�tj_|_}|j�|jj	d|j
�d|jd<tj�|_}tj
j||j�|j|_|gtj_|S)Ni�i iXz<Configure>rr.)r>Z_Screenr?rcrdZScrolledCanvasrbZ
adjustScrollsZ_rootwindowrxrfZScreen�screen�TurtleScreenra�scanvasZ	RawTurtleZscreens)r^r=ZcanvasZ_s_r#r#r$rN�s		,

zDemoWindow.makeGraphFramecCs2|td<tt�|jd<d||jd<dS)Nr	r6zFont size %dr5)rurtr5rO)r^�sizer#r#r$�set_txtsize�s
zDemoWindow.set_txtsizecCs"|jttddt��dS)Nr	�break)r~�maxru�MINIMUM_FONT_SIZE)r^�dummyr#r#r$rv�szDemoWindow.decrease_sizecCs"|jttddt��dS)Nr	r)r~�minru�MAXIMUM_FONT_SIZE)r^r�r#r#r$rwszDemoWindow.increase_sizecCs.|jdktkr |j�S|j�SdS)Nr)Zdeltarrvrw)r^rer#r#r$rys
zDemoWindow.update_mousewheel�ZbluecCs�|jjd|d|tkr$dnd�|jjd|d|tkrOdnd�|jjd|d|tkrzdnd�|jjd|d|�dS)Nr]r3z#d00z#fcar5r8)rR�config�NORMALrTrVrO)r^�start�stop�clearZtxtZcolorr#r#r$rZszDemoWindow.configGUIc
s[t|�}xHt�D]=}|�fdd�}|jd|dddtd|�qW|S)Ncs�j|�dS)N)rY)r")r^r#r$�loadsz)DemoWindow.makeLoadDemoMenu.<locals>.loadr0r1rr6r9)rGr)�add_command�menufont)r^�masterr/r"r�r#)r^r$rHszDemoWindow.makeLoadDemoMenuc
s�t|�}|jddd�jdt�|jddd�jdt�|j�xKtD]C}|�fdd�}|jdt|�dd	dtd|�q[W|S)
Nr0zDecrease (C-'-')r9r6zIncrease (C-'+')cs�j|�dS)N)r~)r})r^r#r$�resize*sz'DemoWindow.makeFontMenu.<locals>.resizer1r)rGr�rvr�rwZ
add_separator�
font_sizes�str)r^r�r/r}r�r#)r^r$rI!s

zDemoWindow.makeFontMenucs[t|�}xHtD]@\}}||�fdd�}|jd|dtd|�qW|S)Ncst�j||�dS)N)rr=)�
help_label�	help_file)r^r#r$�show4sz%DemoWindow.makeHelpMenu.<locals>.showr0r6r9)rG�help_entriesr�r�)r^r�r/r�r�r�r#)r^r$rJ0s
 zDemoWindow.makeHelpMenucCs#|jr|jj�d|_dS)NF)rWrzr�)r^r#r#r$�
refreshCanvas9s	
zDemoWindow.refreshCanvasc
Cs�|j�dtj_d|}t|�tj||_t|jj	d��}|j
�}WdQRX|jjdd�|jj
d|�|jj|d�|jtttdd�t|_dS)	NFzturtledemo.�rz1.0�endz# - a Python turtle graphics examplezPress start button�red)rUr>r{�_RUNNING�
__import__�sys�modules�module�open�__file__�readr5�delete�insertr=r@rZr�r[�READYr])r^r_�modname�f�charsr#r#r$rY>s



zDemoWindow.loadfilecCs)|j�d|_dtj_|jtttdd�|jj	�|jj
d�t|_y4|j
j�}|dkr�t|_n	t|_Wn7tjk
r�|jdkr�dSt|_d}YnX|jtkr�|jttt|�n1|jtkr%d|_|jtttdd�dS)	NTzdemo running...r<ZstandardZ	EVENTLOOPzstopped!zuse mouse/keys or STOPr�)r�rWr>r{r�rZr[r�rzr��mode�RUNNINGr]r��main�EVENTDRIVEN�DONEZ
Terminatorr=rX)r^�resultr#r#r$rQMs2
	

	
	
	zDemoWindow.startDemocCsD|j�|jjd�|jjdd�|jttt�dS)N�allZcursorr�)r�rz�_deleter|r�rZr�r[)r^r#r#r$rUjs
zDemoWindow.clearCanvascCsE|jr5|j�d|_|jtttdd�dtj_dS)NFzSTOPPED!r�)rXrUrZr�r[r>r{r�)r^r#r#r$rSps	
	
zDemoWindow.stopItcCs&dtj_|jj�d|_dS)NF)r>r{r�r=Zdestroy)r^r#r#r$rAxs
zDemoWindow._destroy)�__name__�
__module__�__qualname__rarfrMrNr~rvrwryrZrHrIrJr�rYrQrUrSrAr#r#r#r$r*�s$D	
	r*cCst�}|jj�dS)N)r*r=Zmainloop)Zdemor#r#r$r�~s	r��__main__)rrr)(r�r&�tkinterZidlelib.ColorDelegatorrrZidlelib.PercolatorrZidlelib.textViewrZ
turtledemorZabout_turtledemor>�time�path�dirname�abspathr�r(�platformrr\r�r�r�r�r�r�rPrur�r�r�r)r��objectr*r�r�r#r#r#r$�<module>Xs:
'		�