
    gf?                          G d  de       Zy)c                   |    e Zd Z	 	 	 	 	 ddZd Zd Zd ZeZd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zy)GeometryNc                    ||||f\  | _         | _        | _        | _        t	        |t
              rv|j                  d      }|d   j                  d      }	 t        |d         | _         	 t        |d         | _        	 t        |d         | _        	 t        |d         | _        yy# t        t        f$ r Y Ow xY w# t        t        f$ r Y Pw xY w# t        t        f$ r Y Qw xY w# t        t        f$ r Y yw xY w)a  
        Generate a geometry object from the standard Tk geometry string.

        Args:
            text (str): The standard Tk geometry string.
                If str, Must be: `[width]x[height]+[left]+[top]` (integers).
            width (int): The width value.
                If this can be extracted from `text`, this parameter is
                ignored.
            height (int): The height value.
                If this can be extracted from `text`, this parameter is
                ignored.
            left (int): The left value.
                If this can be extracted from `text`, this parameter is
                ignored.
            top (int): The top value.
                If this can be extracted from `text`, this parameter is
                ignored.
        Returns:
            None.

        Examples:
            >>> print(Geometry('1x2+3+4'))
            1x2+3+4
            >>> print(Geometry())
            0x0+0+0
            >>> print(Geometry('1x2'))
            1x2+0+0
            >>> print(Geometry('+1+2'))
            0x0+1+2
            >>> print(Geometry('1+2+3'))
            1x0+2+3
            >>> print(Geometry('1x2+1'))
            1x2+1+0
        +    x      N)
widthheightlefttop
isinstancestrsplitint
ValueError
IndexError)selftextr
   r   r   r   tokens1tokens2s           e/var/dept/share/cheung/public_html/OutSchool/python/env/lib/python3.12/site-packages/pytk/Geometry.py__init__zGeometry.__init__   s   T 8=fdC7O4
DKDHdC jjoGaj&&s+G _
!'!*o
O	wqz?! !
 
+  
+  
+  
+ sH   B' *B< >C C& 'B98B9<CCC#"C#&C87C8c              #      K   d}| j                   | j                  | j                  | j                  f}t	        ||      D ]  \  }}||f  y w)N)whlt)r
   r   r   r   zipr   kvs      r   __iter__zGeometry.__iter__E   sK     JJTYY8AY 	EAqQ$J	s   AAc                 R    dj                  t        | j                                     S )Nz{w:d}x{h:d}+{l:d}+{t:d})
format_mapdictitemsr   s    r   __str__zGeometry.__str__K   s    (33D4FGG    c           
      t    dj                  | D cg c]  \  }}|dz   t        |      z    c}}      S c c}}w )Nz, =)joinr   r    s      r   __repr__zGeometry.__repr__N   s0    yyt<tq!!c'CF*<==<s   4
c              #   (   K   | D ]	  \  }}|  y wN r    s      r   valueszGeometry.valuesS         	DAqG	   c              #   (   K   | D ]	  \  }}|  y wr0   r1   r    s      r   keyszGeometry.keysW   r3   r4   c                     |j                   dz  | j                   dz  z
  |j                  z   | _        |j                  dz  | j                  dz  z
  |j                  z   | _        | S 
        Update the geometry to be centered with respect to a container.

        Args:
            parent (Geometry): The geometry of the container.

        Returns:
            geometry (Geometry): The updated geometry.
        r	   r
   r   r   r   r   parents     r   set_to_centerzGeometry.set_to_center[   sV     LLA%

a7&++E	==A%q(886::Er*   c                 "    d| _         d| _        | S )z
        Update the geometry to be centered with respect to a container.

        Args:
            None.

        Returns:
            geometry (Geometry): The updated geometry.
        r   r   r   r(   s    r   set_to_originzGeometry.set_to_origini   s     	r*   c                 J    |j                   | _         |j                  | _        | S r9   r?   r;   s     r   set_to_top_leftzGeometry.set_to_top_leftw   s     KK	::r*   c                     |j                   dz  | j                   dz  z
  |j                  z   | _        |j                  | _        | S r8   r
   r   r   r;   s     r   
set_to_topzGeometry.set_to_top   s:     LLA%

a7&++E	::r*   c                 ~    |j                   | j                   z
  |j                  z   | _        |j                  | _        | S rB   rE   r;   s     r   set_to_top_rightzGeometry.set_to_top_right   s1     LL4::-;	::r*   c                     |j                   | j                   z
  |j                  z   | _        |j                  dz  | j                  dz  z
  |j                  z   | _        | S r8   r:   r;   s     r   set_to_rightzGeometry.set_to_right   sM     LL4::-;	==A%q(886::Er*   c                     |j                   | j                   z
  |j                  z   | _        |j                  | j                  z
  |j                  z   | _        | S rB   r:   r;   s     r   set_to_bottom_rightzGeometry.set_to_bottom_right   sC     LL4::-;	==4;;.;r*   c                     |j                   dz  | j                   dz  z
  |j                  z   | _        |j                  | j                  z
  |j                  z   | _        | S r8   r:   r;   s     r   set_to_bottomzGeometry.set_to_bottom   sL     LLA%

a7&++E	==4;;.;r*   c                 ~    |j                   | _         |j                  | j                  z
  |j                  z   | _        | S rB   r   r   r   r;   s     r   set_to_bottom_leftzGeometry.set_to_bottom_left   s1     KK	==4;;.;r*   c                     |j                   | _         |j                  dz  | j                  dz  z
  |j                  z   | _        | S r8   rP   r;   s     r   set_to_leftzGeometry.set_to_left   s;     KK	==A%q(886::Er*   )Nr   r   r   r   )__name__
__module____qualname__r   r#   r)   r.   r'   r2   r6   r=   r@   rC   rF   rH   rJ   rL   rN   rQ   rS   r1   r*   r   r   r      sl     =~H> Er*   r   N)objectr   r1   r*   r   <module>rX      s   
`v `r*   