MpjdZddlZddlZddlZdZdZdej cxkrdkrnndZdej cxkrdkrnndZes esed  ddlZ dd lddl m Z ddl mZe j(d kred  ddlmZddlmZereZereZdZdZddlZdZddZ dZ!e"dk(r e#dyy#e$r' ddlZ dd lddlZ ddlZn#e$r ed wxYwYzwxYw#Y^xYw)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)ImageTkcdjtjtjdtjdtjdS)zD Convert exception info into a string suitable for display. r)join tracebackformat_exceptionsysexc_infoa/mnt/ssd/data/Dropbox/adrian/scripts/msg_venv/lib/python3.12/site-packages/easygui/boxes/utils.pyexception_formatrEsJ 779-- q3<<>!,cllnQ.? rct}t|D]J\}}|d|||dzdz}||vr|j|*|jdj||L|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_stringsrSsw &KZ(:4bq>Jq1uv$66 x    t $   y//a8 9 : rc:|ddg}||Stjd|}|rD|jd}|jd}|d|dz |||z||dzdz}|||||dz g}tjd|}|r;|jd}|jd}|d|dz ||dzdz}||||dg}tjd|}|rJ|jd}|jd}|d|dz ||dzdz}|dj |||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'esZ"T4 G | ))%t ,C  ! ggajz "T%_4tC!GH~EDsOUQY7 )))4 0C  ! ggajz "T#'(^3DsOT2 ))*D 1C  ! ggajz "T#'(^3FMM$uS/:DA Nrc|ytjj|stdj |d}tjj |}tjj |\}} tj|}tj||}|S# tj||}Y|S#dj |} t}t|#|dz }Yt|xYwxYwxYw)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 77>>( # + 2 28 <> >Hww)H WW  h 'FAs"MM(+ ((9E O " "}}(9EH O "LSSC mS/ ! mllS/ !s6,B//D 2C  D C1& D1D8DD cV|r |r|d|S|r |s t|S|r |s t|Sy)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 rgetFileDialogTitlerAs4 u!3'' 53x S5z r__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__printrrrrXs*  -:-O -:-O @ AA=."<<# N OO  %)JJ   -`)^   z e ==, =;<<= ! =( s6B8 C'8C$>CC$CC$#C$'C+