
    wZi                        S r SSKrSSKrSSKrSrSrS\R                  s=::  a  S::  a  O  OSrS\R                  s=::  a  S::  a  O  OSr\(       d  \(       d  \" S	5      e SSKr	SS
K7  SSK
Jr  SSKJr  \	R(                  S:  a  \" S5      e SSKJr  SSKJr  \(       a  \r\(       a  \rS rS rSSKrS rSS jr S r!\"S:X  a	  \#" S5        gg! \ a'     SSKr	SS
K7  SSKrSSKr Nv! \ a	    \" S5      ef = ff = f!    Nk= f)z

.. moduleauthor:: easygui developers and Stephen Raymond Ferg
.. default-domain:: py
.. highlight:: python

Version |release|

    NFi i  Ti i  z*You must run on Python 2.7+ or Python 3.4+)*zUnable to find tkinter package.g       @z6You must use python-tk (tkinter) version 8.0 or higher)Image)ImageTkc                      SR                  [        R                  " [        R                  " 5       S   [        R                  " 5       S   [        R                  " 5       S   5      5      $ )z<
Convert exception info into a string suitable for display.
 r         )join	tracebackformat_exceptionsysexc_info     m/var/www/eduai.edurigo.com/question_generate/ques_gen_env/lib/python3.13/site-packages/easygui/boxes/utils.pyexception_formatr   E   sJ     779--q3<<>!,cllnQ.?  r   c                     [        5       n[        U 5       HJ  u  p#U SU XS-   S -   nX4;  a  UR                  U5        M*  UR                  SR                  X25      5        ML     U$ )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.
Nr   z{0}_{1})list	enumerateappendformat)
input_listoutput_listiitemtempLists        r   uniquify_list_of_stringsr   S   sj     &KZ(bq>J1uv$66t$y//89 ) r   c                 N   U SS/nU c  U$ [         R                  " SU 5      nU(       a@  UR                  S5      nUR                  S5      nU SUS-
   XU -   XS-   S -   nXPX4 US-
  /n[         R                  " SU 5      nU(       a8  UR                  S5      nUR                  S5      nU SUS-
   XS-   S -   nXPX4 S/n[         R                  " SU 5      nU(       aH  UR                  S5      nUR                  S5      nU SUS-
   XS-   S -   nUSR	                  XU 5      S/nU$ )	ak  
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 <Enter> may also be
used:  Move [<left>]  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(?<=\[).(?=\])r   r   z(?<=\[\[).(?=\]\])r	   z(?<=\[\<).+(?=\>\])z<{}>)researchstartendr   )textret_valresr!   r"   captions         r   parse_hotkeyr'   e   sH   " T4 G| ))%t
,C
		!ggajz	"T_4t!GH~EOUQY7 )))4
0C
		!ggajz	"T'(^3OT2 ))*D
1C
		!ggajz	"T'(^3FMM$S/:DANr   c                    U c  g[         R                  R                  U 5      (       d  [        SR	                  U 5      5      eSn[         R                  R                  U 5      n [         R                  R                  U 5      u  p4 [        R                  " U 5      n[        R                  " XQS9nU$ !    [        R                  " XS9n U$ !   SR	                  U 5      n [        nO!   US-  n O= f[        U5      e= f= f)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
NzImage 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.)ospathisfile
ValueErrorr   normpathsplitextPILImageopen
PILImageTk
PhotoImagetk)filename	tk_mastertk_image_ext	pil_imagemsgs          r   load_tk_imager=      s     77>>(##+228<> 	> Hww)HWWh'FA"MM(+	((E O"
	"}}(EH O	"LSSCmmllS/!s6   *B2 2D5CC> C'&C>'C0.C>>Dc                     U (       a  U(       a	  U< SU < 3$ U (       a  U(       d  [        U 5      $ U(       a  U (       d  [        U5      $ g)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     r   getFileDialogTitlerA      s4     u!3''
53xS5zr   __main__zHello from utils)N)$__doc__r+   r   r   runningPython27runningPython34
hexversion	Exceptiontkinterr5   tkinter.filedialog
filedialogtk_FileDialogtkinter.fontfonttk_FontImportErrorTkintertkFileDialogtkFont	TkVersionPILr   r1   r   r3   
basestringr?   r   r   r   r'   r=   rA   __name__printr   r   r   <module>rX      s%   
 
  -:-O-:-O
@
AA=." <<#
N
OO
	%) JJ 
-`)^  z	
 e  	==,  =;<<=	=(	s*   "C D D C--C<<D D