
_y]c           @   s   d  Z  d d l Z d d l Z d d l m Z d d l m Z d d l m Z d d l	 m
 Z
 m Z d d l m Z d d l m Z d d	 l m Z d
   Z d e
 j f d     YZ d S(   s   The Qt MainWindow for the QtConsole

This is a tabbed pseudo-terminal of Jupyter sessions, with a menu bar for
common actions.
iN(   t   Thread(   t   jupyter_runtime_dir(   t   get_all_styles(   t   QtGuit   QtCore(   t   styles(   t   JupyterWidget(   t   gui_referencec         C   s   t  d |   } | j   | S(   s7   call a function in a simple thread, to prevent blockingt   target(   R    t   start(   t   ft   t(    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyt
   background   s    
t
   MainWindowc           B   s  e  Z e d6 d6 d6 d   Z d   Z e d    Z e d    Z e d    Z	 d   Z
 d   Z d   Z d   Z d	   Z d
   Z d6 d  Z d   Z d   Z d   Z e d  Z d   Z e d  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# d   Z$ d   Z% d    Z& d!   Z' d"   Z( d#   Z) d$   Z* d%   Z+ d&   Z, d'   Z- d(   Z. d)   Z/ d*   Z0 d+   Z1 d,   Z2 d-   Z3 d.   Z4 d/   Z5 d0   Z6 d1   Z7 d2   Z8 d3   Z9 d4   Z: d5   Z; RS(7   c         C   s   t  t |   j   d |  _ d |  _ | |  _ | |  _ | |  _ | |  _ | |  _	 t
 j |   |  _ |  j j t  |  j j t  |  j j t j |  j  |  j |  j  |  j j   j t  |  j j t j j  d S(   sZ   Create a tabbed MainWindow for managing FrontendWidgets
        
        Parameters
        ----------
        
        app : reference to QApplication parent
        confirm_exit : bool, optional
            Whether we should prompt on close of tabs
        new_frontend_factory : callable
            A callable that returns a new JupyterWidget instance, attached to
            its own running kernel.
        slave_frontend_factory : callable
            A callable that takes an existing JupyterWidget, and  returns a new 
            JupyterWidget instance, attached to the same kernel.
        i    N(   t   superR   t   __init__t   _kernel_countert   _external_kernel_countert   _appt   confirm_exitt   new_frontend_factoryt   slave_frontend_factoryt   connection_frontend_factoryR   t
   QTabWidgett
   tab_widgett   setDocumentModet   Truet   setTabsClosablet   tabCloseRequestedt   intt   connectt	   close_tabt   setCentralWidgett   tabBart
   setVisiblet   Falset   setFocusPolicyR   t   Qtt   NoFocus(   t   selft   appR   R   R   R   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR   #   s    							c         C   sj   |  j  j   d k r. |  j  j   j t  n |  j  j   j t  |  j  j   d k rf |  j   n  d S(   s   update visibility of the tabBar depending of the number of tab

        0 or 1 tab, tabBar hidden
        2+ tabs, tabBar visible

        send a self.close if number of tab ==0

        need to be called explicitly, or be connected to tabInserted/tabRemoved
        i   i    N(   R   t   countR!   R"   R#   R   t   close(   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyt   update_tab_bar_visibilityL   s
    
c         C   s   |  j  } |  j  d 7_  | S(   s,   constantly increasing counter for kernel IDsi   (   R   (   R'   t   c(    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyt   next_kernel_id]   s    	c         C   s   |  j  } |  j  d 7_  | S(   s5   constantly increasing counter for external kernel IDsi   (   R   (   R'   R,   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyt   next_external_kernel_idd   s    	c         C   s   |  j  j   S(   N(   R   t   currentWidget(   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyt   active_frontendk   s    c         C   s   |  j    } |  j |  d S(   s0   create a new frontend and attach it to a new tabN(   R   t   add_tab_with_frontend(   R'   t   widget(    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyt   create_tab_with_new_frontendo   s    c         C   sJ   |  j    } t j j |  d d d | \ } } | rF |  j |  n  d S(   s#   Set the title of the console windows   Rename Windows
   New title:t   textN(   t   windowTitleR   t   QInputDialogt   getTextt   setWindowTitle(   R'   t	   old_titlet   titlet   ok(    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyt   set_window_titlet   s    c         C   sf   t  j j |  d t   d  \ } } | s. d S|  j |  } d j |  j  } |  j | d | d S(   sA   create a new frontend attached to an external kernel in a new tabs   Connect to Existing Kernels   Connection file (*.json)Ns   external {}t   name(   R   t   QFileDialogt   getOpenFileNameR   R   t   formatR.   R1   (   R'   t   connection_filet	   file_typeR2   R=   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyt   create_tab_with_existing_kernel~   s    c         C   sx   |  j  j   } |  j  j |  } |  j  j |  } |  j |  } d | k rW | } n
 d | } |  j | d | d S(   sD   create a new frontend attached to the same kernel as the current tabt   slaves
   (%s) slaveR=   N(   R   R/   t   indexOft   tabTextR   R1   (   R'   t   current_widgett   current_widget_indext   current_widget_nameR2   R=   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyt   create_tab_with_current_kernel   s    	
c         C   sh   |  j  j |  j  j    } t j j |  d d d | \ } } | rd |  j  j |  j  j   |  n  d S(   s    Set the title of the current tabs
   Rename Tabs
   New title:R4   N(   R   RF   t   currentIndexR   R6   R7   t
   setTabText(   R'   R9   R:   R;   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyt   set_tab_title   s    c         C   su  t  |  t k	 r' |  j j |  } n  |  j j |  } | d k rI d S|  j |  } d } t | d  r
| j } | d k	 r
x | D] } t	 | _
 q W| | k ry |  j |  j d  Wn1 t k
 r |  j j d  |  j j |  n X|  j   d Sq
n  | j } | j } | d k r>| j r>| j } n  | d k r| rg| j rg|  j   j   } t j j }	 t j j }
 | j rtd d |  j j |  d } d } t j d |   } | j  d	  t j d
 |   } | j  d  | j  d  t j t j j! | |  } | j" |  | j# |	  | j# | t j j$  | j# | t j j%  | j& |  | j' |	  t j( |  j) j* j+ t, j- d d    } | j. |  | j/   } | d k r,x: | D]2 } t0 | j j1  |  j j |  j j |   qW| j2   |  j j |  t0 | j1  q| d k r| j sQ| j d  n  |  j j |  t0 | j1  qqt j j3 |  | d d |
 |	 Bd |
 } | |
 k r|  j j |  qqgn | r|  j j |  t0 | j1  n |  j j |  | rg| j rgx: | D]2 } t0 | j j1  |  j j |  j j |   qW| rW| j2   n  t0 | j1  n  |  j   d S(   s    Called when you need to try to close a tab.

        It takes the number of the tab to be closed as argument, or a reference
        to the widget inside this tab
        Nt   _keep_kernel_on_exitt   exits<   Master already closed or not local, closing only current tabs   You are closing the tab : t   "sJ   Would you like to quit the Kernel and close all attached Consoles as well?s   &No, just this Tabt   Ns   &Yes, close allt   Ys   Ctrl+Di@   i   i    s	   exit Trues,   Are you sure you want to close this Console?s2   
The Kernel and other Consoles will remain active.t   defaultButton(4   t   typeR   R   RE   R2   t   Nonet   find_slave_widgetst   hasattrRN   R   t   _hiddent   find_master_tabt   executet   AttributeErrort   logt   infot	   removeTabR+   t   kernel_clientt   kernel_managert   _confirm_exitt	   _existingt   channels_runningt   windowR5   R   t   QMessageBoxt   Cancelt   Okt
   _may_closeRF   t   QPushButtont   setShortcutt   Questiont   setInformativeTextt	   addButtont   NoRolet   YesRolet   setDefaultButtont   setEscapeButtont   QPixmapR   t   icont   pixmapR   t   QSizet   setIconPixmapt   exec_R   t   stop_channelst   shutdown_kernelt   question(   R'   t   current_tabt   closing_widgett
   slave_tabst
   keepkernelt   tabR_   R`   R:   t   cancelt   okayt   msgR]   t   justthist   closeallt   boxRt   t   replyRD   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR      s    			

			* 
	
	 c         C   sW   | s d |  j  } n  |  j j | |  |  j   |  j |  | j j |  j  d S(   sP    insert a tab with a given frontend in the tab bar, and give it a name

        s	   kernel %iN(   R-   R   t   addTabR+   t   make_frontend_visiblet   exit_requestedR   R   (   R'   t   frontendR=   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR1     s    
c         C   s!   |  j  j |  j  j   d  d  S(   Ni   (   R   t   setCurrentIndexRK   (   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyt   next_tab  s    c         C   s!   |  j  j |  j  j   d  d  S(   Ni   (   R   R   RK   (   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyt   prev_tab!  s    c         C   s5   |  j  j |  } | d k r1 |  j  j |  n  d  S(   Ni    (   R   RE   R   (   R'   R   t   widget_index(    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR   $  s    c   	      C   s   t  | t  r$ |  j j |  } n  | j } g  t |  j j    D] } |  j j |  ^ qC } g  | D]0 } | j j | j k rh t | d  rh | ^ qh } g  | D] } | j	 r | ^ q } | r | St
 |  d k s t  t
 |  d k r d S| d S(   s  
        Try to return the frontend that owns the kernel attached to the given widget/tab.

            Only finds frontend owned by the current application. Selection
            based on port of the kernel might be inaccurate if several kernel
            on different ip use same port number.

            This function does the conversion tabNumber/widget if needed.
            Might return None if no master widget (non local kernel)
            Will crash if more than 1 masterWidget

            When asList set to True, always return a list of widget(s) owning
            the kernel. The list might be empty or containing several Widget.
        Rh   i   i    N(   t
   isinstanceR   R   R2   R_   t   rangeR)   RA   RW   Rh   t   lent   AssertionErrorRU   (	   R'   R   t   as_listt   kmt   it   widget_listR2   t   filtered_widget_listt   master_widget(    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyRY   )  s    	4"c            s   t  | t  r$ |  j j |  } n  | j   g  t |  j j    D] } |  j j |  ^ qC }   f d   | D } |  j | d t } g  | D] } | | k r | ^ q } | S(   s*  return all the frontends that do not own the kernel attached to the given widget/tab.

            Only find frontends owned by the current application. Selection
            based on connection file of the kernel.

            This function does the conversion tabNumber/widget if needed.
        c         3   s*   |  ]  } | j  j   j k r | Vq d  S(   N(   R_   RA   (   t   .0R2   (   R   (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pys	   <genexpr>a  s    R   (	   R   R   R   R2   R_   R   R)   RY   R   (   R'   R   R   R   R   t   master_widget_listR2   t
   slave_list(    (   R   s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyRV   P  s    		4%c         C   s:   | j  |  |  j  |  | r6 | j t j j  n  d S(   s?  Add action to menu as well as self
        
        So that when the menu bar is invisible, its actions are still available.
        
        If defer_shortcut is True, set the shortcut context to widget-only,
        where it will avoid conflict with shortcuts already bound to the
        widgets themselves.
        N(   t	   addActiont   setShortcutContextR   R%   t   WidgetShortcut(   R'   t   menut   actiont   defer_shortcut(    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyt   add_menu_actionk  s    	c         C   s@   |  j    |  j   |  j   |  j   |  j   |  j   d  S(   N(   t   init_file_menut   init_edit_menut   init_view_menut   init_kernel_menut   init_window_menut   init_help_menu(   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyt   init_menu_barz  s    




c         C   s?  |  j    j d  |  _ t j d |  d d d |  j |  _ |  j |  j |  j  t j d |  d d d |  j |  _	 |  j |  j |  j	  t j d |  d d	 d |  j
 |  _ |  j |  j |  j  |  j j   t j d
 |  d t j j d |  j |  _ |  j |  j |  j  t j d |  d t j j d |  j |  _ |  j |  j |  j t  |  j j   t j t j j  } | j d  rt j d k rd } n  t j d |  d | d |  j |  _ |  j |  j |  j t  t j d k r;|  j j   t j d |  d t j j d |  j |  _ |  j |  j |  j  n  d  S(   Ns   &Files   New Tab with &New kernelt   shortcuts   Ctrl+Tt	   triggereds   New Tab with Sa&me kernels   Ctrl+Shift+Ts   New Tab with &Existing kernels   Alt+Ts
   &Close Tabs   &Save to HTML/XHTMLs   Ctrl+Pt   darwins   Ctrl+Shift+Ps   &Prints   &Quit(   t   menuBart   addMenut	   file_menuR   t   QActionR3   t   new_kernel_tab_actR   RJ   t   slave_kernel_tab_actRC   t   existing_kernel_tab_actt   addSeparatort   QKeySequencet   Closet   close_active_frontendt   close_actiont   Savet   export_action_active_frontendt   export_actionR   t   Printt   matchest   syst   platformt   print_action_active_frontendt   print_actiont   QuitR*   t   quit_action(   R'   t   printkey(    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR     sV    								c      	   C   sA  |  j    j d  |  _ t j d |  d t j j d d d |  j |  _ |  j	 |  j |  j  t j d |  d t j j
 d d d |  j |  _ |  j	 |  j |  j  |  j j   t j d	 |  d t j j d |  j |  _ |  j	 |  j |  j t  t j d
 |  d t j j d |  j |  _ |  j	 |  j |  j t  t j d |  d d d |  j |  _ |  j	 |  j |  j t  t j d |  d t j j d |  j |  _ |  j	 |  j |  j t  |  j j   t j t j j  } | j d  r t j d k r d } n  t j d |  d | d |  j |  _ |  j	 |  j |  j t  d  S(   Ns   &Edits   &UndoR   t	   statusTips   Undo last action if possibleR   s   &Redos   Redo last action if possibles   &Cuts   &Copys   Copy (&Raw Text)s   Ctrl+Shift+Cs   &Pastes   Ctrl+AR   s   Ctrl+Shift+As   Select Cell/&All(    R   R   t	   edit_menuR   R   R   t   Undot   undo_active_frontendt   undo_actionR   t   Redot   redo_active_frontendt   redo_actionR   t   Cutt   cut_active_frontendt
   cut_actionR   t   Copyt   copy_active_frontendt   copy_actiont   copy_raw_active_frontendt   copy_raw_actiont   Pastet   paste_active_frontendt   paste_actiont	   SelectAllR   R   R   t   select_all_active_frontendt   select_all_action(   R'   t	   selectall(    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR     sV    								c   	   	      sg    j    j d    _ t j d k rj t j d   d d d d d   j   _   j	   j   j  n  t j d k r d	 n d
 } t j d   d | d d d   j
   _   j	   j   j    j j   t j d   d t j j d   j   _   j	   j   j t  t j d   d t j j d   j   _   j	   j   j t  t j d   d d d   j   _   j	   j   j t    j j   t j d   d d d d d   j   _   j	   j   j    j j d    _ t j d   d   f d   } t j d   d   f d   } t j d   d   f d   }   j j |    j j |    j j |    j   } t |  d k rc  j j d    _ t j    } x | D] } t j d j |    d |   f d  } | j  t  | j |    j j |  | d k r| j! t    j j" |  qqWn  d  S(    Ns   &ViewR   s   Toggle &Menu BarR   s   Ctrl+Shift+MR   s   Toggle visibility of menubarR   s   Ctrl+Meta+Ft   F11s   &Full Screens)   Toggle between Fullscreen and Normal Sizes   Zoom &Ins	   Zoom &Outs   Zoom &Resets   Ctrl+0s   &Clear Screens   Ctrl+Ls   Clear the consoles   &Pagers   .. &Horizontal Splitc              s     j  d  S(   Nt   hsplit(   t   set_paging_active_frontend(    (   R'   (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyt   <lambda>:  t    s    : &Vertical Splitc              s     j  d  S(   Nt   vsplit(   R   (    (   R'   (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR   >  R   s      &Inside Pagerc              s     j  d  S(   Nt   inside(   R   (    (   R'   (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR   B  R   i    s   &Syntax Styles   {}c            s     j  d |  S(   Nt   syntax_style(   t   set_syntax_style(   t   vR   (   R'   (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR   N  s    	t   default(#   R   R   t	   view_menuR   R   R   R   t   toggle_menu_bart   toggle_menu_bar_actR   t   toggleFullScreent   full_screen_actR   R   t   ZoomInt"   increase_font_size_active_frontendt   increase_font_sizeR   t   ZoomOutt"   decrease_font_size_active_frontendt   decrease_font_sizet   reset_font_size_active_frontendt   reset_font_sizet   clear_active_frontendt   clear_actiont
   pager_menuR   t   get_available_syntax_stylesR   t   syntax_style_menut   QActionGroupR@   t   setCheckablet
   setCheckedt   setDefaultAction(	   R'   t   fs_keyt   hsplit_actiont   vsplit_actiont   inside_actiont   available_syntax_stylest   style_groupt   styleR   (    (   R'   s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR     s    									c      	   C   s  |  j    j d  |  _ t j d k r- d n d } t j d |  d |  j d | d |  _ |  j	 |  j |  j  t j d	 |  d |  j
 d | d
 |  _ |  j	 |  j |  j  |  j j   t j d |  d t d |  j j d |  j |  _ |  j	 |  j |  j  |  j j j |  j  d  S(   Ns   &KernelR   t   Metat   Ctrls   &Interrupt current KernelR   R   s   +Cs   &Restart current Kernels   +.s   &Confirm kernel restartt	   checkablet   checked(   R   R   t   kernel_menuR   R   R   R   t    interrupt_kernel_active_frontendt   interrupt_kernel_actionR   t   restart_kernel_active_frontendt   restart_kernel_actionR   R   R0   t   confirm_restartt&   toggle_confirm_restart_active_frontendt   confirm_restart_kernel_actionR   t   currentChangedR   t   update_restart_checkbox(   R'   t   ctrl(    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR   Y  s(    					c      	   C   s  |  j    j d  |  _ t j d k r t j d |  d d d d d |  j |  _ t j d	 |  d d
 d d d |  j	 |  _
 |  j |  j |  j  |  j |  j |  j
  |  j j   n  t j d k r d n d } t j d |  d | d d d |  j |  _ |  j |  j |  j  t j d k r'd n d } t j d |  d | d d d |  j |  _ |  j |  j |  j  t j d |  d d d d d |  j |  _ |  j |  j |  j  t j d |  d d d d d |  j |  _ |  j |  j |  j  d  S(   Ns   &WindowR   s	   Mini&mizeR   s   Ctrl+mR   s'   Minimize the window/Restore Normal SizeR   s   &Zooms   Ctrl+Shift+Ms'   Maximize the window/Restore Normal Sizes   Ctrl+Alt+Lefts	   Ctrl+PgUps   Pre&vious Tabs   Select previous tabs   Ctrl+Alt+Rights   Ctrl+PgDowns	   Ne&xt Tabs   Select next tabs   Rename &Windows   Alt+Rs   Rename windows   &Rename Current Tabs   Ctrl+Rs   Rename current tab(   R   R   t   window_menuR   R   R   R   t   toggleMinimizedt   minimizeActt   toggleMaximizedt   maximizeActR   R   R   t   prev_tab_actR   t   next_tab_actR<   t   rename_window_actRM   t   rename_current_tab_act(   R'   t   prev_keyt   next_key(    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR   {  sR    						c         C   s   |  j    j d  |  _ t j d |  d |  j |  _ t j d |  d |  j |  _ |  j	 |  j |  j  |  j	 |  j |  j  d  S(   Ns   &Helps   Show &QtConsole helpR   s   Open online &help(
   R   R   t	   help_menuR   R   t
   _show_helpt   help_actiont   _open_online_helpt   online_help_actionR   (   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR     s    c         C   s    t  j j d |  j j j  d  S(   Ni   (   R   t   QTimert
   singleShotR0   t   _controlt   setFocus(   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyt   _set_active_frontend_focus  s    c         C   s9   |  j    } | j   r( | j t  n | j t  d  S(   N(   R   t	   isVisibleR"   R#   R   (   R'   t   menu_bar(    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR     s    c         C   s'   |  j    s |  j   n
 |  j   d  S(   N(   t   isMinimizedt   showMinimizedt
   showNormal(   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR    s    c         C   s   |  j  j t  d  S(   N(   R0   t   _pageR   (   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR    s    c         C   s   t  j d d d d t d  S(   Ns    https://qtconsole.readthedocs.iot   newi   t	   autoraise(   t
   webbrowsert   openR   (   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR!    s    c         C   s'   |  j    s |  j   n
 |  j   d  S(   N(   t   isMaximizedt   showMaximizedR,  (   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR    s    c         C   s   |  j    sK |  j   t j d k r |  j j t  |  j j t  q n< |  j   t j d k r |  j j t	  |  j j t	  n  d  S(   NR   (
   t   isFullScreent   showFullScreenR   R   R  t
   setEnabledR#   R  R,  R   (   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR     s    

c         C   s   |  j  j |  d  S(   N(   R0   t   _set_paging(   R'   t   paging(    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR     s    c         C   s   t  t    } t |  S(   s,   Get a list with the syntax styles available.(   t   listR   t   sorted(   R'   R   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR     s    c         C   s   | d k r d } n t  j |  r- d } n d } | |  j _ t  j | |  } | |  j _ |  j j   |  j j   |  j j d t	  |  j j
 d t	  d S(   s,   Set up syntax style for the current console.t   bwt   nocolort   linuxt   lightbgt   clears   %colors linuxN(   R   t
   dark_styleR0   R   t   sheet_from_templatet   style_sheett   _syntax_style_changedt   _style_sheet_changedt   resetR   t   _execute(   R'   R   t   colorsRB  (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR     s    		c         C   s   |  j  |  j  d  S(   N(   R   R0   (   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR     s    c         C   s   |  j  j   d  S(   N(   R0   t   request_restart_kernel(   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR    s    c         C   s   |  j  j   d  S(   N(   R0   t   request_interrupt_kernel(   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR	    s    c         C   s-   |  j  } | j | _ |  j j | j  d  S(   N(   R0   R  R  R   (   R'   R2   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR    s    	c         C   s3   |  j  d  k r d  S|  j  } |  j j | j  d  S(   N(   R0   RU   R  R   R  (   R'   R2   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR    s    	c         C   s   |  j  j   d  S(   N(   R0   R?  (   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR     s    c         C   s&   |  j  } | j   r" | j   n  d  S(   N(   R0   t   can_cutt   cut(   R'   R2   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR     s    	c         C   s   |  j  } | j   d  S(   N(   R0   t   copy(   R'   R2   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR   !  s    	c         C   s   |  j  j j   d  S(   N(   R0   t   _copy_raw_actiont   trigger(   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR   %  s    c         C   s&   |  j  } | j   r" | j   n  d  S(   N(   R0   t	   can_pastet   paste(   R'   R2   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR   (  s    	c         C   s   |  j  j   d  S(   N(   R0   t   undo(   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR   -  s    c         C   s   |  j  j   d  S(   N(   R0   t   redo(   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR   0  s    c         C   s   |  j  j j   d  S(   N(   R0   R   RN  (   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR   3  s    c         C   s   |  j  j j   d  S(   N(   R0   R   RN  (   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR   6  s    c         C   s   |  j  j j   d  S(   N(   R0   R   RN  (   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR   9  s    c         C   s   |  j  j j   d  S(   N(   R0   R   RN  (   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR   <  s    c         C   s   |  j  j j   d  S(   N(   R0   R   RN  (   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR   ?  s    c         C   s   |  j  j j   d  S(   N(   R0   R   RN  (   R'   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR   B  s    c         C   s  |  j  j   d k r# | j   d S|  j   j   } t j j } t j j } t j j	 } |  j
 rV|  j  j   d k r d } n d } d } t j d |   } | j d  t j t j j | |  }	 |	 j |  |	 j |  |	 j | t j j  |	 j |  |	 j |  t j |  j j j t j d	 d	    }
 |	 j |
  |	 j   } n | } | | k rv| j   d S| | k s| | k rx8 |  j  j   d k r|  j } t | _ |  j |  qW| j   n  d S(
   sH    Forward the close event to every tabs contained by the windows
        i    Ni   s+   Close all tabs, stop all kernels, and Quit?s%   Close console, stop kernel, and Quit?s=   Kernels not started here (e.g. notebooks) will be left alone.s   &Quitt   Qi@   (    R   R)   t   acceptRd   R5   R   Re   Rf   Rg   t
   AcceptRoleR   Ri   Rj   Rk   Rl   Rm   Ro   Rp   Rq   Rr   R   Rs   Rt   R   Ru   Rv   Rw   t   ignoreR0   R#   Ra   R   (   R'   t   eventR:   R   R   t   accept_roleR   R]   R   R   Rt   R   R2   (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyt
   closeEventI  sD    
		*
		N(<   t   __name__t
   __module__R   RU   R   R+   t   propertyR-   R.   R0   R3   R<   RC   RJ   RM   R   R1   R   R   R   R#   RY   RV   R   R   R   R   R   R   R   R   R'  R   R  R  R!  R  R   R   R   R   R   R  R	  R  R  R   R   R   R   R   R   R   R   R   R   R   R   R   RY  (    (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyR      sp   &			
			
	r			'				@	?	W	"	3																													(   t   __doc__R   R0  t	   threadingR    t   jupyter_core.pathsR   t   pygments.stylesR   t   qtconsole.qtR   R   t	   qtconsoleR   t   qtconsole.jupyter_widgetR   t   qtconsole.usageR   R   t   QMainWindowR   (    (    (    s3   lib/python2.7/site-packages/qtconsole/mainwindow.pyt   <module>   s   	