Hacked By AnonymousFox

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

U

��.e�7�@sdZddlZddlZddlTddlmZmZddlmZddl	m
Z
ddlmZddl
Z
ej�ej�e��ZejdkZd	Zd
ZdZdZd
ZddefZdZdddgZdZdZdddddddddddgZ dd �Z!d!efd"efd#e
jffZ"Gd$d%�d%e#�Z$d&d'�Z%e&d(k�re%�dS))a�
  ----------------------------------------------
      turtleDemo - Help
  ----------------------------------------------

  This document has two sections:

  (1) How to use the demo viewer
  (2) How to add your own demos to the demo repository


  (1) How to use the demo viewer.

  Select a demoscript from the example menu.
  The (syntax colored) source code appears in the left
  source code window. IT CANNOT BE EDITED, but ONLY VIEWED!

  The demo viewer windows can be resized. The divider between text
  and canvas can be moved by grabbing it with the mouse. The text font
  size can be changed from the menu and with Control/Command '-'/'+'.
  It can also be changed on most systems with Control-mousewheel
  when the mouse is over the text.

  Press START button to start the demo.
  Stop execution by pressing the STOP button.
  Clear screen by pressing the CLEAR button.
  Restart by pressing the START button again.

  SPECIAL demos, such as clock.py are those which run EVENTDRIVEN.

      Press START button to start the demo.

      - Until the EVENTLOOP is entered everything works
      as in an ordinary demo script.

      - When the EVENTLOOP is entered, you control the
      application by using the mouse and/or keys (or it's
      controlled by some timer events)
      To stop it you can and must press the STOP button.

      While the EVENTLOOP is running, the examples menu is disabled.

      - Only after having pressed the STOP button, you may
      restart it or choose another example script.

   * * * * * * * *
   In some rare situations there may occur interferences/conflicts
   between events concerning the demo script and those concerning the
   demo-viewer. (They run in the same process.) Strange behaviour may be
   the consequence and in the worst case you must close and restart the
   viewer.
   * * * * * * * *


   (2) How to add your own demos to the demo repository

   - Place the file in the same directory as turtledemo/__main__.py
     IMPORTANT! When imported, the demo should not modify the system
     by calling functions in other modules, such as sys, tkinter, or
     turtle. Global variables should be initialized in main().

   - The code must contain a main() function which will
     be executed by the viewer (see provided example scripts).
     It may return a string which will be displayed in the Label below
     the source code window (when execution has finished.)

   - In order to run mydemo.py by itself, such as during development,
     add the following at the end of the file:

    if __name__ == '__main__':
        main()
        mainloop()  # keep window open

    python -m turtledemo.mydemo  # will then run it

   - If the demo is EVENT DRIVEN, main must return the string
     "EVENTLOOP". This informs the demo viewer that the script is
     still running and must be stopped by the user!

     If an "EVENTLOOP" demo runs by itself, as with clock, which uses
     ontimer, or minimal_hanoi, which loops by recursion, then the
     code should catch the turtle.Terminator exception that will be
     raised when the user presses the STOP button.  (Paint is not such
     a demo; it only acts in response to mouse clicks and movements.)
�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__)'rr�r%ZtkinterZidlelib.colorizerrrZidlelib.percolatorrZidlelib.textviewrZ
turtledemoZabout_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>s>U


�~


Hacked By AnonymousFox1.0, Coded By AnonymousFox