o
    ǋ|cX                     @   s  d dl Z d dlZdZg dZdZdZdZdZd!dd	ZG d
d dZ	d"ddZ
d!ddZedkre 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 dS )#    Nz0.9)NORMALROMANBOLDITALIC
nametofontFontfamiliesnamesZ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root)r   )r   r    r   lib/python3.10/tkinter/font.pyr      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 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   _set2   s
   z	Font._setc                 C   s$   g }|D ]	}| d|  qt|S r   )r   r   )r   argsr   r   r   r   r   _get9   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   |d u r	t d}t|d|}|r||dd|}n| |}|s,dtt| j }|| _	|rYd| _
| j	||ddvrJt jd| j	f |rX|jdd| j	g|R   n|jdd	| j	g|R   d
| _
|| _|j| _|j| _d S )Nzuse fonttkfontactualFr	   z$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   r   r%   r   r   r   r$   r   r   r   __init__E   s.   


zFont.__init__c                 C   s   | j S N)r   r   r   r   r   __str__d   s   zFont.__str__c                 C   s"   d| j j d| j j d| jdS )N<.z object >)	__class__
__module____qualname__r   r5   r   r   r   __repr__g   s   zFont.__repr__c                 C   s&   t |tstS | j|jko| j|jkS r4   )
isinstancer   NotImplementedr   r0   )r   otherr   r   r   __eq__k   s   
zFont.__eq__c                 C   s
   |  |S r4   )cget)r   keyr   r   r   __getitem__p   s   
zFont.__getitem__c                 C   s   | j di ||i d S )Nr   )r'   )r   rC   valuer   r   r   __setitem__s   s   zFont.__setitem__c                 C   s8   z| j r| dd| j W d S W d S  ty   Y d S w )Nr%   delete)r/   r2   r   	Exceptionr5   r   r   r   __del__v   s   zFont.__del__c                 C   s   t | jfi |  S )z*Return a distinct copy of the current font)r   r0   r&   r5   r   r   r   copy}      z	Font.copyc                 C   s^   d}|rd|f}|r|d| f }| j dd| jg|R  S | | | j dd| jg|R  S )zReturn actual font attributesr   
-displayofr   r%   r&   )r2   r   r#   r1   )r   option	displayofr   r   r   r   r&      s   zFont.actualc                 C   s   |  dd| jd| S )zGet font attributer%   configr   )r2   r   )r   rM   r   r   r   rB      rK   z	Font.cgetc              	   K   sB   |r| j dd| jg| |R   dS | | |  dd| jS )zModify font attributesr%   rO   N)r2   r   r   r#   r1   )r   r   r   r   r   rO      s   zFont.configc                 C   s4   |f}|r
d||f}| j | jdd| jg|R  S )zReturn text widthrL   r%   measure)r0   getintr2   r   )r   textrN   r   r   r   r   rP      s   
 zFont.measurec                 O   s   d}| dd}|rd|f}|r'|| | }| j| jdd| jg|R  S | | jdd| jg|R  }i }tdt|dD ]}| j||d	  ||| d	d < q@|S )
z}Return font metrics.

        For best performance, create a dummy widget
        using this font before calling this method.r   rN   NrL   r%   metricsr   r   r   )	popr   r0   rQ   r2   r   r1   r    r!   )r   r   r   r   rN   resr"   r   r   r   rS      s   &zFont.metrics)NNNFNNr4   )__name__r;   r<   __doc__	itertoolscountr.   r   r   r#   r3   r6   r=   rA   rD   rF   rI   rJ   r&   rB   rO   r'   rP   rS   r   r   r   r   r      s(    


	
r   c                 C   s@   | du r	t d} d}|rd|f}| j| jjddg|R  S )zGet font families (as a tuple)Nzuse font.families()r   rL   r%   r   r(   r)   r$   r+   r,   )r   rN   r   r   r   r   r      s   
r   c                 C   s(   | du r	t d} | j| jddS )z'Get names of defined fonts (as a tuple)Nzuse font.names()r%   r	   r[   )r   r   r   r   r	      s   
r	   __main__times   )familysizeweightr_   ra   ZhelloZ	linespace)rN   )ZCourier   r
   )r%   zHello, world)rR   r%   zQuit!)rR   Zcommandr%   )ra   r4   rV   )rY   r(   __version____all__r   r   r   r   r   r   r   r	   rW   ZTkr   fprintr&   rO   rB   rP   rS   ZLabelwZpackZButtonZdestroyrJ   ZfbZmainloopr   r   r   r   <module>   sH   
 


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