a  ze:@sddlZddlZddlTddlmZmZddlmZddlm Z ddl m Z ddl Z ejejeZejdkZdZd Zd Zd Zd Zd defZdZgdZdZdZgdZ ddZ!de fde fde j ffZ"Gddde#Z$ddZ%e&dkre%dS)N)*)ColorDelegator color_config) Percolator) view_text)__doc__darwinArial )rrZbold)zLucida Console normald)  r rcCsddttDS)NcSs.g|]&}|dr|ddkr|ddqS)z.pyr_N)endswith).0entryr"G/opt/bitninja-python-dojo/embedded/lib/python3.9/turtledemo/__main__.py usz%getExampleEntries..)oslistdirdemo_dirr"r"r"r#getExampleEntriestsr(zTurtledemo helpzAbout turtledemozAbout turtle modulec@seZdZd(ddZddZddZdd Zd d Zd)d d Zd*ddZ ddZ d+ddZ ddZ ddZ ddZddZddZd d!Zd"d#Zd$d%Zd&d'ZdS), DemoWindowNc Cst|_}t_|d|d|jtrbddl}|j ddddd t ddg|j |j d |jdd d |jdd d |jd d d d |jdd d d |jdd d d t|tdd|_|jj||jddd|jj||jddd|jj||jddd|j|d<ttdtdd}|||||||jddddt|d ddddtd|_ trt!|d t"d!|j#d"|_$t!|d#t"d!|j%d"|_&t!|d$t"d!|j'd"|_(nHt!|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,|_.|rx|/||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)stderrstdoutr )weightZ)Zminsizer,r r )relief borderwidthZExamples)menulabel underlineZFontsizeZHelpr0r z#ddd)orientZ sashwidthZ sashreliefbgr news)rowZ columnspanstickyz --- z#ddf)rr)Zheighttextr4fontr/r.z START z#00cc22)r9r:fgcommandz STOP z CLEAR Zwhitez#fed)r9r:r;Zdisabledforegroundr<)rr )r6columnr7padxZew)r6r=r7FzChoose example from menublack)4ZTkrootturtle_roottitleZ wm_protocol_destroyr subprocessrunformatr%getpidDEVNULLZgrid_rowconfigureZgrid_columnconfigureMenuZRAISEDZmBarZ add_cascademakeLoadDemoMenu makeFontMenu makeHelpMenuZ PanedWindow HORIZONTALZSOLIDadd makeTextFramemakeGraphFrameZgridZLabelZRIDGE output_lblZButtonbtnfont startDemo start_btnstopItstop_btn clearCanvas clear_btnrr9Z insertfilterrdirtyexitflagloadfile configGUIDISABLEDSTARTUPstate)selffilenamer@rEZpaner"r"r#__init__s       zDemoWindow.__init__cCsP|j}|j}|jd|j||j|jd|j||jdS)Ng?)_canvasZ winfo_widthZ winfo_heightZ xview_moveto canvwidthZ yview_moveto canvheight)raeventZcwidthZcheightr"r"r#onResizes  zDemoWindow.onResizecCs6t||_}t|ddddd|_}t|t|dd|_}|j|d<|jt t d t|d t d |_ }|j |d<|jttd |j|d <|j|d <tt|d<trdnd}|d||j|d||j|d||j|d||j|d|j|d|j|d|j|jt tdd|S)Nr9r Znone-)namer>wrapwidthvbar)rjr<)sidefillhbar)rjr3ZyscrollcommandZxscrollcommandr:ZCommandZControlz <%s-minus>z<%s-underscore>z <%s-equal>z <%s-plus>zzzr )rnroexpand)ZFrame text_frameTextr9rZ ScrollbarrmZyviewpackZLEFTYrNrpZxviewZBOTTOMXsettupletxtfontrZbind_all decrease_size increase_sizebindupdate_mousewheelZBOTH)rar@rrr9rmrpZshortcutr"r"r#rPs0       zDemoWindow.makeTextFramecCs|tj_d|_d|_t|dd|j|jtj_|_}||j d|j d|jd<t |_ }tj ||j|j|_|gtj_|S)Nii iXz rr/)rAZ_ScreenrBrerfZScrolledCanvasrdZ adjustScrollsZ _rootwindowr|rhZScreenscreen TurtleScreenrcscanvasZ RawTurtleZscreens)rar@ZcanvasZ_s_r"r"r#rQs  zDemoWindow.makeGraphFramecCs(|td<tt|jd<d||jd<dS)Nr r:z Font size %dr9)ryrxr9rR)rasizer"r"r# set_txtsizeszDemoWindow.set_txtsizecCs|ttddtdSNr break)rmaxryMINIMUM_FONT_SIZEradummyr"r"r#rzszDemoWindow.decrease_sizecCs|ttddtdSr)rminryMAXIMUM_FONT_SIZErr"r"r#r{szDemoWindow.increase_sizecCs$|jdkt kr|S|SdS)Nr)Zdeltarrzr{)rargr"r"r#r} szDemoWindow.update_mousewheelbluecCstr0|jj|d|jj|d|jj|dnT|jj||tkrDdndd|jj||tkr`dndd|jj||tkr|dndd|jj||ddS)N)r`z#d00z#fca)r`r4)r9r;)rrUconfigrWrYNORMALrR)rastartstopclearZtxtZcolorr"r"r#r]szDemoWindow.configGUIcs:t|}tD]&}|ffdd }|j|dt|dq|S)Ncs|dSN)r\)r!rar"r#load&sz)DemoWindow.makeLoadDemoMenu..loadrr1r2r:r<)rJr( add_commandmenufont)ramasterr0r!rr"rr#rK"s zDemoWindow.makeLoadDemoMenucsht|}|jdjtd|jdjtd|tD]*}|ffdd }|jt|dt|dq8|S)NzDecrease (C-'-'))r1r<r:zIncrease (C-'+')cs|dSr)r)rrr"r#resize5sz'DemoWindow.makeFontMenu..resizerr)rJrrzrr{Z add_separator font_sizesstr)rarr0rrr"rr#rL,s   zDemoWindow.makeFontMenucs<t|}tD]*\}}||ffdd }|j|t|dq |S)Ncstj||dSr)rr@) help_label help_filerr"r#show?sz%DemoWindow.makeHelpMenu..show)r1r:r<)rJ help_entriesrr)rarr0rrrr"rr#rM;s  zDemoWindow.makeHelpMenucCs|jr|jd|_dSNF)rZr~rrr"r"r# refreshCanvasDs zDemoWindow.refreshCanvascCs|dtj_d|}t|tj||_t|jj d}| }Wdn1sX0Y|j dd|j d||j|d|tttddt|_dS) NFz turtledemo.rz1.0endz# - a Python turtle graphics examplezPress start buttonred)rXrAr_RUNNING __import__sysmodulesmoduleopen__file__readr9deleteinsertr@rCr]rr^READYr`)rarbmodnamefcharsr"r"r#r\Is & zDemoWindow.loadfilecCs|d|_dtj_|tttdd|j |j dt |_ z$|j }|dkr`t|_ nt|_ Wn.tjy|jdurYdSt|_ d}Yn0|j tkr|ttt|n"|j tkrd|_|tttdddS) NTzdemo running...r?ZstandardZ EVENTLOOPzstopped!zuse mouse/keys or STOPr)rrZrArrr]r^rr~rmodeRUNNINGr`rmain EVENTDRIVENDONEZ Terminatorr@r[)raresultr"r"r#rTXs8           zDemoWindow.startDemocCs4||jd|jjdd|tttdS)Nallr)Zcursor)rr~_deleterrr]rr^rr"r"r#rXus zDemoWindow.clearCanvascCs2|jr&|d|_|tttdddtj_dS)NFzSTOPPED!r)r[rXr]rr^rArrrr"r"r#rV{s zDemoWindow.stopItcCsdtj_|jd|_dSr)rArrr@Zdestroyrr"r"r#rDs zDemoWindow._destroy)N)N)N)rr)__name__ __module__ __qualname__rcrhrPrQrrzr{r}r]rKrLrMrr\rTrXrVrDr"r"r"r#r)s$ L     r)cCst}|jdSr)r)r@Zmainloop)demor"r"r#rsr__main__)'rr%tkinterZidlelib.colorizerrrZidlelib.percolatorrZidlelib.textviewrZ turtledemorZabout_turtledemorApathdirnameabspathrr'platformrr_rrrrrrrSryrrrr(robjectr)rrr"r"r"r#Xs>