Your IP : 3.145.35.234


Current Path : /usr/lib64/python3.8/turtledemo/__pycache__/
Upload File :
Current File : //usr/lib64/python3.8/turtledemo/__pycache__/__main__.cpython-38.opt-2.pyc

U

��.e�7�@sddlZddlZddlTddlmZmZddlmZddlm	Z	ddl
mZddl
Z
ej�ej�e��ZejdkZdZd	Zd
ZdZdZd
defZdZdddgZdZdZdddddddddddgZ dd�Z!d efd!efd"e
jffZ"Gd#d$�d$e#�Z$d%d&�Z%e&d'k�re%�dS)(�N)�*)�ColorDelegator�color_config)�
Percolator)�	view_text)�__doc__�darwin������Arial�)rrZboldzLucida Console�
�normal��d��	�������cCsdd�t�t�D�S)NcSs.g|]&}|�d�r|ddkr|dd��qS)z.pyr�_N���)�endswith)�.0�entry�r"�+/usr/lib64/python3.8/turtledemo/__main__.py�
<listcomp>ts
�z%getExampleEntries.<locals>.<listcomp>)�os�listdir�demo_dirr"r"r"r#�getExampleEntriesssr(zTurtledemo helpzAbout turtledemozAbout turtle modulec@s�eZdZd(dd�Zdd�Zdd�Zdd	�Zd
d�Zd)dd
�Zd*dd�Z	dd�Z
d+dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�ZdS),�
DemoWindowNc	CsJt�|_}t_|�d�|�d|j�trbddl}|j	ddddd�
t���ddg|j
|j
d	�|jdd
d�|jdd
d�|jd
dd
d
�|jddd
d
�|jddd
d
�t|tdd�|_|jj|�|j�ddd�|jj|�|j�ddd�|jj|�|j�ddd�|j|d<ttdtdd�}|�|�|��|�|�|��|jdddd�t|d
ddddtd�|_ t!|d t"d!d"|j#d#�|_$t!|d$t"d!d"|j%d#�|_&t!|d%t"d!d"|j'd#�|_(|j jd
ddd&d'�|j$jd
d
d(d)�|j&jd
dd(d)�|j(jd
dd(d)�t)|j*��+t,��d*|_-d*|_.|�r.|�/|�|�0t1t1t1d+d,�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�stdoutr	)�weight�Z)Zminsizer,r
r)�relief�borderwidthZExamples)�menu�label�	underlineZFontsizeZHelpr0r
z#ddd)�orientZ	sashwidthZ
sashrelief�bgrZnews)�rowZ
columnspan�stickyz --- z#ddf)r�r)Zheight�textr4�fontr/r.z START Zwhitez#fed)r8r9�fgZdisabledforeground�commandz STOP z CLEAR )rr
)r5�columnr6�padxZew)r5r<r6FzChoose example from menu�black)4ZTk�root�turtle�_root�titleZwm_protocol�_destroyr�
subprocess�run�formatr%�getpidZDEVNULLZgrid_rowconfigureZgrid_columnconfigure�MenuZRAISEDZmBarZadd_cascade�makeLoadDemoMenu�makeFontMenu�makeHelpMenuZPanedWindow�
HORIZONTALZSOLID�add�
makeTextFrame�makeGraphFrameZgridZLabelZRIDGE�
output_lblZButton�btnfont�	startDemo�	start_btn�stopIt�stop_btn�clearCanvas�	clear_btnrr8Zinsertfilterr�dirty�exitflag�loadfile�	configGUI�DISABLED�STARTUP�state)�self�filenamer?rDZpaner"r"r#�__init__�s�
������
�
����

�zDemoWindow.__init__cCsP|j��}|j��}|j�d|j||j�|j�d|j||j�dS)Ng�?)�_canvasZwinfo_widthZwinfo_heightZxview_moveto�	canvwidthZyview_moveto�
canvheight)r_�eventZcwidthZcheightr"r"r#�onResize�s

zDemoWindow.onResizecCs6t|�|_}t|ddddd�|_}t|�t|dd�|_}|j|d<|jt	t
d	�t|d
td�|_}|j
|d<|jttd	�|j|d<|j|d
<tt�|d<tr�dnd}|�d||j�|�d||j�|�d||j�|�d||j�|�d|j�|�d|j�|�d|j�|jt	tdd�|S)Nr8r
Znone�-)�namer=Zwrap�width�vbar)rhr;)�side�fill�hbar)rhr3ZyscrollcommandZxscrollcommandr9ZCommandZControlz
<%s-minus>z<%s-underscore>z
<%s-equal>z	<%s-plus>z<Control-MouseWheel>z<Control-Button-4>z<Control-Button-5>r	)rkrl�expand)ZFrame�
text_frameZTextr8rZ	ScrollbarrjZyviewZpackZLEFT�YrLrmZxviewZBOTTOM�X�set�tuple�txtfontrZbind_all�
decrease_size�
increase_size�bind�update_mousewheelZBOTH)r_r?ror8rjrmZshortcutr"r"r#rN�s2�



zDemoWindow.makeTextFramecCs�|tj_d|_d|_t�|dd|j|j�tj_|_}|��|j�	d|j
�d|jd<t��|_}tj
�||j�|j|_|gtj_|S)Ni�i iXz<Configure>rr/)r@Z_ScreenrArcrdZScrolledCanvasrbZ
adjustScrollsZ_rootwindowrwrfZScreen�screen�TurtleScreenra�scanvasZ	RawTurtleZscreens)r_r?ZcanvasZ_s_r"r"r#rO�s$�

zDemoWindow.makeGraphFramecCs(|td<tt�|jd<d||jd<dS)Nr	r9zFont size %dr8)rtrsr8rP)r_�sizer"r"r#�set_txtsize�szDemoWindow.set_txtsizecCs|�ttddt��dS�Nr	�break)r}�maxrt�MINIMUM_FONT_SIZE�r_Zdummyr"r"r#ru�szDemoWindow.decrease_sizecCs|�ttddt��dSr~)r}�minrt�MAXIMUM_FONT_SIZEr�r"r"r#rvszDemoWindow.increase_sizecCs$|jdktkr|��S|��SdS)Nr)Zdeltarrurv)r_rer"r"r#rxszDemoWindow.update_mousewheel��bluecCsh|jj||tkrdndd�|jj||tkr0dndd�|jj||tkrLdndd�|jj||d�dS)Nz#d00z#fca)r^r4)r8r:)rS�config�NORMALrUrWrP)r_�start�stop�clearZtxtZcolorr"r"r#r[s���zDemoWindow.configGUIcs:t|�}t�D]&}|f�fdd�	}|j|dt|d�q|S)Ncs��|�dS�N)rZ)r!�r_r"r#�loadsz)DemoWindow.makeLoadDemoMenu.<locals>.loadr�r1r2r9r;)rHr(�add_command�menufont)r_�masterr0r!r�r"r�r#rIs
�zDemoWindow.makeLoadDemoMenucsht|�}|jd�jtd�|jd�jtd�|��tD]*}|f�fdd�	}|jt|�dt|d�q8|S)NzDecrease (C-'-'))r1r;r9zIncrease (C-'+')cs��|�dSr�)r})r|r�r"r#�resize(sz'DemoWindow.makeFontMenu.<locals>.resizerr�)rHr�rur�rvZ
add_separator�
font_sizes�str)r_r�r0r|r�r"r�r#rJs
�
��zDemoWindow.makeFontMenucs<t|�}tD]*\}}||f�fdd�	}|j|t|d�q|S)Ncst�j||�dSr�)rr?)�
help_label�	help_filer�r"r#�show2sz%DemoWindow.makeHelpMenu.<locals>.show)r1r9r;)rH�help_entriesr�r�)r_r�r0r�r�r�r"r�r#rK.s
zDemoWindow.makeHelpMenucCs|jr|j��d|_dS�NF)rXryr�r�r"r"r#�
refreshCanvas7s
zDemoWindow.refreshCanvasc	Cs�|��dtj_d|}t|�tj||_t|jj	d��}|�
�}W5QRX|j�dd�|j�
d|�|j�|d�|�tttdd�t|_dS)	NFzturtledemo.�rz1.0�endz# - a Python turtle graphics examplezPress start button�red)rVr@rz�_RUNNING�
__import__�sys�modules�module�open�__file__�readr8�delete�insertr?rBr[r�r\�READYr^)r_r`�modname�f�charsr"r"r#rZ<s
�zDemoWindow.loadfilecCs�|��d|_dtj_|�tttdd�|j�	�|j�
d�t|_z$|j
��}|dkr`t|_nt|_Wn0tjk
r�|jdkr�YdSt|_d}YnX|jtkr�|�ttt|�n"|jtkr�d|_|�tttdd�dS)	NTzdemo running...r>ZstandardZ	EVENTLOOPzstopped!zuse mouse/keys or STOPr�)r�rXr@rzr�r[r\r�ryr��mode�RUNNINGr^r��main�EVENTDRIVEN�DONEZ
Terminatorr?rY)r_�resultr"r"r#rRKs<
�






�

�zDemoWindow.startDemocCs4|��|j�d�|jjdd�|�ttt�dS)N�allr�)Zcursor)r�ryZ_deleter{r�r[r�r\r�r"r"r#rVhszDemoWindow.clearCanvascCs2|jr&|��d|_|�tttdd�dtj_dS)NFzSTOPPED!r�)rYrVr[r�r\r@rzr�r�r"r"r#rTns
�zDemoWindow.stopItcCsdtj_|j��d|_dSr�)r@rzr�r?Zdestroyr�r"r"r#rCvs
zDemoWindow._destroy)N)N)N)r�r�)�__name__�
__module__�__qualname__rarfrNrOr}rurvrxr[rIrJrKr�rZrRrVrTrCr"r"r"r#r)s$
D


	
	r)cCst�}|j��dSr�)r)r?Zmainloop)Zdemor"r"r#r�|sr��__main__)'r�r%ZtkinterZidlelib.colorizerrrZidlelib.percolatorrZidlelib.textviewrZ
turtledemorZabout_turtledemor@�path�dirname�abspathr�r'�platformrr]r�r�r�r�r�r�rQrtr�r�r�r(r��objectr)r�r�r"r"r"r#�<module>Ws<


�~


?>