|idZddlZddlZddlZdZdZdejcxkrdkrnndZdejcxkrdkrnndZes es ed  ddlZ dd lTddl m Z ddl mZn1#e$r) ddlZ dd lTddlZ ddlZn#e$r ed wxYwYnwxYwe jd kr ed  ddlmZddlmZn#YnxYwereZereZdZdZddlZdZddZ dZ!e"dkr e#ddSdS)z .. moduleauthor:: easygui developers and Stephen Raymond Ferg .. default-domain:: py .. highlight:: python Version |release| NFiiTiiz*You must run on Python 2.7+ or Python 3.4+)*zUnable to find tkinter package.g @z6You must use python-tk (tkinter) version 8.0 or higher)Image)ImageTkcdtjtjdtjdtjdS)zD Convert exception info into a string suitable for display. r)join tracebackformat_exceptionsysexc_infoAC:\PYTHON\_runtimes\venv\Lib\site-packages\easygui/boxes/utils.pyexception_formatrEsQ 779- q3<>>!,clnnQ.?  rct}t|D]`\}}|d|||dzdz}||vr||7|d||a|S)z Ensure that every string within input_list is unique. :param list input_list: List of strings :return: New list with unique names as needed. Nrz{0}_{1})list enumerateappendformat) input_list output_listiitemtempLists runiquify_list_of_stringsrSs &&KZ((::4bqb>Jq1uvv$66 x     t $ $ $ $   y//a88 9 9 9 9 rc|ddg}||Stjd|}|r`|d}|d}|d|dz |||z||dzdz}|||||dz g}tjd|}|rR|d}|d}|d|dz ||dzdz}||||dg}tjd|}|re|d}|d}|d|dz ||dzdz}|d|||dg}|S) a Extract a desired hotkey from the text. The format to enclose the hotkey in square braces as in Button_[1] which would assign the keyboard key 1 to that button. The one will be included in the button text. To hide they key, use double square braces as in: Ex[[qq]] it , which would assign the q key to the Exit button. Special keys such as may also be used: Move [] for a full list of special keys, see this reference: http://infohoglobal_state.nmt.edu/tcc/help/ pubs/tkinter/web/key-names.html :param text: :return: list containing cleaned text, hotkey, and hotkey position within cleaned text. Nz(?<=\[).(?=\])rrz(?<=\[\[).(?=\]\])r z(?<=\[\<).+(?=\>\])z<{}>)researchstartendr)textret_valresr!r"captions r parse_hotkeyr'es"T4 G | )%t , ,C 8 ! ggajjz z"T%)_4tC!GHH~EDsOUQY7 ))4 0 0C 3 ! ggajjz z"T#'((^3DsOT2 )*D 1 1C B ! ggajjz z"T#'((^3FMM$uSy/::DA Nrc(|dStj|s"td|d}tj|}tj|\}} tj|}tj ||}n]# tj ||}n>#d|} t}n #|dz }YnxYwt|xYwYnxYw|S)a Load in an image file and return as a tk Image. Loads an image. If the PIL library is available use it. otherwise use the tk method. NOTE: tk_master is required if there are more than one Tk() instances, which there are very often. REF: http://stackoverflow.com/a/23229091/2184122 :param filename: image filename to load :param tk_master: root object (Tk()) :return: tk Image object NzImage file {} does not exist.)master)filer)z8Cannot load {}. Check to make sure it is an image file.zR PIL library isn't installed. If it isn't installed, only .gif files can be used.) ospathisfile ValueErrorrnormpathsplitextPILImageopen PILImageTk PhotoImagetk)filename tk_mastertk_image_ext pil_imagemsgs r load_tk_imager=s-t 7>>( # #> + 2 28 < <>> >Hw))H W  h ' 'FAs"M(++ (9EEE " "}(9EEEHH "LSSC m mllS// ! H Os< *B55D8CDD 'C/.D /C86D  Dch|r |r|d|S|r|st|S|r|st|SdS)z Create nicely-formatted string based on arguments msg and title :param msg: the msg to be displayed :param title: the window title :return: None z - N)str)r<titles rgetFileDialogTitlerAs^ (u(!EE33'' 53xx S5zz 4r__main__zHello from utils)N)$__doc__r+r r runningPython27runningPython34 hexversion Exceptiontkinterr5tkinter.filedialog filedialog tk_FileDialog tkinter.fontfonttk_Font ImportErrorTkinter tkFileDialogtkFont TkVersionPILrr1rr3 basestringr?rrrr'r=rA__name__printrrrrXsy  ----:-----O ----:-----OBB )@ A AA=......""""""" = = ==,,,,     ===k;<<<= ! =<# +N O OO  %%%%%%))))))) D JJ     ---`))))^     z E s6A&&B,A=<B=BBB. B;;B?