B
    <™cµ  ã               @   sz  d Z ddlZddlZdZdZdZdZdd„ ZG d	d
„ d
ƒZd dd„Z	d!dd„Z
edkrve ¡ ZeddedZee ¡ ƒ ee d¡ƒ ee d¡ƒ ee ¡ ƒ ee d¡ƒ ee d¡ƒ ee
ƒ ƒ ee d¡e d¡ƒ eejedƒ eddZee d¡ejdedƒ ejededZe ¡  ejedejdZe ¡  eed d ¡ Zejed ejed e ¡  dS )"z0.9é    NZnormalZromanÚboldZitalicc             C   s   t | ddS )zFGiven the name of a tk named font, returns a Font representation.
    T)ÚnameÚexists)ÚFont)r   © r   úlib/python3.7/tkinter/font.pyÚ
nametofont   s    r   c               @   sœ   e Zd ZdZe d¡Zdd„ Zdd„ Zdd„ Z	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„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   s>   g }x0|  ¡ D ]$\}}| d| ¡ | t|ƒ¡ qW t|ƒS )Nú-)ÚitemsÚappendÚstrÚtuple)ÚselfÚkwÚoptionsÚkÚvr   r   r   Ú_set1   s
    z	Font._setc             C   s(   g }x|D ]}|  d| ¡ q
W t|ƒS )Nr
   )r   r   )r   Úargsr   r   r   r   r   Ú_get8   s    
z	Font._getc             C   s>   i }x4t 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   sÞ   |s
t j}t|d|ƒ}|r0| | dd|¡¡}n
|  |¡}|sPdtt| jƒƒ }|| _	|r¨d| _
| j	| | dd¡¡krŒt j d| j	f ¡‚|rÄ|jdd| j	f|žŽ  n|jdd| j	f|žŽ  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
   |   |¡S )N)Úcget)r   Úkeyr   r   r   Ú__getitem__i   s    zFont.__getitem__c             C   s   | j f ||iŽ d S )N)r    )r   r3   Úvaluer   r   r   Ú__setitem__l   s    zFont.__setitem__c             C   s4   y| j r|  dd| j¡ W n tk
r.   Y nX d S )Nr   Údelete)r(   r+   r   Ú	Exception)r   r   r   r   Ú__del__o   s
    zFont.__del__c             C   s   t | jf|  ¡ ŽS )z*Return a distinct copy of the current font)r   r)   r   )r   r   r   r   Úcopyv   s    z	Font.copyc             C   s^   d}|rd|f}|r8|d| f }| j dd| jf|žŽ S |  |  | j dd| jf|žŽ ¡¡S dS )zReturn actual font attributesr   z
-displayofr
   r   r   N)r+   r   r   r*   )r   ÚoptionÚ	displayofr   r   r   r   r   z   s    zFont.actualc             C   s   |   dd| jd| ¡S )zGet font attributer   Úconfigr
   )r+   r   )r   r;   r   r   r   r2   †   s    z	Font.cgetc          	   K   sB   |r"| j dd| jf|  |¡žŽ  n|  |  |   dd| j¡¡¡S dS )zModify font attributesr   r=   N)r+   r   r   r   r*   )r   r   r   r   r   r=   Š   s
    zFont.configc             C   s2   |f}|rd||f}| j  | jdd| jf|žŽ ¡S )zReturn text widthz
-displayofr   Úmeasure)r)   Úgetintr+   r   )r   Útextr<   r   r   r   r   r>   •   s    
zFont.measurec             O   s²   d}|  dd¡}|rd|f}|rL||  |¡ }| j | jdd| jf|žŽ ¡S |  | jdd| jf|žŽ ¡}i }x<tdt|ƒdƒD ](}| j ||d	  ¡||| d	d… < q~W |S dS )
z}Return font metrics.

        For best performance, create a dummy widget
        using this font before calling this method.r   r<   Nz
-displayofr   Úmetricsr   r   r	   )	Úpopr   r)   r?   r+   r   r*   r   r   )r   r   r   r   r<   Zresr   r   r   r   rA   œ   s    (zFont.metrics)NNNF)NN)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	itertoolsÚcountr'   r   r   r   r-   r.   r1   r4   r6   r9   r:   r   r2   r=   r    r>   rA   r   r   r   r   r      s$   


	
r   c             C   s2   | s
t j} d}|rd|f}| j | jjd|žŽ ¡S )zGet font families (as a tuple)r   z
-displayofr   Úfamilies)r   rI   )r!   r"   r   r$   r%   )r,   r<   r   r   r   r   rI   ±   s    rI   c             C   s    | s
t 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__Útimesé   )ÚfamilyÚsizeÚweightrM   rO   ZhelloZ	linespace)r<   )ZCourieré   r   )r   zHello, world)r@   r   zQuit!)r@   Zcommandr   )rO   )NN)N)Ú__version__rG   r!   ZNORMALZROMANZBOLDZITALICr   r   rI   r   rC   ZTkr,   ÚfÚprintr   r=   r2   r>   rA   ZLabelÚwZpackZButtonZdestroyr:   ZfbZmainloopr   r   r   r   Ú<module>   sB    






