|i;dZddlZddlZ ddlmZddlmZddlm Z ddl m Z ddl m Z dd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddl!m"Z"ddl!m#Z#n##e$e%e&f$re'de(YnwxYwej)*ej)*ej)+e,Z-Gdde.Z/dZ0dZ1d Z2d!Z3d"Z4d#Z5d$Z6d%Z7d&Z8d'Z9d(Z:d)Z;d*Zd-Z?d.Z@d/ZAd0ZBd1ZCd2ZDd3ZEd4ZFd5ZGd6ZHdS)7zn .. moduleauthor:: easygui developers and Stephen Raymond Ferg .. default-domain:: py .. highlight:: python N)utils) buttonbox)textbox) diropenbox) fileopenbox) filesavebox) multenterbox)multpasswordbox)ynbox)ccbox)boolbox)indexbox)msgbox) integerbox)enterbox exceptionbox)codebox) passwordbox) choicebox) multchoicebox)about) eg_version) abouteasyguiz+Please run demo.py from outside the packagec0eZdZdZdZdZdZdZdZdS)Demosa Collection of demos A choice is comprised of two pieces of data: - a description, which is a string. The descriptions will be shown in the choicebox, and one will be returned by it. - a function to execute when the description is selected cdtfdtfdtfdtfdtfdt fdt fdtfd tfd tfd tfd tfd tfdtfdtfdtfdt fdt"fdt$fdt&fdt(fdt*fdt,fdt.fg|_dS)Nrr r rrz buttonbox that displays an imagezbuttonbox - select an imagerrrrrrrrr r zenterbox that displays an imager rrrz About EasyGuiHelp) demo_msgbox demo_ynbox demo_ccbox demo_boolboxdemo_buttonboxdemo_buttonbox_with_imagedemo_buttonbox_with_choice demo_indexboxdemo_choiceboxdemo_multichoicebox demo_textbox demo_codebox demo_enterboxdemo_integerboxdemo_passwordboxdemo_multenterboxdemo_multpasswordboxdemo_enterbox_imagedemo_filesaveboxdemo_fileopenboxdemo_diropenboxdemo_exceptionbox demo_about demo_helpdemosselfs @C:\PYTHON\_runtimes\venv\Lib\site-packages\easygui/boxes/demo.py__init__zDemos.__init__=s { # j ! j !  % . ) /1J K *,F G  ' . ) 1 2  %  %  ' ? + , - . /  4 5 .0C D , - , - ? + . / j ) Y 1  c(d|jD}|S)Ncg|] }|d S)r).0cs r; z+Demos.list_descriptions..Zs111!111r=r8)r: descriptionss r;list_descriptionszDemos.list_descriptionsYs11dj111 r=c,|j|}|dS)NrrDr:indexdemos r;get_demozDemos.get_demo]sz% Awr=c,|j|}|dS)NrrDrHs r;get_descriptionzDemos.get_descriptionbsz% Awr=c*t|jS)N)lenr8r9s r;__len__z Demos.__len__fs4:r=N) __name__ __module__ __qualname____doc__r<rFrKrMrPr@r=r;rr3si   8 r=rc|t}dgt|z}tdg}|d|dt j|dt|dtj d |}dtz}| }d } d t||D}t|||| }|sdSt|||} || } | } | rd | || <nd|| <|dz }|t|krd })z Run the EasyGui demo. zd z+Pick the kind of box that you wish to demo.z * Python version {}z * EasyGui version {}z * Tk version {} zEasyGui rTcg|] \}}||z Sr@r@)rAdrs r;rCz easygui_demo..~s-:::aAE:::r=)msgtitlechoices preselectz - Last reply: {}rN)rrOprintappendformatsysversionrut TkVersionjoinrFziprrIrK) r8repliesr[ intro_messager\rE preselectedpresented_choicesreplyindex_chosen_demo chosen_demo demo_replys r; easygui_demorpjs GGEdSZZG * CJJ<===JJ%,,S[99:::JJ&--j99:::JJ!((66777IIcNNM  #E**,,LK::!,88:::m %"3$/   E e -33E::nn%677  []]   ,)<)C)CJ)O)OG% & &)+G% &q #/00 0 0K7r=cjtdd}td||S)Nz short msgzThis is a long titleReply was: {!r})rr_rarls r;r r s4 ; 6 7 7E  " "5 ) )*** Lr=ctgdd}td|d}d}t||gdd }td||S) N)onetworvthreerv)r]default_choicerrz*Demo of Buttonbox with many, many buttons!zDThis buttonbox shows what happens when you specify too many buttons.)1234567r)r[r\r] cancel_choice)rr_ra)rlr\r[s r;r$r$s <<<%* , , ,E  " "5 ) )*** 8E 'C #UAAA$' ) ) )E  " "5 ) )*** Lr=cd}gd}tjtdtjtdtjtdtjtdfD]9}t ||z||}t d|:|S) Nz Do you like this picture? It is )YesNoz No opinionpython_and_check_logo.gifpython_and_check_logo.jpgpython_and_check_logo.png zzzzz.gif)imager]rr)ospathrf package_dirrr_ra)r[r]rrls r;r%r%s -C)))G GLL&A B B GLL&A B B GLL&A B B GLLk 2 2 4// #+UGDDD &&u--.... Lr=cVd}dg}t}|tjt d|tjt d|tjt d|tjt dt ||dg}td||S) Nz Pick an imagecancelrrrr)imagesr]rr) listr`rrrfrrr_ra)r[r]rrls r;r&r&s CjG VVF MM"',,{,GHHIII MM"',,{,GHHIII MM"',,{,GHHIII MM"',,{K88999 c&8* = = =E  " "5 ) )*** Lr=crd}d}t||}td||S)Nz!Insert your favorite message herez Demo of ccboxrr)r r_ra)r[r\rls r;r"r"s= -C E #u  E  " "5 ) )*** Lr=c~gd}d}d}t|d||}td||S)N)aaabbbcccggghhhiiijjjkkkLLLmmmnnnooopppqqqrrrssstttuuuvvvz!Pick as many choices as you wish.zDemo of multchoiceboxrr)rr_ra) listChoicesr^r[rls r;r)r)sUKI -C #6 Y O OE  " "5 ) )*** Lr=cd}d}t||}td||rtdd|S)Nz Demo of ynboxz+Were you expecting the Spanish Inquisition?rrz'NOBODY expects the Spanish Inquisition!zWrong!)r r_rar)r\r[rls r;r!r!sW E 7C #u  E  " "5 ) )*** D8(CCC Lr=cd}d}ddddd|ddd d d d d ddddddddddddg}d}t||}td|d}t|||}td|d}tdt}td||S)NzDemo of choiceboxzThis is an example of a very long option which you may or may not wish to choose.This is an example of a very long option which you may or may not wish to choose.rdddeeefffrrrrrrrrrrrrrrrrrraHPick something. A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A wrapable sentence of text ?! A separate line of text. A separate line of text. A separate line of text. A separate line of text. A separate line of text. A separate line of text.)r[r]rrzPick something. )r[r\r]zThe list of choices is empty!)rr_rar)r\ longchoicerr[rls r;r(r(s E %uueUE5%ue%%u 6K  ,C #{ 3 3 3E  " "5 ) )*** C #UK @ @ @E  " "5 ) )*** C  +TVV = = =E  " "5 ) )*** Lr=ctddddd}td|tdd}td||S) Nz Enter a number between 3 and 333z%Demo: integerbox WITH a default valueiMrrzEnter a number between 0 and 99z(Demo: integerbox WITHOUT a default value)rr_rarss r;r-r-su */a > >E  " "5 ) )*** )2  E  " "5 ) )*** Lr=cft}td||SNrr)rr_rarss r;r6r6s- NNE  " "5 ) )*** Lr=ctjtd}d}t |dd}t d|d}t |ddd}t d|t d d }t d||S) Nrz>Enter the name of your best friend. (Result will be stripped.)zLove!z Suzy Smith rrzBEnter the name of your best friend. (Result will NOT be stripped.)F)stripz#Enter the name of your worst enemy:zHate!rrrfrrr_rarmessagerls r;r,r,s GLL&A B BE.G Wg'= > >E  " "5 ) )***2G 0 ? ? ?E  " "5 ) )*** :G D DE  " "5 ) )*** Lr=cd}d}gd}t}t|||} |nt}t||D]E\}}|dkr(|d|Ft |sn&td||||}td||S)NzEnter logon informationzDemo of multpasswordbox)z Server IDzUser IDPasswordTrVz"{}" is a required field. Reply was: {!s}) rr rgrr`rarOrfr_r[r\ fieldNames fieldValueserrsnvs r;r0r0+s #C %E555J&&K!#uj99K ;   vv K00 G GDAqwwyyB ;BB1EEFFF4yy  % GGDMM5*k;;  ;  " "; / /000 r=c~ddz}d}d}t|||}td||S)NaIt was the best of times, and it was the worst of times. The rich ate cake, and the poor had cake recommended to them, but wished only for enough cash to buy bread. The time was ripe for revolution! It was the best of times, and it was the worst of times. The rich ate cake, and the poor had cake recommended to them, but wished only for enough cash to buy bread. The time was ripe for revolution! It was the best of times, and it was the worst of times. The rich ate cake, and the poor had cake recommended to them, but wished only for enough cash to buy bread. The time was ripe for revolution! It was the best of times, and it was the worst of times. The rich ate cake, and the poor had cake recommended to them, but wished only for enough cash to buy bread. The time was ripe for revolution! It was the best of times, and it was the worst of times. The rich ate cake, and the poor had cake recommended to them, but wished only for enough cash to buy bread. The time was ripe for revolution! zDemo of textboxaHere is some sample text. Here is some sample text. Here is some sample text. Here is some sample text. Here is some sample text. Here is some sample text. Here is some sample text. Here is some sample text. Here is some sample text. Here is some sample text. Here is some sample text. Here is some sample text. Here is some sample text. Here is some sample text. Here is some sample text. Here is some sample text. r)rr_ra) text_snippetr\r[rls r;r*r*CsR  L E +C C - -E  " "5 ) )*** Lr=ctd}d}t|d|}td||S)Na} dafsdfa dasflkj pp[oadsij asdfp;ij asdfpjkop asdfpok asdfpok asdfpokdafsdfa dasflkj pp[oadsij asdfp;ij asdfpjkop asdfpok asdfpok asdfpokdafsdfa dasflkj pp[oadsij asdfp;ij asdfpjkop asdfpok asdfpok asdfpok # here is some dummy Python code for someItem in myListOfStuff: do something(someItem) do something() do something() if somethingElse(someItem): doSomethingEvenMoreInteresting() # here is some dummy Python code for someItem in myListOfStuff: do something(someItem) do something() do something() if somethingElse(someItem): doSomethingEvenMoreInteresting() # here is some dummy Python code for someItem in myListOfStuff: do something(someItem) do something() do something() if somethingElse(someItem): doSomethingEvenMoreInteresting() # here is some dummy Python code for someItem in myListOfStuff: do something(someItem) do something() do something() if somethingElse(someItem): doSomethingEvenMoreInteresting() # here is some dummy Python code for someItem in myListOfStuff: do something(someItem) do something() do something() if somethingElse(someItem): doSomethingEvenMoreInteresting() # here is some dummy Python code for someItem in myListOfStuff: do something(someItem) do something() do something() if somethingElse(someItem): doSomethingEvenMoreInteresting() # here is some dummy Python code for someItem in myListOfStuff: do something(someItem) do something() do something() if somethingElse(someItem): doSomethingEvenMoreInteresting() # here is some dummy Python code for someItem in myListOfStuff: do something(someItem) do something() do something() if somethingElse(someItem): doSomethingEvenMoreInteresting() # here is some dummy Python code for someItem in myListOfStuff: do something(someItem) do something() do something() if somethingElse(someItem): doSomethingEvenMoreInteresting() # here is some dummy Python code for someItem in myListOfStuff: do something(someItem) do something() do something() if somethingElse(someItem): doSomethingEvenMoreInteresting() # here is some dummy Python code for someItem in myListOfStuff: do something(someItem) do something() do something() if somethingElse(someItem): doSomethingEvenMoreInteresting() # here is some dummy Python code for someItem in myListOfStuff: do something(someItem) do something() do something() if somethingElse(someItem): doSomethingEvenMoreInteresting() # here is some dummy Python code for someItem in myListOfStuff: do something(someItem) do something() do something() if somethingElse(someItem): doSomethingEvenMoreInteresting() # here is some dummy Python code for someItem in myListOfStuff: do something(someItem) do something() do something() if somethingElse(someItem): doSomethingEvenMoreInteresting() # here is some dummy Python code for someItem in myListOfStuff: do something(someItem) do something() do something() if somethingElse(someItem): doSomethingEvenMoreInteresting() # here is some dummy Python code for someItem in myListOfStuff: do something(someItem) do something() do something() if somethingElse(someItem): doSomethingEvenMoreInteresting() aHere is some sample code. Here is some sample code. Here is some sample code. Here is some sample code. Here is some sample code. Here is some sample code. Here is some sample code. Here is some sample code. Here is some sample code. Here is some sample code. Here is some sample code. Here is some sample code. Here is some sample code. Here is some sample code. Here is some sample code. Here is some sample code. z Code Samplerr)rr_ra) code_snippetr[rls r;r+r+QsC L ,C C 5 5E  " "5 ) )*** Lr=cft}td||Sr)rr_rarss r;r#r#bs- IIE  " "5 ) )*** Lr=ctjtd}d}t |d|}t d||S)NrzWhat kind of snake is this?Quiz)rrrrrs r;r1r1hsS GLL&A B BE+G WfE 2 2 2E  " "5 ) )*** Lr=ctdd}td|tddd}td||S)Nz@Demo of password box WITHOUT default Enter your secret passwordz Member Logonrz=Demo of password box WITH default Enter your secret passwordalfie)rr_rarss r;r.r.psu ;& ( (E  " "5 ) )*** ;& 1 1E  " "5 ) )*** Lr=c<tdtjdS)Nz EasyGui Help)text)rrEASYGUI_ABOUT_INFORMATIONr@r=r;r7r7}s N!@AAAA 4r=czd}d}d}t|||}td||S)Nz myNewFile.txtz File SaveAsz Save file as:defaultzYou chose to save file: {})r r_ra)filenamer\r[fs r;r2r2sGH E CC111A & - -a 0 0111 Hr=cBd}d}t||}td|t||d}td|t||d}td||S)NzDemo of diropenboxz)Pick the directory that you wish to open.zYou chose directory...: {}z./rzc:/)rr_ra)r\r[rYs r;r4r4s E 5C3A & - -a 0 01113t,,,A & - -a 0 01113u---A & - -a 0 0111 Hr=c> ddz }n#tYnxYwdS)Nrrr)#thisWillCauseADivideByZeroExceptions r;r5r5s/./!e++ 4sc|d}d}gd}t|||}td||S)NIndexboxzDemo of indexbox)Choice1Choice2Choice3Choice4rr)rr_ra)r\r[r]rls r;r'r'sJ E !C:::G S% ) )E  " "5 ) )*** Lr=cd}d}gd}t}t|||} |nt}t||D]E\}}|dkr(|d|Ft |sn&td||||}td||S) NzEnter your personal informationzCredit Card Application)NamezStreet AddressCityStateZipCodeTrVz"{}" is a required field.rWz Reply was: {}) rr rgrr`rarOrfr_rs r;r/r/s +C %EGGGJ&&KsE:66K =   vv K00 C CDAqwwyyB 7>>qAABBB4yy  " IIdOOUJ ==  = /  - -... r=cd}d}d}t|||}td|d}d}dgd gd g}t||||d }td |z|S)Nz Python filesz Open filesz*.pyrzYou chose to open file: {}z./*.gifz$Some other file types (Multi-select)z*.jpg)z*.zipz*.tgsz*.gzz Archive files)z*.htmz*.htmlz HTML filesT)r filetypesmultiplezYou chose to open file: %s)rr_ra)r[r\rrrs r;r3r3s C EGC000A & - -a 0 0111G 0C,,,-N-N-NPI UGy4 I I IA & *+++ Hr=)IrTrrbrVrrd button_boxrtext_boxr diropen_boxr fileopen_boxr filesave_boxr multi_fillable_boxr r derived_boxesr r rrrrrrrr choice_boxrrrrr SystemError ValueError ImportErrorr_exitrdirnamerealpath__file__robjectrrpr r$r%r&r"r)r!r(r-r6r,r0r*r+r#r1r.r7r2r4r5r'r/r3r@r=r;rs  %%%%%%!!!!!!''''''))))))))))))000000333333$$$$$$$$$$$$&&&&&&''''''%%%%%%))))))''''''++++++&&&&&&******%%%%%%))))))!!!!!!#######Z-    E 7888DFFFFF goobgoobg.>.>x.H.HIIJJ 44444F444n...b            :    $0   "            0     sB BB76B7