ó
_y]c           @   sŞ   d  Z  d d l Z d d l m Z m Z d d l m Z d d l m Z m	 Z	 e
 e  Z e
 e j  Z d e e f d     YZ d   Z e e j  Z d d	  Z d S(
   s@    Defines miscellaneous Qt-related helper classes and functions.
i˙˙˙˙N(   t   QtCoret   QtGui(   t	   iteritems(   t	   HasTraitst	   TraitTypet   MetaQObjectHasTraitsc           B   s    e  Z d  Z d   Z d   Z RS(   s   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         C   s   xu t  |  D]g \ } } t | t  r4 | | _ q t j |  r t | t  rt |   } | | _ | | | <qt q q Wt j |  | | |  } | S(   N(	   R   t
   isinstanceR   t   namet   inspectt   isclasst
   issubclasst   MetaQObjectt   __new__(   t   mclsR   t   basest	   classdictt   kt   vt   vinstt   cls(    (    s-   lib/python2.7/site-packages/qtconsole/util.pyR      s    		c         C   s0   t  j |  | | |  t j |  | | |  d  S(   N(   R   t   __init__t   MetaHasTraits(   R   R   R   R   (    (    s-   lib/python2.7/site-packages/qtconsole/util.pyR   '   s    (   t   __name__t
   __module__t   __doc__R   R   (    (    (    s-   lib/python2.7/site-packages/qtconsole/util.pyR      s   	c            s#   d   f    f d     Y  S(   sÜ   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.
    t   SuperQClassc              s)   e  Z   f d    Z    f d   Z RS(   c            s      j  |   }   j |  | S(   N(   R   R   (   R   t   argst   kwt   inst(   t   QClass(    s-   lib/python2.7/site-packages/qtconsole/util.pyR   =   s    c            sv   |  j  j   } x!   j   D] } | j |  q W| j   d } | t |  k  rr | | j |  | |  n  d  S(   Ni   (   t	   __class__t   mrot   removet   indext   lenR   (   t   selfR   R   R   t   qt_classt
   next_index(   R   R   (    s-   lib/python2.7/site-packages/qtconsole/util.pyR   D   s    (   R   R   R   R   (    (   R   R   (    s-   lib/python2.7/site-packages/qtconsole/util.pyR   ;   s   (    (   R   (    (   R   R   s-   lib/python2.7/site-packages/qtconsole/util.pyt   superQ0   s    c         C   sR   t  j |   } t  j |  } | d k	 rN | j   |  k rN t  j |  } n  | S(   sť  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
    N(   R   t   QFontt	   QFontInfot   Nonet   family(   R*   t   fallbackt   fontt	   font_info(    (    s-   lib/python2.7/site-packages/qtconsole/util.pyt   get_fontU   s
    (   R   R   t   qtconsole.qtR    R   t   ipython_genutils.py3compatR   t	   traitletsR   R   t   typeR   t   QObjectR   R   R&   t   SuperQObjectR)   R.   (    (    (    s-   lib/python2.7/site-packages/qtconsole/util.pyt   <module>   s   	