
 M@`                @   s#  d  Z  e  j   d Z d d d d d d d d	 d
 d d d d d d d d d d d d d d g Z d d l Z d d l Z d d l Z d d l Z d d l Z e j	 d k r d Z
 n d Z
 e j	 d k r d Z n d Z y* d d l m Z d d  l m Z d Z Wn d Z Yn Xe rFd d! l Td d l j Z d d" l m Z n& d d! l Td d l Z d d" l m Z d# d$   Z d% d&   Z e Z e d' k  rd( d) Z e d* e d+ e e  d, e d*  e j  d  d- d.   Z! d/ a" d Z# d3 Z$ d4 Z% d5 Z& d6 Z' d7 d8 d9 g Z( d a) d a* d a+ d a, d a- d a. d: a/ d: a0 d a1 d a2 d a3 d a4 d; Z5 d< d= d d d@ d  Z6 d< d= d d dC d  Z7 d< d= d d dD d  Z8 d< d= d d dE d  Z9 dF d= dG d d dH d  Z: d: d= d d d dL d  Z; d: d= d: d dM d d dN d  Z< dO d= f  f  dP d	  Z= dO d= e>   e>   dQ d  Z? dR dS   Z@ dT dU   ZA dV dW   ZB dO d= f  f  d dX dY  ZC dZ d[   ZD d\ d]   ZE d^ d= d: d d d d_ d
  ZF d` d= d: d d da d  ZG d: d: d d d db dc  ZH dd de   ZI df dg   ZJ dh di   ZK dj dk   ZL dl d= f  dm d  ZM dn d= f  do d  ZN dp dq   ZO dr ds   ZP dt du   ZQ dv dw   ZR dx dy   ZS dz d{   ZT d| d}   ZU d d d~ d  ZV d: d= d: d d  ZW d: d= d: d d d  ZX d d   ZY d d d d d  ZZ d d   Z[ Gd d   d  Z\ d d d( d d d  Z] d d d: d d d  Z^ d d   Z_ d d   Z` d d   Za Gd d   d  Zb d d   Zc d d   Zd d d   Ze d d   Zf d d   Zg d d   Zh d d   Zi d d   Zj d d   Zk d Zl d d   Zm en d k rec   d S)a  
@version: 0.96(2010-08-29)

@note:
ABOUT EASYGUI

EasyGui provides an easy-to-use interface for simple GUI interaction
with a user.  It does not require the programmer to know anything about
tkinter, frames, widgets, callbacks or lambda.  All GUI interactions are
invoked by simple function calls that return results.

@note:
WARNING about using EasyGui with IDLE

You may encounter problems using IDLE to run programs that use EasyGui. Try it
and find out.  EasyGui is a collection of Tkinter routines that run their own
event loops.  IDLE is also a Tkinter application, with its own event loop.  The
two may conflict, with unpredictable results. If you find that you have
problems, try running your EasyGui program outside of IDLE.

Note that EasyGui requires Tk release 8.0 or greater.

@note:
LICENSE INFORMATION

EasyGui version 0.96

Copyright (c) 2010, Stephen Raymond Ferg

All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

    1. Redistributions of source code must retain the above copyright notice,
       this list of conditions and the following disclaimer. 
    
    2. Redistributions in binary form must reproduce the above copyright notice,
       this list of conditions and the following disclaimer in the documentation and/or
       other materials provided with the distribution. 
    
    3. The name of the author may not be used to endorse or promote products derived
       from this software without specific prior written permission. 

THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

@note:
ABOUT THE EASYGUI LICENSE

This license is what is generally known as the "modified BSD license",
aka "revised BSD", "new BSD", "3-clause BSD".
See http://www.opensource.org/licenses/bsd-license.php

This license is GPL-compatible.
See http://en.wikipedia.org/wiki/License_compatibility
See http://www.gnu.org/licenses/license-list.html#GPLCompatibleLicenses

The BSD License is less restrictive than GPL.
It allows software released under the license to be incorporated into proprietary products. 
Works based on the software may be released under a proprietary license or as closed source software.
http://en.wikipedia.org/wiki/BSD_licenses#3-clause_license_.28.22New_BSD_License.22.29

   ynboxccboxboolboxindexboxmsgbox	buttonbox
integerboxmultenterboxenterboxexceptionbox	choiceboxcodeboxtextbox
diropenboxfileopenboxfilesaveboxpasswordboxmultpasswordboxmultchoiceboxabouteasygui	egversionegdemoEgStore    Ni TFi  )Image)ImageTk)*)StringIOc              G   s6   d d   |  D }  d j  |   }  t j j |   d  S)Nc             S   s   g  |  ] } t  |   q S )str).0argr   r   /Users/mwclarkson/Documents/School Work/Extra Stuff/Websites/Pi Webserver/2015/Python/Part 1 - KS3/Lesson 2 - Magic 8 Ball/Resources/easygui.py
<listcomp>   s   	 zwrite.<locals>.<listcomp> )joinsysstdoutwrite)argsr   r   r"   r(      s    r(   c              G   s   t  |    t j j  d  d  S)N
)r(   r&   r'   )r)   r   r   r"   writeln   s    
r+   g       @r   K   z


z
You are running Tk version: zJ
You must be using Tk version 8.0 or greater to use EasyGui.
Terminating.
c             C   s   d |  S)Nz"%s"r   )sr   r   r"   dq   s    r.   z+300+200MSSansSerifCourier
   	      ReturnzButton-1space z<

---------------------------------------------
Error: %s
%szShall I continue?r$   YesNoc             C   s   t  |  | | d | S)a~  
    Display a msgbox with choices of Yes and No.

    The default is "Yes".

    The returned value is calculated this way::
        if the first choice ("Yes") is chosen, or if the dialog is cancelled:
            return 1
        else:
            return 0

    If invoked without a msg argument, displays a generic request for a confirmation
    that the user wishes to continue.  So it can be used this way::
        if ynbox(): pass # continue
        else: sys.exit(0)  # exit the program

    @arg msg: the msg to be displayed.
    @arg title: the window title
    @arg choices: a list or tuple of the choices to be displayed
    image)r   )msgtitlechoicesr;   r   r   r"   r      s    ContinueCancelc             C   s   t  |  | | d | S)a  
    Display a msgbox with choices of Continue and Cancel.

    The default is "Continue".

    The returned value is calculated this way::
        if the first choice ("Continue") is chosen, or if the dialog is cancelled:
            return 1
        else:
            return 0

    If invoked without a msg argument, displays a generic request for a confirmation
    that the user wishes to continue.  So it can be used this way::

        if ccbox():
            pass # continue
        else:
            sys.exit(0)  # exit the program

    @arg msg: the msg to be displayed.
    @arg title: the window title
    @arg choices: a list or tuple of the choices to be displayed
    r;   )r   )r<   r=   r>   r;   r   r   r"   r      s    c          	   C   s=   t  d |  d | d | d |  } | | d k r5 d Sd Sd S)z
    Display a boolean msgbox.

    The default is the first choice.

    The returned value is calculated this way::
        if the first choice is chosen, or if the dialog is cancelled:
            returns 1
        else:
            returns 0
    r<   r>   r=   r;   r   r   N)r   )r<   r=   r>   r;   replyr   r   r"   r     s    ! c          	   C   sb   t  d |  d | d | d |  } d } x( | D]  } | d } | | k r. | Sq. Wt d   d S)	zf
    Display a buttonbox with the specified choices.
    Return the index of the choice selected.
    r<   r>   r=   r;   r   z@There is a program logic error in the EasyGui code for indexbox.N)r   AssertionError)r<   r=   r>   r;   rA   indexchoicer   r   r"   r   .  s    	!
 z(Your message goes here)OKc             C   sL   t  |  t  d  k r$ t d   t d |  d | d | g d | d |  S)z
    Display a messagebox
    rF   z4The 'ok_button' argument to msgbox must be a string.r<   r=   r>   r;   root)typerC   r   )r<   r=   	ok_buttonr;   rG   r   r   r"   r   C  s    Button1Button2Button3c             C   s  | d a  | r6 | j   t d |  a t j   n t   a t j   t j d t  t j |  t j d  t j	 t
  t j d d  t d t  } | j d t d t  d	 } | rt j j |  } t j j |  \ } }	 t j j |  r|	 j   d k r't d t d |  } qt r~y( t j |  }
 t j |
 d t } Wq|  t | d t   f 7}  YqXq|  t | d |	 d f 7}  n |  t | d f 7}  | rt d t  } | j d t d t  t | d | } | | _ | j d t d t d t  d d d d  t d t  a! t! j d t d t  t" | d |  d d } | j# d t$ t% f  | j d t d t d t  d d d d  t& |  t' j(   t j)   t j*   t j+   | r| j)   t  S)a;  
    Display a msg, a title, and a set of buttons.
    The buttons are defined by the members of the choices list.
    Return the text of the button that the user selected.

    @arg msg: the msg to be displayed.
    @arg title: the window title
    @arg choices: a list or tuple of the choices to be displayed
    r   masterWM_DELETE_WINDOWDialogi  d   sidefillN.gif.pgm.ppmfilezd
The Python Imaging Library (PIL) could not convert this file to a displayable image.

PIL reports:
z
I could not import the Python Imaging Library (PIL) to display the image.

You may need to install PIL
(http://www.pythonware.com/products/pil/)
to display z image files.z
Image file not found.r;   expandpadx1mpadytextwidthfont3m)rS   rT   rU   ),__replyButtonTextwithdrawToplevelboxRootTkprotocoldenyWindowManagerCloser=   iconnamegeometryrootWindowPositionminsizeFramepackTOPBOTHospathnormpathsplitextexistslower
PhotoImagePILisLoadedPILImageopen
PILImageTkImageErrorMsgexception_formatLabelr;   YESXbuttonsFrameMessage	configurePROPORTIONAL_FONT_FAMILYPROPORTIONAL_FONT_SIZE__put_buttons_in_buttonframe__firstWidgetfocus_force	deiconifymainloopdestroy)r<   r=   r>   r;   rG   messageFrametk_ImageimageFilenamejunkext	pil_Image
imageFramelabelmessageWidgetr   r   r"   r   P  sf    

	
			((




 
c   c       	      K   s  d | k r t  d d   d | k r8 t  d d   | d k r t |  t d  k r t  d	 d
 t t |   d   t |  t d  k r t  d	 d t t |   d   t |  t d  k r t  d	 d t t |   d   |  d k rd t |  d t |  }  x t |  | t |  d | d | } | d k rVd Sy t |  } Wn( t d t t |   d  w"Yn X| | k  rt d t |  d d  q"| | k rt d t |  d d  q"| SWd S)a  
    Show a box in which a user can enter an integer.

    In addition to arguments for msg and title, this function accepts
    integer arguments for "default", "lowerbound", and "upperbound".

    The default argument may be None.

    When the user enters some text, the text is checked to verify that it
    can be converted to an integer between the lowerbound and upperbound.

    If it can be, the integer (not the text) is returned.

    If it cannot, then an error msg is displayed, and the integerbox is
    redisplayed.

    If the user cancels the operation, None is returned.

    NOTE that the "argLowerBound" and "argUpperBound" arguments are no longer
    supported.  They have been replaced by "upperbound" and "lowerbound".
    ZargLowerBoundz=
integerbox no longer supports the 'argLowerBound' argument.
zUse 'lowerbound' instead.

ZargUpperBoundz=
integerbox no longer supports the 'argUpperBound' argument.
zUse 'upperbound' instead.

r8   r   z,integerbox received a non-integer value for zdefault of Errorzlowerbound of zupperbound of zEnter an integer between z and r;   rG   Nz2The value that you entered:
	%s
is not an integer.z;The value that you entered is less than the lower bound of .z>The value that you entered is greater than the upper bound of )rC   rH   r.   r   r
   intr   )	r<   r=   defaultZ
lowerboundZ
upperboundr;   rG   ZinvalidKeywordArgumentsrA   r   r   r"   r     sN    

   $ zFill in values for the fields.c             C   s   t  |  | | | d  S)a  
    Show screen with multiple data entry fields.

    If there are fewer values than names, the list of values is padded with
    empty strings until the number of values is the same as the number of names.

    If there are more values than names, the list of values
    is truncated so that there are as many values as names.

    Returns a list of the values of the fields,
    or None if the user cancels the operation.

    Here is some example code, that shows how values returned from
    multenterbox can be checked for validity before they are accepted::
        ----------------------------------------------------------------------
        msg = "Enter your personal information"
        title = "Credit Card Application"
        fieldNames = ["Name","Street Address","City","State","ZipCode"]
        fieldValues = []  # we start with blanks for the values
        fieldValues = multenterbox(msg,title, fieldNames)

        # make sure that none of the fields was left blank
        while 1:
            if fieldValues == None: break
            errmsg = ""
            for i in range(len(fieldNames)):
                if fieldValues[i].strip() == "":
                    errmsg += ('"%s" is a required field.\n\n' % fieldNames[i])
            if errmsg == "":
                break # no problems found
            fieldValues = multenterbox(errmsg, title, fieldNames, fieldValues)

        writeln("Reply was: %s" % str(fieldValues))
        ----------------------------------------------------------------------

    @arg msg: the msg to be displayed.
    @arg title: the window title
    @arg fields: a list of fieldnames.
    @arg values:  a list of field values
    N)__multfillablebox)r<   r=   fieldsvaluesr   r   r"   r	     s    -c             C   s   t  |  | | | d  S)aU  
    Same interface as multenterbox.  But in multpassword box,
    the last of the fields is assumed to be a password, and
    is masked with asterisks.

    Example
    =======

    Here is some example code, that shows how values returned from
    multpasswordbox can be checked for validity before they are accepted::
        msg = "Enter logon information"
        title = "Demo of multpasswordbox"
        fieldNames = ["Server ID", "User ID", "Password"]
        fieldValues = []  # we start with blanks for the values
        fieldValues = multpasswordbox(msg,title, fieldNames)

        # make sure that none of the fields was left blank
        while 1:
            if fieldValues == None: break
            errmsg = ""
            for i in range(len(fieldNames)):
                if fieldValues[i].strip() == "":
                    errmsg = errmsg + ('"%s" is a required field.\n\n' % fieldNames[i])
                if errmsg == "": break # no problems found
            fieldValues = multpasswordbox(errmsg, title, fieldNames, fieldValues)

        writeln("Reply was: %s" % str(fieldValues))
    r   )r   )r<   r=   r   r   r   r   r"   r   @  s    !c             C   sD   |  j  d t  |  j  d t  |  j  d t  |  j  d t  d  S)Nz<Down>z<Up>z<Right>z<Left>)bindtabRighttabLeft)widgetr   r   r"   
bindArrowsc  s    r   c             C   s   t  j d  d  S)Nz<Tab>)rb   event_generate)eventr   r   r"   r   j  s    r   c             C   s   t  j d  d  S)Nz<Shift-Tab>)rb   r   )r   r   r   r"   r   m  s    r   c             C   s+  d d g } t  |  d k r" d  St | d  d    } t | d  d    } t  |  t  |  k ri n] t  |  t  |  k r | d t  |   } n, x) t  |  t  |  k  r | j d  q Wt   a t j d t  t j |  t j d  t j	 t
  t j d t  t d t  } | j d	 t d
 t  t | d d d |  } | j d t t f  | j d	 t d d d
 t d d d d  g  a t  |  d } x4t t  |   D] }	 | |	 }
 | |	 } t d t  } | j d	 t d
 t  t | d |
 } | j d	 t  t | d d d d a t j t  t j d t t f  t j d	 t d d  t t  t j d t  t j d t  |	 | k r| rt |	 j d |  t |	 j d |  |	 d 7}	 qWt d t  } | j d	 t  d
 t  t! | d d d d a" t t"  t" j d d d	 t d d d d d d d d  t" } t } x" t# D] } | j d | |  qfWt! | d d d d a$ t t$  t$ j d d d	 t d d d d d d d d  t$ } t } x" t# D] } | j d | |  qWt d j%   t j&   t j'   t( S)NrF   r@   r   r8   rN   rO   z<Escape>rM   rQ   rR   r\   z4.5ir[   r]   rW   r   rX   r^   rZ   (   highlightthickness   z<Return>show	takefocusipadx2mipadyrY   z<%s>))lenlistappendrc   rb   rd   re   r=   rf   rg   rh   r   __multenterboxCancelrj   rk   rl   rm   r   r   r   r   RIGHTentryWidgetsranger{   LEFTEntryentryWidgetTEXT_ENTRY_FONT_SIZEr   __multenterboxGetTextinsertBOTTOMButtonokButtonSTANDARD_SELECTION_EVENTScancelButtonr   r   r   __multenterboxText)r<   r=   r   r   maskr>   r   r   ZlastWidgetIndexZwidgetIndexZargFieldNameZargFieldValue
entryFrameZlabelWidgetr~   commandButtonhandlerselectionEventr   r   r"   r   s  s~      	(



.
.

r   c             C   s8   g  a  x! t D] } t  j | j    q Wt j   d  S)N)r   r   r   getrb   quit)r   r   r   r   r"   r     s    r   c             C   s   d  a  t j   d  S)N)r   rb   r   )r   r   r   r"   r     s    r   zEnter something.c             C   sC   t  |  | d | d d d | d | } | r? | r? | j   } | S)a8  
    Show a box in which a user can enter some text.

    You may optionally specify some default text, which will appear in the
    enterbox when it is displayed.

    Returns the text that the user entered, or None if he cancels the operation.

    By default, enterbox strips its result (i.e. removes leading and trailing
    whitespace).  (If you want it not to strip, use keyword argument: strip=False.)
    This makes it easier to test the results of the call::

        reply = enterbox(....)
        if reply:
            ...
        else:
            ...
    r   r   Nr;   rG   )__fillableboxstrip)r<   r=   r   r   r;   rG   resultr   r   r"   r
     s    'zEnter your password.c          
   C   s"   t  |  | | d d d | d | S)z
    Show a box in which a user can enter a password.
    The text is masked with asterisks, so the password is not displayed.
    Returns the text that the user entered, or None if he cancels the operation.
    r   r   r;   rG   )r   )r<   r=   r   r;   rG   r   r   r"   r     s    c             C   s  | d k r | d k | d k r( d } | a  t  a | r` | j   t d |  a t j   n t   a t j   t j d t  t j |  t j	 d  t j
 t  t j d t  t d t  } | j d t d t  d } | rt j j |  } t j j |  \ }	 }
 t j j |  r|
 j   d' k rQt d t d |  } qt ry( t j |  } t j | d t } Wq|  t | d t   f 7}  YqXq|  t | d |
 d f 7}  n |  t | d f 7}  | rIt d t  } | j d t d t  t | d | } | | _  | j d t d t! d t" d d d d  t d t  } | j d t d t  t d t  } | j d t d t  t d t  } | j d t d t  t# | d d d |  } | j$ d t% t& f  | j d t' d d d t d d d d  t( | d d a) t* t)  t) j$ d t% t+ f  | rVt) j$ d |  t) j d t, d d  t) j d t-  t) j d t  t) j. d t   t/ | d  d d d! a0 t* t0  t0 j d d d t, d d d d d" d# d$ d  t0 } t- } x" t1 D] } | j d% | |  qWt/ | d  d d d& a2 t* t2  t2 j d d d t' d d d d d" d# d$ d  t2 } t } x" t1 D] } | j d% | |  qWt) j3   t j4   t j5   | r| j4   t j6   t S)(z
    Show a box in which a user can enter some text.
    You may optionally specify some default text, which will appear in the
    enterbox when it is displayed.
    Returns the text that the user entered, or None if he cancels the operation.
    Nr8   rM   rN   rO   z<Escape>rQ   rR   .gif.pgm.ppmrV   zd
The Python Imaging Library (PIL) could not convert this file to a displayable image.

PIL reports:
z
I could not import the Python Imaging Library (PIL) to display the image.

You may need to install PIL
(http://www.pythonware.com/products/pil/)
to display z image files.z
Image file not found.r;   rW   rX   rY   rZ   r\   z4.5ir[   r]   r   r^   r   r   z<Return>r   r   rF   r   r   r   z<%s>r@   )r   r   r   )7__enterboxDefaultText__enterboxTextr`   ra   rb   rc   rd   re   r=   rf   rg   rh   r   __enterboxCancelrj   rk   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r;   r|   r}   r   r   r   r   r   r   r   r   r   r   __enterboxGetTextr   r   r   r   r   r   r   r   r   )r<   r=   r   r   r;   rG   r   r   r   r   r   r   r   r   r~   r   r   r   r   r   r   r   r"   r   "  s     
 
	
			((

.
.


 

r   c             C   s   t  j   a t j   d  S)N)r   r   r   rb   r   )r   r   r   r"   r     s    r   c             C   s0   t  j d t t  j     t  j d t  d  S)Nr   )r   deleter   r   r   r   )r   r   r   r"   __enterboxRestore  s    r   c             C   s   d  a  t j   d  S)N)r   rb   r   )r   r   r   r"   r     s    r   c              C   s+   t    }  |  j   |  j   |  j   d S)z% don't allow WindowManager close
    N)rc   r`   bellr   )xr   r   r"   re     s    	

re   zPick as many items as you like.c             K   s1   t  |  d k r d g } d a t |  | |  S)aw  
    Present the user with a list of choices.
    allow him to select multiple items and return them in a list.
    if the user doesn't choose anything from the list, return the empty list.
    return None if he cancelled selection.

    @arg msg: the msg to be displayed.
    @arg title: the window title
    @arg choices: a list or tuple of the choices to be displayed
    r   z0Program logic error - no choices were specified.r   )r   __choiceboxMultipleSelect__choicebox)r<   r=   r>   kwargsr   r   r"   r     s     	zPick something.c             C   s1   t  |  d k r d g } d a t |  | |  S)a  
    Present the user with a list of choices.
    return the choice that he selects.
    return None if he cancels the selection selection.

    @arg msg: the msg to be displayed.
    @arg title: the window title
    @arg choices: a list or tuple of the choices to be displayed
    r   z0Program logic error - no choices were specified.)r   r   r   )r<   r=   r>   r   r   r"   r     s     	c             C   s  t  | d d   } t |  d k r1 d g } d d g } x. t t |   D] } t | |  | | <qP Wt t |  d  } d } | d k r d } d a t   a t j d t	  t j
   } t j   } t | d	  } t | d
  }	 t | d  }
 t | d  } t j |  t j d  d } t j |  t t _ t j | |	  d t |
  d t |  } t j |  t d t  } | j d t d t d t  t |  } | j d t d t d t  t |  } | j d t d t d d  t d t  } | j d t d t d t  t | d t d |  d t | d  } | j d t t  f  | j d t d t d t d d d d  t! | d | d d d d d  d! a" t# rt" j d" t$  t" j d t t  f  t% | d# t& d$ t" j' } t" j d% | j(  t% | d# t) d$ t" j* } t" j d& | j(  | j d t d t  | j d t d t+  t" j d t d d d d d t d t  x. t t |   D] } t | |  | | <qWt, r| j- d' t j.  n | j- d( d)    d } g  a/ x@ | D]8 } | | k rqt" j0 t1 |  t/ j2 |  | } qWt j3 d* t4  t |  d k rt5 | d+ t d d d d, d d- } t6 |  | j d t d t d d. d d d/ d d0 d.  | } t7 } x" t8 D] } | j3 d1 | |  qWt" j3 d2 t7  t" j3 d3 t7  n  t" j3 d2 t9  t" j3 d3 t9  t5 | d+ t d d d d, d d- } t6 |  | j d t d t d d. d d d/ d d0 d.  | } t9 } x" t8 D] } | j3 d1 | |  qWt |  d k rt# rt |  } | j d t d t+ d t  t5 | d d4 d d, d d- } t6 |  | j3 d5 t:  | j d t d t d d. d d d/ d d0 d.  t5 | d d6 d d, d d- } t6 |  | j3 d5 t;  | j d t d t d d. d d d/ d d0 d.  t j3 d7 t9  t" j< d  t" j=   t j>   t j?   t S)8zE
    internal routine to support choicebox() and multchoicebox()
    Nr   z0Program logic error - no choices were specified.rF   r@      r8   rN   g?g      ?g?g?rO   z+0+0+rM   rQ   rR   rW   rZ   anchorr[   r\   g?r]   rX   rY   heightborderwidthreliefflatbgwhite
selectmodeorientcommandyscrollcommandxscrollcommandkeyc             S   s   t  |  j   | j    S)N)cmprs   )r   yr   r   r"   <lambda>q  s    z__choicebox.<locals>.<lambda>z	<Any-Key>r   r      r   r   r   z<%s>z<Return>z<Double-Button-1>z
Select Allz
<Button-1>z	Clear Allz<Escape>)@r   r   r   r   min__choiceboxResultsrc   rb   rd   re   winfo_screenwidthwinfo_screenheightr   r=   rf   rg   NOrW   ri   rj   rk   rl   r}   r   r|   r   r   rm   r   NWr   r   r   ListboxchoiceboxWidgetr   MULTIPLE	ScrollbarVERTICALyviewset
HORIZONTALxviewYrunningPython3sortrs   choiceboxChoicesr   ENDr   r   KeyboardListenerr   r   __choiceboxGetChoicer   __choiceboxCancel__choiceboxSelectAll__choiceboxClearAll
select_setr   r   r   )r<   r=   r>   ZdefaultButtonsrD   Zlines_to_showscreen_widthscreen_height
root_widthroot_height	root_xpos	root_yposrh   message_and_buttonsFramer   r~   ZchoiceboxFramer   rightScrollbarbottomScrollbarZlastInsertedrE   r   r   r   r   r   ZselectionButtonsFrameZselectAllButtonZclearAllButtonr   r   r"   r     s    	 		((		( 
$
.$
.
.
.


r   c             C   sK   t  r" d d   t j   D a n t j   } t j |  a t j   d  S)Nc             S   s   g  |  ] } t  j |   q Sr   )r   r   )r    rD   r   r   r"   r#     s   	 z(__choiceboxGetChoice.<locals>.<listcomp>)r   r   curselectionr   r   rb   r   )r   Zchoice_indexr   r   r"   r     s
    r   c             C   s   t  j d t t  d  d  S)Nr   r   )r   selection_setr   r   )r   r   r   r"   r     s    r   c             C   s   t  j d t t  d  d  S)Nr   r   )r   selection_clearr   r   )r   r   r   r"   r     s    r   c             C   s   d  a  t j   d  S)N)r   rb   r   )r   r   r   r"   r     s    r   c             C   s  |  j  } t |  d k r| t j k ry t t j   d  } Wn t k
 r^ d } Yn Xt j d d  xt	 | d t t
   D]M } t
 | } | d j   | j   k r t j d |  t j |  d  Sq Wxa t	 t t
   D]M } t
 | } | d j   | j   k r t j d |  t j |  d  Sq Wx t	 t t
   D]p } t
 | } | d j   | j   k rQ| d k rt j d | d  n t j d d  t j |  d  SqQWt t
  d } t j d |  t j |  d  Sd  S)Nr   r   endfirstrB   )keysymr   string	printabler   r   r
  
IndexErrorr  r   r   rs   r  see)r   r   Zstart_nnitemZ	lastIndexr   r   r"   r     s@    	 


r   c               C   s:   d j  t j t j   d t j   d t j   d   S)zD
    Convert exception info into a string suitable for display.
    r8   r   r   r   )r%   	tracebackformat_exceptionr&   exc_infor   r   r   r"   rz     s    rz   c             C   s;   | d k r d } |  d k r$ d }  t  |  | t    d S)a^  
    Display a box that gives information about
    an exception that has just been raised.

    The caller may optionally pass in a title for the window, or a
    msg to accompany the error information.

    Note that you do not need to (and cannot) pass an exception object
    as an argument.  The latest exception will automatically be used.
    NzError Reportz1An error (exception) has occurred in the program.)r   rz   )r<   r=   r   r   r"   r      s
     c             C   s   t  |  | | d d S)a  
    Display some text in a monospaced font, with no line wrapping.
    This function is suitable for displaying code and text that is
    formatted using spaces.

    The text parameter should be a string, or a list or tuple of lines to be
    displayed in the textbox.
    r   r   )r   )r<   r=   r[   r   r   r"   r   5  s    c             C   s  |  d k r d }  | d k r$ d } d g } | d a  t   a t j d t  t j   } t j   } t | d  } t | d  } t | d  }	 t | d	  }
 t j |  t j	 d
  d a
 t j t
  t t _ t j | |  d t |	  d t |
  a
 t j t
  t d t  } | j d t d t d t  t | d d } | j d t d t d t  t |  } | j d t d t d t  t |  } | j d t d t d t  t |  a t j d t d t  | rKt | d t  } t | d d d | d d d d } | j d t  | j d t t f  n^ t | d t  } t | d d d | d d d d } | j d t  | j d t  t! f  | j" d | j# d t$   | j" d | j# d; t$   | j" d  | j% d t$   | j" d! | j% d< t$   | j" d" | j# d t&   | j" d# | j# d= t&   t' | d$ t( d% | j) } | j d& | j*  t' | d$ t+ d% | j, } | j d' | j*  | r| j d t d t  | j d t d t-  | j d t d t d t  t. | d( t/ d) |  d t | d*  } | j d t  t! f  | j d t d t d t d d d d  t0 t d+ t d) d d d d d, } | j d t d t d d d d d- d d. d  | } t1 } x+ d/ d0 d1 g D] } | j" d2 | |  qWy{ t2 |  t2 d3  k rnI y d j3 |  } Wn3 t4 d4 t t2 |   d5  t5 j6 d6  Yn X| j7 t8 | d7  Wn t4 d8  t5 j6 d6  Yn Xy | j9   Wn t4 d9  t5 j6 d6  Yn Xt j:   | j; d: t8  } t j<   | S)>a  
    Display some text in a proportional font with line wrapping at word breaks.
    This function is suitable for displaying general written text.

    The text parameter should be a string, or a list or tuple of lines to be
    displayed in the textbox.
    Nr8   rF   r   rN   g?g      ?g?g?rO   z+0+0r   rM   rQ   rR   rW   r      g333333?r      r\   rX   r   rZ   rY   wrapr]   z<Next>r   z<Prior>z<Right>z<Left>z<Down>z<Up>r   r   r   r   r   r[   g?r   r   r   r   r6   zButton-1ZEscapez<%s>abcz!Exception when trying to convert z to text in textArea   normalz+Exception when trying to load the textArea.z/Exception when trying to put focus on okButton.g        rB   rB   rB   )=r_   rc   rb   rd   re   r   r   r   r=   rf   rh   rg   r   rW   ri   r   rj   rk   rl   rm   r|   r   r}   r   r~   r   MONOSPACE_FONT_SIZETextr   NONEMONOSPACE_FONT_FAMILYWORDr   r   r   yview_scrollPAGESxview_scrollUNITSr   r   r   r   r   r   r   r   r   r   __textboxOKrH   r%   r   r&   exitr   r   r   r   r   r   )r<   r=   r[   r   r>   r  r  r  r  r  r  Z	mainframeZtextboxFramer  r   Zcharacter_widthZtextArear  r	  r   r   r   r   r   ZareaTextr   r   r"   r   F  s      	
		$		(($. 



c             C   s   t  j   d  S)N)rb   r   )r   r   r   r"   r(    s    r(  c          	   C   sv   t  |  |  } t   } | j   | s. d } t j d | d | d | d d  } | j   | sf d St j j |  S)a:  
    A dialog to get a directory name.
    Note that the msg argument, if specified, is ignored.

    Returns the name of a directory, or None if user chose to cancel.

    If the "default" argument specifies a directory name, and that
    directory exists, then the dialog box will start with that directory.
    Nparentr=   
initialdirinitialfile)	getFileDialogTitlerc   r`   tk_FileDialogaskdirectoryr   rn   ro   rp   )r<   r=   r   	localRootfr   r   r"   r     s    	
 		
 c             C   sL   |  r | r d | |  f S|  r1 | r1 t  |   S| rH |  rH t  |  Sd  S)Nz%s - %s)r   )r<   r=   r   r   r"   r-    s      
 
r-  c               @   sd   e  Z d  Z d d   Z d d   Z d d   Z d d   Z d	 d
   Z d d   Z d d   Z	 d S)FileTypeObjectc             C   s   t  |  d k r t d   g  |  _ t |  t d  k rO |  j |  nz t |  t g   k r t  |  d k  r t d d |   q | d	 |  _ t | d  d
   |  _ n t d |   d  S)Nr   zFiletype argument is empty.r  r   zInvalid filemask.
z'List contains less than 2 members: "%s"r   zInvalid filemask: "%s"rB   rB   )r   rC   masksrH   initializeFromStringnamer   )selffilemaskr   r   r"   __init__  s    	zFileTypeObject.__init__c             C   s   |  j  | j  k r d Sd S)NTF)r5  )r6  otherr   r   r"   __eq__0  s     zFileTypeObject.__eq__c             C   s:   x3 | j  D]( } | |  j  k r" q
 |  j  j |  q
 Wd  S)N)r3  r   )r6  r9  r   r   r   r"   add4  s     zFileTypeObject.addc             C   s   |  j  t |  j  f S)N)r5  tupler3  )r6  r   r   r"   toTuple9  s    zFileTypeObject.toTuplec             C   s   |  j  d k r d Sd S)Nz	All filesTF)r5  )r6  r   r   r"   isAll<  s     zFileTypeObject.isAllc             C   so   t  j j |  d |  _ |  j d k r1 d |  _ |  j d k rI d |  _ |  j   |  _ d |  j g |  _ d  S)Nr   r8   z.*r   r   )rn   ro   rq   r   getNamer5  r3  )r6  r7  r   r   r"   r4  @  s     	 	z#FileTypeObject.initializeFromStringc             C   s   |  j  } | d k r d S| d k r) d S| d k r9 d S| d k rI d S| d k rY d	 S| j d
  r | d d   j   d S| j   d S)Nz.*z	All filesz.txtz
Text filesz.pyzPython filesz.pycz.xlszExcel filesr   r   z files)r   
startswithupper)r6  er   r   r"   r?  H  s    	     zFileTypeObject.getNameN)
__name__
__module____qualname__r8  r:  r;  r=  r>  r4  r?  r   r   r   r"   r2    s   r2  c       	      C   s   t    } | j   t | |  \ } } } } | j d  d k  ra | j d  d k  ra d } n | d k rs d } t j d | d t |  |  d | d | d	 |  } | j   | s d St j	 j
 |  S)
aO  
    A dialog to get a file name.

    About the "default" argument
    ============================
        The "default" argument specifies a filepath that (normally)
        contains one or more wildcards.
        fileopenbox will display only files that match the default filepath.
        If omitted, defaults to "*" (all files in the current directory).

        WINDOWS EXAMPLE::
            ...default="c:/myjunk/*.py"
        will open in directory c:\myjunk\ and show all Python files.

        WINDOWS EXAMPLE::
            ...default="c:/myjunk/test*.py"
        will open in directory c:\myjunk\ and show all Python files
        whose names begin with "test".


        Note that on Windows, fileopenbox automatically changes the path
        separator to the Windows path separator (backslash).

    About the "filetypes" argument
    ==============================
        If specified, it should contain a list of items,
        where each item is either::
            - a string containing a filemask          # e.g. "*.txt"
            - a list of strings, where all of the strings except the last one
                are filemasks (each beginning with "*.",
                such as "*.txt" for text files, "*.py" for Python files, etc.).
                and the last string contains a filetype description

        EXAMPLE::
            filetypes = ["*.css", ["*.htm", "*.html", "HTML files"]  ]

    NOTE THAT
    =========

        If the filetypes list does not contain ("All files","*"),
        it will be added.

        If the filetypes list does not contain a filemask that includes
        the extension of the "default" argument, it will be added.
        For example, if     default="*abc.py"
        and no filetypes argument was specified, then
        "*.py" will automatically be added to the filetypes argument.

    @rtype: string or None
    @return: the name of a file, or None if user chose to cancel

    @arg msg: the msg to be displayed.
    @arg title: the window title
    @arg default: filepath with wildcards
    @arg filetypes: filemasks that a user can choose, e.g. "*.txt"
    r   r   ?Nr*  r=   r+  r,  	filetypes)rc   r`   fileboxSetupfindr.  askopenfilenamer-  r   rn   ro   rp   )	r<   r=   r   rG  r0  initialbaser,  r+  r1  r   r   r"   r   W  s     =	
*		
 c       	      C   s   t    } | j   t | |  \ } } } } t j d | d t |  |  d | d | d |  } | j   | su d St j j	 |  S)a  
    A file to get the name of a file to save.
    Returns the name of a file, or None if user chose to cancel.

    The "default" argument should contain a filename (i.e. the
    current name of the file to be saved).  It may also be empty,
    or contain a filemask that includes wildcards.

    The "filetypes" argument works like the "filetypes" argument to
    fileopenbox.
    r*  r=   r,  r+  rG  N)
rc   r`   rH  r.  asksaveasfilenamer-  r   rn   ro   rp   )	r<   r=   r   rG  r0  rK  r,  r+  r1  r   r   r"   r     s    	
	
 c             C   s  |  s t  j j d d  }  t  j j |   \ } } | s? d } | sK d } t  j j |  \ } } t |  } t d  } d } | s g  } g  }	 xU | D]M }
 t |
  } | j   r d } | | k r | j |  q |	 j |  q W| r n | | k rn |	 j	 d |  t
 |	  d k r2|	 j |  | |	 d |	 d	 f k rOn& t re|	 j |  n |	 j	 d |  d d   |	 D } | | | | f S)
Nr   r   FTr   r   c             S   s   g  |  ] } | j     q Sr   )r=  )r    ftor   r   r"   r#     s   	 z fileboxSetup.<locals>.<listcomp>rB   )rn   ro   r%   splitrq   r2  r>  r;  r   r   r   runningPython26)r   rG  r+  r,  rK  Z
initialextZinitialFileTypeObjectZallFileTypeObjectZALL_filetypes_was_specifiedZfiletypeObjectsr7  rM  r   r   r"   rH    sF        rH  c             C   s   t  |  j a t j   d S)zJ
    Handle an event that is generated by a person clicking a button.
    N)__widgetTextsr   r_   rb   r   )r   r   r   r"   __buttonEvent  s    rQ  c             C   s   d a  i  a d } x |  D] } t t d d d | } t |  | j d t d t d d	 d
 d	 d d d d	  | t | <| d k r | a  d } | } t } x" t	 D] } | j
 d | |  q Wq Wd S)z)Put the buttons in the buttons frame
    Nr   r   r   r[   rW   rQ   rX   rY   rZ   r   r   r   z<%s>)r   rP  r   r~   r   rk   r|   r   rQ  r   r   )r>   iZ
buttonTextZ
tempButtonr   r   r   r   r   r"   r     s    
.
r   c               @   sR   e  Z d  Z d Z d d   Z d d   Z d d   Z d d	   Z d
 d   Z d S)r   a  
A class to support persistent storage.

You can use EgStore to support the storage and retrieval
of user settings for an EasyGui application.


# Example A
#-----------------------------------------------------------------------
# define a class named Settings as a subclass of EgStore
#-----------------------------------------------------------------------
class Settings(EgStore):
::
    def __init__(self, filename):  # filename is required
        #-------------------------------------------------
        # Specify default/initial values for variables that
        # this particular application wants to remember.
        #-------------------------------------------------
        self.userId = ""
        self.targetServer = ""

        #-------------------------------------------------
        # For subclasses of EgStore, these must be
        # the last two statements in  __init__
        #-------------------------------------------------
        self.filename = filename  # this is required
        self.restore()            # restore values from the storage file if possible



# Example B
#-----------------------------------------------------------------------
# create settings, a persistent Settings object
#-----------------------------------------------------------------------
settingsFile = "myApp_settings.txt"
settings = Settings(settingsFile)

user    = "obama_barak"
server  = "whitehouse1"
settings.userId = user
settings.targetServer = server
settings.store()    # persist the settings

# run code that gets a new value for userId, and persist the settings
user    = "biden_joe"
settings.userId = user
settings.store()


# Example C
#-----------------------------------------------------------------------
# recover the Settings instance, change an attribute, and store it again.
#-----------------------------------------------------------------------
settings = Settings(settingsFile)
settings.userId = "vanrossum_g"
settings.store()

c             C   s   d  |  _  t    d  S)N)filenameNotImplementedError)r6  rS  r   r   r"   r8  {  s    	zEgStore.__init__c          
   C   s   t  j j |  j  s |  St  j j |  j  s2 |  Syx t |  j d  } t j |  } | j   xF t	 |  j
 j    D]/ } |  j
 | } | j
 j | |  |  j
 | <qv WWn Yn X|  S)ay  
        Set the values of whatever attributes are recoverable
        from the pickle file.

        Populate the attributes (the __dict__) of the EgStore object
        from     the attributes (the __dict__) of the pickled object.

        If the pickled object has attributes that have been initialized
        in the EgStore object, then those attributes of the EgStore object
        will be replaced by the values of the corresponding attributes
        in the pickled object.

        If the pickled object is missing some attributes that have
        been initialized in the EgStore object, then those attributes
        of the EgStore object will retain the values that they were
        initialized with.

        If the pickled object has some attributes that were not
        initialized in the EgStore object, then those attributes
        will be ignored.

        IN SUMMARY:

        After the recover() operation, the EgStore object will have all,
        and only, the attributes that it had when it was initialized.

        Where possible, those attributes will have values recovered
        from the pickled object.
        rb)rn   ro   rr   rS  isfilerw   pickleloadcloser   __dict__keysr   )r6  r1  ZunpickledObjectr   r   r   r   r"   restore  s      
$zEgStore.restorec             C   s0   t  |  j d  } t j |  |  | j   d S)z
        Save the attributes of the EgStore object to a pickle file.
        Note that if the directory for the pickle file does not already exist,
        the store operation will fail.
        wbN)rw   rS  rW  dumprY  )r6  r1  r   r   r"   store  s    zEgStore.storec             C   s)   t  j j |  j  r% t  j |  j  d S)zM
        Delete my persistent file (i.e. pickle file), if it exists.
        N)rn   ro   rV  rS  remove)r6  r   r   r"   kill  s    zEgStore.killc             C   s   d } g  } x9 |  j  j   D]( } | j |  t | t |   } q W| j   g  } xG | D]? } |  j  | } | j |  } | j d | t |  f  q_ Wd j |  S)zK
        return my contents as a string in an easy-to-read format.
        r   z%s : %s
r8   )	rZ  r[  r   maxr   r   ljustreprr%   )r6  Zlongest_key_lengthr[  r   linesvaluer   r   r"   __str__  s    
!zEgStore.__str__N)	rC  rD  rE  __doc__r8  r\  r_  ra  rg  r   r   r   r"   r   @  s   :.c              C   s  t  d d  d d t j d t d t t  }  xnd d d	 d
 d d d d d d d d d d d d d d d d d d d g } t d |  d d  t d! |  } | s d" S| j   } | d# d k r t d$ d%  } t  d& t	 |   q8 | d# d' k r
t
   } q8 | d# d( k r$t   q8 | d# d k rt   } t  d& t	 |   d) } d* } t d | d | d! |  } t  d& t	 |   q8 | d# d+ k rt   q8 | d# d k rt   } t  d& t	 |   q8 | d# d k rsd, } d- } t | d. d/  } t  d& t	 |   d0 } t | d. d/ d1 d2 } t  d& t	 |   t d3 d4  } t  d& t	 |   q8 | d# d5 k rd, } d6 } t | d7 d8 | } t  d& t	 |   q8 | d# d k ry d9 d# } Wqt   YqXq8 | d# d k rPt d: d; d< d= d>  } t  d& t	 |   t d? d@  } t  d& t	 |   q8 | d# d k rjt   q8 | d# d k rt   q8 | d# d k rt   q8 | d# d k r| d# } dA | d# } dB dC dD dE g } t | | |  } t  d& t	 |   q8 | d# d k ret dF dG dH  } t  d& t |   t dI dG dH dJ  } t  d& t |   q8 | d# d k rFdK } dL } dM dN dO dP dQ g }	 g  }
 t | | |	  }
 x~ |
 d" k rPdR } xB t t |	   D]. } |
 | j   dR k r| dS |	 | } qW| dR k rPt | | |	 |
  }
 qWt  d& t |
   q8 | d# d k r!dT } dU } dV dW dX g }	 g  }
 t | | |	  }
 x~ |
 d" k rPdR } xB t t |	   D]. } |
 | j   dR k r| dS |	 | } qW| dR k rPt | | |	 |
  }
 qWt  d& t |
   q8 | d# d k rvdY } dZ } t | |  } t  d& t	 |   | rt d[ d\  q8 | d# d k rd] } t | |  } t  d& t	 |   q8 | d# d
 k rd^ } d_ d` } da db dc dd de | de df dg dh di dj dk dl dm dn da do dp dq dr ds dt du dv g } dw dx dy dz d{ } t d | d! |  } t  d& t	 |   dw } t d | d | d! |  } t  d& t	 |   dw } t d d| d! g   } t  d& t	 |   q8 | d# d k rGde df dg dh di dj dk dl dm dn da do dp dq dr ds dt du dv g } d} } t | d~ |  } t  d& t	 |   q8 | d# d k rht | d#  q8 | d# d k rt  | d#  q8 t d | d d  d" Sq8 Wd" S)z
    Run the EasyGui demo.
    r*   rP   z,Pick the kind of box that you wish to demo.
z
 * Python version z
 * EasyGui version z
 * Tk version r   r   z6buttonbox(image) -- a buttonbox that displays an imager   r   r   r   r   r
   z5enterbox(image) -- an enterbox that displays an imager   r   r   r   r   r   r   r   r	   r   r   zAbout EasyGuiz Helpr<   r=   zEasyGui r>   Nr   z	short msgzThis is a long titlezReply was: %sZAboutHelpz*Demo of Buttonbox with many, many buttons!zDThis buttonbox shows what happens when you specify too many buttons.zbuttonbox(image)zpython_and_check_logo.gifz>Enter the name of your best friend.
(Result will be stripped.)zLove!z     Suzy Smith     zBEnter the name of your best friend.
(Result will NOT be stripped.)r   Fz#Enter the name of your worst enemy:zHate!zenterbox(image)zWhat kind of snake is this?ZQuizr;   r   z Enter a number between 3 and 333z%Demo: integerbox WITH a default value   r  iM  zEnter a number between 0 and 99z(Demo: integerbox WITHOUT a default valuezDemo of ZChoice1ZChoice2ZChoice3ZChoice4z$Demo of password box WITHOUT defaultz

Enter your secret passwordzMember Logonz!Demo of password box WITH defaultZalfiezEnter your personal informationzCredit Card ApplicationNamezStreet AddressZCityZStateZZipCoder8   z"%s" is a required field.

zEnter logon informationzDemo of multpasswordboxz	Server IDzUser IDZPasswordzDemo of ynboxz+Were you expecting the Spanish Inquisition?z'NOBODY expects the Spanish Inquisition!zWrong!zDemo of ccboxzDemo of choiceboxzQThis is an example of a very long option which you may or may not wish to choose.r   ZnnnZdddZeeeZfffZaaabbbcccZgggZhhhZiiiZjjjZkkkZLLLZmmmZoooZpppZqqqZrrrZsssZtttZuuuZvvvzPick something. zA wrapable sentence of text ?!    z
A separate line of text.r   zThe list of choices is empty!z!Pick as many choices as you wish.zDemo of multchoiceboxzChoice

z

is not recognizedzProgram Logic Error)!r+   r&   versionr   r   	TkVersionr   rN  r   rd  r   
_demo_helpr   _demo_buttonbox_with_imager   r
   r   r   _demo_diropenbox_demo_fileopenbox_demo_filesaveboxr   r   r	   r   r   r   r   r   r   r   _demo_textbox_demo_codebox)Zintro_messager>   rE   rA   r=   r<   r;   messageZ#thisWillCauseADivideByZeroExceptionZ
fieldNamesZfieldValueserrmsgrR  Z
longchoiceZlistChoicesr   r   r"   r     sX   '	
	 
	
		 
 
 

    
?  c             C   sL   d d d d } d } d d } t  | | |  }  t d t |    d  S)	NzIt 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!    z

r3   zDemo of textboxzHere is some sample text. r  zReply was: %s)r   r+   r   )rA   Ztext_snippetr=   r<   r   r   r"   rv    s    
rv  c             C   sJ   d d d d d } d d } t  | d |  }  t d t |    d  S)	NzDdafsdfa dasflkj pp[oadsij asdfp;ij asdfpjkop asdfpok asdfpok asdfpokr  r*   z# here is some dummy Python code
for someItem in myListOfStuff:
    do something(someItem)
    do something()
    do something()
    if somethingElse(someItem):
        doSomethingEvenMoreInteresting()

r  zHere is some sample code. zCode SamplezReply was: %s)r   r+   rd  )rA   Zcode_snippetr<   r   r   r"   rw    s
    	
rw  c              C   sf   d }  d d d g } xJ d d d d g D]6 } t  |  | d	 | d
 | } t d t |   q( Wd  S)Nz Do you like this picture?
It is r9   r:   z
No opinionzpython_and_check_logo.gifzpython_and_check_logo.jpgzpython_and_check_logo.pngz	zzzzz.gifr;   r>   zReply was: %s)r   r+   rd  )r<   r>   r;   rA   r   r   r"   rr    s    rr  c              C   sF   t  j }  t   t  _ } t d  |  t  _ t d d | j   d  S)NeasyguizEasyGui Helpr[   )r&   r'   r   helpr   getvalue)ZsavedStdoutZcapturedOutputr   r   r"   rq    s
    	
	rq  c              C   s9   d }  d } d } t  | | d |  } t d |  d  S)NzmyNewFile.txtzFile SaveAszSave file as:r   zYou chose to save file: %s)r   r+   )rS  r=   r<   r1  r   r   r"   ru    s
    ru  c              C   ss   d }  d } t  | |   } t d |  t  | |  d d } t d |  t  | |  d d } t d |  d  S)NzDemo of diropenboxz)Pick the directory that you wish to open.zYou chose directory...: %sr   z./zc:/)r   r+   )r=   r<   dr   r   r"   rs    s    rs  c              C   s   d }  d } d } t  |  | d | } t d |  d } d d d	 d
 d g d d d g g } t  |  | d | d | } t d |  d  S)NzPython filesz
Open filesz*.pyr   zYou chose to open file: %sz./*.gifz*.jpgz*.zipz*.tgsz*.gzzArchive filesz*.htmz*.htmlz
HTML filesrG  )r   r+   )r<   r=   r   r1  rG  r   r   r"   rt    s    $rt  c               C   s   d  S)Nr   r   r   r   r"   _dummy	  s    r  a!  
========================================================================
0.96(2010-08-29)
========================================================================
This version fixes some problems with version independence.

BUG FIXES
------------------------------------------------------
 * A statement with Python 2.x-style exception-handling syntax raised
   a syntax error when running under Python 3.x.
   Thanks to David Williams for reporting this problem.

 * Under some circumstances, PIL was unable to display non-gif images
   that it should have been able to display.
   The cause appears to be non-version-independent import syntax.
   PIL modules are now imported with a version-independent syntax.
   Thanks to Horst Jens for reporting this problem.

LICENSE CHANGE
------------------------------------------------------
Starting with this version, EasyGui is licensed under what is generally known as
the "modified BSD license" (aka "revised BSD", "new BSD", "3-clause BSD").
This license is GPL-compatible but less restrictive than GPL.
Earlier versions were licensed under the Creative Commons Attribution License 2.0.


========================================================================
0.95(2010-06-12)
========================================================================

ENHANCEMENTS
------------------------------------------------------
 * Previous versions of EasyGui could display only .gif image files using the
   msgbox "image" argument. This version can now display all image-file formats
   supported by PIL the Python Imaging Library) if PIL is installed.
   If msgbox is asked to open a non-gif image file, it attempts to import
   PIL and to use PIL to convert the image file to a displayable format.
   If PIL cannot be imported (probably because PIL is not installed)
   EasyGui displays an error message saying that PIL must be installed in order
   to display the image file.

   Note that
   http://www.pythonware.com/products/pil/
   says that PIL doesn't yet support Python 3.x.


========================================================================
0.94(2010-06-06)
========================================================================

ENHANCEMENTS
------------------------------------------------------
 * The codebox and textbox functions now return the contents of the box, rather
   than simply the name of the button ("Yes").  This makes it possible to use
   codebox and textbox as data-entry widgets.  A big "thank you!" to Dominic
   Comtois for requesting this feature, patiently explaining his requirement,
   and helping to discover the tkinter techniques to implement it.

   NOTE THAT in theory this change breaks backward compatibility.  But because
   (in previous versions of EasyGui) the value returned by codebox and textbox
   was meaningless, no application should have been checking it.  So in actual
   practice, this change should not break backward compatibility.

 * Added support for SPACEBAR to command buttons.  Now, when keyboard
   focus is on a command button, a press of the SPACEBAR will act like
   a press of the ENTER key; it will activate the command button.

 * Added support for keyboard navigation with the arrow keys (up,down,left,right)
   to the fields and buttons in enterbox, multenterbox and multpasswordbox,
   and to the buttons in choicebox and all buttonboxes.

 * added highlightthickness=2 to entry fields in multenterbox and
   multpasswordbox.  Now it is easier to tell which entry field has
   keyboard focus.


BUG FIXES
------------------------------------------------------
 * In EgStore, the pickle file is now opened with "rb" and "wb" rather than
   with "r" and "w".  This change is necessary for compatibility with Python 3+.
   Thanks to Marshall Mattingly for reporting this problem and providing the fix.

 * In integerbox, the actual argument names did not match the names described
   in the docstring. Thanks to Daniel Zingaro of at University of Toronto for
   reporting this problem.

 * In integerbox, the "argLowerBound" and "argUpperBound" arguments have been
   renamed to "lowerbound" and "upperbound" and the docstring has been corrected.

   NOTE THAT THIS CHANGE TO THE ARGUMENT-NAMES BREAKS BACKWARD COMPATIBILITY.
   If argLowerBound or argUpperBound are used, an AssertionError with an
   explanatory error message is raised.

 * In choicebox, the signature to choicebox incorrectly showed choicebox as
   accepting a "buttons" argument.  The signature has been fixed.


========================================================================
0.93(2009-07-07)
========================================================================

ENHANCEMENTS
------------------------------------------------------

 * Added exceptionbox to display stack trace of exceptions

 * modified names of some font-related constants to make it
   easier to customize them


========================================================================
0.92(2009-06-22)
========================================================================

ENHANCEMENTS
------------------------------------------------------

 * Added EgStore class to to provide basic easy-to-use persistence.

BUG FIXES
------------------------------------------------------

 * Fixed a bug that was preventing Linux users from copying text out of
   a textbox and a codebox.  This was not a problem for Windows users.

c               C   s   t  d t d t  d S)z,
    shows the easygui revision history
    zAbout EasyGui
ZEasyGuiN)r   r   EASYGUI_ABOUT_INFORMATIONr   r   r   r"   r   	  s    __main__)r/   r0   r1   )YesNo)zContinuezCancel)r  r  )r  r  )rJ   rK   rL   )orh  rN  r   __all__r&   rn   r  rW  r  
hexversionrO  r   ZPILr   rv   r   rx   ru   tkintertkinter.filedialog
filedialogr.  ior   TkintertkFileDialogr(   r+   Zsayrp  Zstarsr   r)  r.   rh   r   r"  r   r  r   r   r   rP  r_   r   r   r   r   r   r   r   r   rb   ry   r   r   r   r   r   r   r   r	   r<  r   r   r   r   r   r   r   r
   r   r   r   r   r   re   r   r   r   r   r   r   r   r   rz   r   r   r   r(  r   r-  r2  r   r   rH  rQ  r   r   r   rv  rw  rr  rq  ru  rs  rt  r  r  r   rC  r   r   r   r"   <module>I   s  			



%	aS0 l		4	;Z#;	"		