
+c`                 @   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   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.5/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   s7  | s t  j } t | d |  } | rH | j | j d d |   } n |  j |  } | sv d t t |  j   } | |  _	 | r d |  _
 |  j	 | j | j d d   k r t  j j d |  j	 f   | r| j d d |  j	 |  n" | j d d |  j	 |  d	 |  _
 | |  _ | j |  _ | j |  _ d  S)
NtkfontactualFnamesz$named font %s does not already exist	configureZ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   d  S)N)r    )r   r3   valuer   r   r   __setitem__l   s    zFont.__setitem__c             C   s<   y# |  j  r" |  j d d |  j  Wn t k
 r7 Yn Xd  S)Nr   Zdelete)r(   r+   r   	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   copyv   s    z	Font.copyc             C   sw   f  } | r d | f } | rH | 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   z   s    zFont.actualc             C   s   |  j  d d |  j d |  S)zGet font attributer   configr
   )r+   r   )r   r:   r   r   r   r2      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   sC   | f } | r d | | f } |  j  j |  j d d |  j |   S)zReturn text widthz
-displayofr   measure)r)   getintr+   r   )r   textr;   r   r   r   r   r=      s    	zFont.measurec             O   s   f  } | j  d d  } | r* d | f } | rh | |  j |  } |  j j |  j d d |  j |   S|  j |  j d d |  j |   } i  } xL t d t |  d  D]2 } |  j j | | 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   r)   r>   r+   r   r*   r   r   )r   r   r   r   r;   Zresr   r   r   r   r@      s    	$0zFont.metrics)__name__
__module____qualname____doc__	itertoolscountr'   r   r   r   r-   r.   r1   r4   r6   r8   r9   r   r2   r<   r    r=   r@   r   r   r   r   r      s$   	r   c             C   sI   |  s t  j }  f  } | r' d | f } |  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   rH      s    	rH   c             C   s.   |  s t  j }  |  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   r?   zHello, worldzQuit!Zcommand)rM   rN   r   )__version__rF   r!   ZNORMALZROMANZBOLDZITALICr   r   rH   r   rB   ZTkr,   fprintr   r<   r2   r=   r@   ZLabelwZpackZButtonZdestroyr9   ZfbZmainloopr   r   r   r   <module>   s@   

%

