ó
ø`9Sc           @   s7   d  d l  Td  d l Td g Z d e f d     YZ d S(   iĸĸĸĸ(   t   *t   ConsoleWidgetc           B   s2   e  Z d  Z d d d d  Z d   Z d   Z RS(   sl   Widget suitable for displaying of real-time textual output generated by
    an external console application.iP   i   c         C   si   t  j |  |  |  j t  |  j   } | j d  |  j |  |  j t  j  | |  _	 | |  _
 d S(   se   'width' and 'height' should specify preferred dimensions of the
        output window, in characters.s   Courier NewN(   t   QPlainTextEditt   __init__t   setReadOnlyt   Truet   fontt	   setFamilyt   setFontt   setLineWrapModet   NoWrapt   widtht   height(   t   selfR   R   t   parentR   (    (    s   code\common\ConsoleWidget.pyR      s    	c         C   s+   |  j  t j  |  j |  |  j   d S(   s   Append a new output string to the end of the widget's current text,
        and make sure that added text is visible on the screen.N(   t
   moveCursort   QTextCursort   Endt   insertPlainTextt   ensureCursorVisible(   R   t   text(    (    s   code\common\ConsoleWidget.pyt   appendOutput0   s    c         C   sĪ   t  |  j    } |  j   } t |  j   j    } | j d |  j  | d | d } | j   |  j | d | } | |  j   j	   j   7} t
 | |  S(   Nt    i   (   t   QFontMetricsR   t
   frameWidtht   intt   documentt   documentMarginR   R   t   verticalScrollBart   sizeHintt   QSize(   R   t   metricsR   t   marginR   R   (    (    s   code\common\ConsoleWidget.pyR   B   s    &N(   t   __name__t
   __module__t   __doc__t   NoneR   R   R   (    (    (    s   code\common\ConsoleWidget.pyR      s   	N(   t   PyQt4.QtCoret   PyQt4.QtGuit   __all__R   R   (    (    (    s   code\common\ConsoleWidget.pyt   <module>   s   

	