
[[\                 @   s"  d  Z  d d l Z d d l Z d Z d Z d Z d Z d d   Z Gd	 d
   d
  Z d d d d  Z	 d d d  Z
 e d k re j   Z e d d d d d e  Z e e j    e e j d   e e j d   e e j    e e j d   e e j d   e e
    e e j d  e j d   e e j d e   e d d  Z e e j d  e j d d e  e j e d d d e Z e j   e j e d d d e j Z e j   e d e d  j   Z e j d e  e j d e  e j   n  d S) z0.9    NZnormalZromanboldZitalicc             C   s   t  d |  d d  S)zFGiven the name of a tk named font, returns a Font representation.
    nameexistsT)Font)r    r   "/usr/lib/python3.4/tkinter/font.py
nametofont   s    r   c               @   s   e  Z d  Z d Z e j d  Z d d   Z d d   Z d d   Z	 d	 d	 d	 d
 d d  Z
 d d   Z d d   Z d d   Z d d   Z d d   Z d d   Z d	 d	 d d  Z d d   Z d d   Z e Z d	 d d   Z d! d"   Z d	 S)#r   a  Represents a named font.

    Constructor options are:

    font -- font specifier (name, system font, or (family, size, style)-tuple)
    name -- name to use for this font configuration (defaults to a unique name)
    exists -- does a named font by this name already exist?
       Creates a new named font if False, points to the existing font if True.
       Raises _tkinter.TclError if the assertion is false.

       the following are ignored if font is specified:

    family -- font 'family', e.g. Courier, Times, Helvetica
    size -- font size in points
    weight -- font thickness: NORMAL, BOLD
    slant -- font slant: ROMAN, ITALIC
    underline -- font underlining: false (0), true (1)
    overstrike -- font strikeout: false (0), true (1)

       c             C   sQ   g  } x> | j    D]0 \ } } | j d |  | j t |   q Wt |  S)N-)itemsappendstrtuple)selfkwoptionskvr   r   r   _set1   s
    z	Font._setc             C   s2   g  } x | D] } | j  d |  q Wt |  S)Nr
   )r   r   )r   argsr   r   r   r   r   _get8   s    z	Font._getc             C   sM   i  } x@ t  d t |  d  D]& } | | d | | | d d   <q W| S)Nr      r	   )rangelen)r   r   r   ir   r   r   _mkdict>   s    $zFont._mkdictNFc             K   sC  | s t  j } n  t | d |  } | rK | j | j d d |   } n |  j |  } | s| d t t |  j   } n  | |  _	 | r d |  _
 |  j	 | j | j d d   k r t  j j d |  j	 f   n  | r| j d d |  j	 |  qn" | j d d |  j	 |  d	 |  _
 | |  _ | j |  _ | j |  _ d  S)
NtkfontactualFnamesz$named font %s does not already exist	configurecreateT)tkinter_default_rootgetattr	splitlistcallr   r   nextcounterr   delete_fontZ_tkinterZTclError_tk_split_call)r   rootr   r   r   r   r   r   r   r   __init__D   s*    !		$			zFont.__init__c             C   s   |  j  S)N)r   )r   r   r   r   __str__c   s    zFont.__str__c             C   s   t  | t  o |  j | j k S)N)
isinstancer   r   )r   otherr   r   r   __eq__f   s    zFont.__eq__c             C   s   |  j  |  S)N)cget)r   keyr   r   r   __getitem__i   s    zFont.__getitem__c             C   s   |  j  i | | 6  d  S)N)r    )r   r4   valuer   r   r   __setitem__l   s    zFont.__setitem__c             C   sY   y& |  j  r% |  j d d |  j  n  Wn, t t f k
 rC   Yn t k
 rT Yn Xd  S)Nr   Zdelete)r)   r,   r   KeyboardInterrupt
SystemExit	Exception)r   r   r   r   __del__o   s    	zFont.__del__c             C   s   t  |  j |  j    S)z*Return a distinct copy of the current font)r   r*   r   )r   r   r   r   copyx   s    z	Font.copyc             C   sz   f  } | r d | f } n  | rK | d | f } |  j  d d |  j |  S|  j |  j |  j  d d |  j |    Sd S)zReturn actual font attributesz
-displayofr
   r   r   N)r,   r   r   r+   )r   option	displayofr   r   r   r   r   |   s    zFont.actualc             C   s   |  j  d d |  j d |  S)zGet font attributer   configr
   )r,   r   )r   r=   r   r   r   r3      s    z	Font.cgetc             K   sW   | r+ |  j  d d |  j |  j |   n( |  j |  j |  j  d d |  j    Sd S)zModify font attributesr   r?   N)r,   r   r   r   r+   )r   r   r   r   r   r?      s
    zFont.configc             C   s@   | f } | r! d | | f } n  t  |  j d d |  j |   S)zReturn text widthz
-displayofr   measure)intr,   r   )r   textr>   r   r   r   r   r@      s    	zFont.measurec             O   s   f  } | j  d d  } | r- d | f } n  | re | |  j |  } t |  j d d |  j |   S|  j |  j d d |  j |   } i  } xF t d t |  d  D], } t | | d  | | | d d  <q W| Sd S)	z}Return font metrics.

        For best performance, create a dummy widget
        using this font before calling this method.r>   Nz
-displayofr   metricsr   r   r	   )popr   rA   r,   r   r+   r   r   )r   r   r   r   r>   Zresr   r   r   r   rC      s    $*zFont.metrics)__name__
__module____qualname____doc__	itertoolscountr(   r   r   r   r.   r/   r2   r5   r7   r;   r<   r   r3   r?   r    r@   rC   r   r   r   r   r      s$   		r   c             C   sO   |  s t  j }  n  f  } | r- d | f } n  |  j j |  j j d d |   S)zGet font families (as a tuple)z
-displayofr   families)r"   r#   r   r%   r&   )r-   r>   r   r   r   r   rK      s    rK   c             C   s1   |  s t  j }  n  |  j j |  j j d d   S)z'Get names of defined fonts (as a tuple)r   r   )r"   r#   r   r%   r&   )r-   r   r   r   r      s    r   __main__Zfamilytimessize   ZweightZhelloZ	linespacer>   r   Courier   rB   zHello, worldzQuit!Zcommand)rP   rQ   r   )__version__rI   r"   ZNORMALZROMANZBOLDZITALICr   r   rK   r   rE   ZTkr-   fprintr   r?   r3   r@   rC   ZLabelwZpackZButtonZdestroyr<   ZfbZmainloopr   r   r   r   <module>   s@   

%

