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 }|| _	|rd| _
| j	||ddkrt 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    




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