
    
8d                         d Z ddlZddlmZmZ ddlmZmZ  ee          Z	 eej
                  Z G d dee	          Zd Z eej
                  Zd	dZdS )
z@ Defines miscellaneous Qt-related helper classes and functions.
    N)QtCoreQtGui)	HasTraits	TraitTypec                       e Zd ZdZd Zd ZdS )MetaQObjectHasTraitsa   A metaclass that inherits from the metaclasses of HasTraits and QObject.

    Using this metaclass allows a class to inherit from both HasTraits and
    QObject. Using SuperQObject instead of QObject is highly recommended. See
    QtKernelManager for an example.
    c                 F   t          |                                          D ]a\  }}t          |t                    r||_        "t          j        |          r+t          |t                    r |            }||_        |||<   bt          	                    | |||          }|S N)
iteritems
isinstancer   nameinspectisclass
issubclassMetaQObject__new__)mclsr   bases	classdictkvvinstclss           .lib/python3.11/site-packages/qtconsole/util.pyr   zMetaQObjectHasTraits.__new__   s     	))** 	) 	)CAa!Y'' )## )a++ )ACCE!"EJ#(IaL!!$eY??
    c                 z    t                               | |||           t                              | |||           d S r
   )r   __init__MetaHasTraits)r   r   r   r   s       r   r   zMetaQObjectHasTraits.__init__&   s<    T4	:::tT5)<<<<<r   N)__name__
__module____qualname____doc__r   r    r   r   r   r      s<           = = = = =r   r   c                 ,      G  fdd           S )a   Permits the use of super() in class hierarchies that contain Qt classes.

    Unlike QObject, SuperQObject does not accept a QObject parent. If it did,
    super could not be emulated properly (all other classes in the heierarchy
    would have to accept the parent argument--they don't, of course, because
    they don't inherit QObject.)

    This class is primarily useful for attaching signals to existing non-Qt
    classes. See QtKernelManagerMixin for an example.
    c                   &    e Zd Z fdZ fdZdS )superQ.<locals>.SuperQClassc                 \                         |           }                    |           |S r
   )r   r   )r   argskwinstQClasss       r   r   z#superQ.<locals>.SuperQClass.__new__<   s-     >>#&&DOOD!!!Kr   c                    | j                                         }                                D ]}|                    |           |                              dz   }|t	          |          k     r ||         j        | g|R i | d S d S )N   )	__class__mroremoveindexlenr   )selfr)   r*   r0   qt_class
next_indexr,   SuperQClasss         r   r   z$superQ.<locals>.SuperQClass.__init__C   s    .$$&&C"JJLL % %

8$$$$;//!3JCHH$$(J(;;;;;;;;; %$r   N)r    r!   r"   r   r   r,   r7   s   r   r7   r'   :   sL        	 	 	 	 		< 	< 	< 	< 	< 	< 	< 	<r   r7   r$   r8   s   `@r   superQr9   /   sE    < < < < < < < <f < < <$ r   c                     t          j        |           }t          j        |          }|,|                                | k    rt          j        |          }|S )a  Return a font of the requested family, using fallback as alternative.

    If a fallback is provided, it is used in case the requested family isn't
    found.  If no fallback is given, no alternative is chosen and Qt's internal
    algorithms may automatically choose a fallback font.

    Parameters
    ----------
    family : str
      A font name.
    fallback : str
      A font name.

    Returns
    -------
    font : QFont object
    )r   QFont	QFontInfofamily)r=   fallbackfont	font_infos       r   get_fontrA   T   sT    $ ;vD %%I	 0 0 2 2f < <{8$$Kr   r
   )r#   r   qtpyr   r   	traitletsr   r   typer   QObjectr   r   r9   SuperQObjectrA   r$   r   r   <module>rG      s              * * * * * * * * Yd6>""= = = = =; = = =<  > vfn%%     r   