U
    |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.8/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 }|  D ]$\}}|d|  |t| qt|S N-)itemsappendstrtuple)selfkwoptionskvr   r   r   _set1   s
    z	Font._setc                 C   s$   g }|D ]}| d|  qt|S r   )r   r   )r   argsr   r   r   r   r   _get8   s    z	Font._getc                 C   s:   i }t dt|dD ] }||d  ||| dd  < q|S )Nr      r
   )rangelen)r   r   r   ir   r   r   _mkdict>   s    zFont._mkdictNFc                 K   s   |st d}t|d|}|r4||dd|}n
| |}|sTd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 )Nzuse fonttkfontactualFnamesz$named font %s does not already exist	configureZcreateT)tkinter_get_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 Nr   r   r   r   r   __str__c   s    zFont.__str__c                 C   s&   t |tstS | j|jko$| j|jkS r0   )
isinstancer   NotImplementedr   r+   )r   otherr   r   r   __eq__f   s    
zFont.__eq__c                 C   s
   |  |S r0   )cget)r   keyr   r   r   __getitem__k   s    zFont.__getitem__c                 C   s   | j f ||i d S r0   )r"   )r   r8   valuer   r   r   __setitem__n   s    zFont.__setitem__c                 C   s4   z| j r| dd| j W n tk
r.   Y nX d S )Nr   delete)r*   r-   r   	Exceptionr1   r   r   r   __del__q   s
    zFont.__del__c                 C   s   t | jf|  S )z*Return a distinct copy of the current font)r   r+   r    r1   r   r   r   copyx   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   
-displayofr   r   r    N)r-   r   r   r,   )r   option	displayofr   r   r   r   r    |   s    zFont.actualc                 C   s   |  dd| jd| S )zGet font attributer   configr   )r-   r   )r   rA   r   r   r   r7      s    z	Font.cgetc              	   K   sB   |r"| j dd| jf| |  n| | |  dd| jS dS )zModify font attributesr   rC   N)r-   r   r   r   r,   )r   r   r   r   r   rC      s    zFont.configc                 C   s2   |f}|rd||f}| j | jdd| jf| S )zReturn text widthr@   r   measure)r+   getintr-   r   )r   textrB   r   r   r   r   rD      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 }tdt|dD ](}| j||d	  ||| d	d < q||S dS )
z}Return font metrics.

        For best performance, create a dummy widget
        using this font before calling this method.r   rB   Nr@   r   metricsr   r   r
   )	popr   r+   rE   r-   r   r,   r   r   )r   r   r   r   rB   resr   r   r   r   rG      s    &zFont.metrics)NNNF)NN)N)__name__
__module____qualname____doc__	itertoolscountr)   r   r   r   r/   r2   r6   r9   r;   r>   r?   r    r7   rC   r"   rD   rG   r   r   r   r   r      s$   


	
r   c                 C   s6   | st d} d}|rd|f}| j| jjd| S )zGet font families (as a tuple)zuse font.families()r   r@   r   families)r   rP   r#   r$   r   r&   r'   )r.   rB   r   r   r   r   rP      s    
rP   c                 C   s$   | st d} | j| jddS )z'Get names of defined fonts (as a tuple)zuse font.names()r   r!   rQ   )r.   r   r   r   r!      s    
r!   __main__times   )familysizeweightrU   rW   ZhelloZ	linespace)rB   )ZCourier   r   )r   zHello, world)rF   r   zQuit!)rF   Zcommandr   )rW   )NN)N)__version__rN   r#   ZNORMALZROMANZBOLDZITALICr	   r   rP   r!   rJ   ZTkr.   fprintr    rC   r7   rD   rG   ZLabelwZpackZButtonZdestroyr?   ZfbZmainloopr   r   r   r   <module>   sB    




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