3
7ßL]a  ã               @   sˆ   d Z ddlZddlmZmZmZmZ ddlmZm	Z	m
Z
 ddlmZmZ ddlmZmZmZ ejƒ ZG dd„ deƒZG d	d
„ d
eƒZdS )zÄ
Module defining a simple Python shell task.

This task provides a view with a simple Python shell.  This shouldn't be
confused with a more full-featured shell, such as those provided by IPython.
é    N)ÚStrÚListÚDictÚInstance)ÚPythonShellÚ
FileDialogÚOK)ÚTaskÚTaskPane)ÚSMenuBarÚSMenuÚ
TaskActionc               @   s@   e Zd ZdZdZdZeeƒZe	e
ƒZe	eƒZdd„ Zdd„ ZdS )	ÚPythonShellPanez2 A Tasks Pane containing a Pyface PythonShell
    z&pyface.tasks.contrib.python_shell.panezPython Shellc             C   s�   t jdƒ t|ƒ| _| jj| _t jdƒ x2| jD ](}x"|jƒ D ]\}}| jj||ƒ q>W q0W t jdƒ x| jD ]}| jj	|ƒ qnW t jdƒ dS )zg Create the python shell task pane
        
        This wraps the standard pyface PythonShell
        z+PythonShellPane: creating python shell panez"PythonShellPane: binding variablesz+PythonShellPane: executing startup commandszPythonShellPane: createdN)
ÚloggerÚdebugr   ÚeditorÚcontrolÚbindingsÚitemsÚbindÚcommandsZexecute_command)ÚselfÚparentZbindingÚnameÚvalueÚcommand© r   úE/tmp/pip-install-5sebvq2j/pyface/pyface/tasks/contrib/python_shell.pyÚcreate    s    




zPythonShellPane.createc             C   s.   t jdƒ | jjƒ  d | _| _t jdƒ dS )z, Destroy the python shell task pane
        z-PythonShellPane: destroying python shell paneNzPythonShellPane: destroyed)r   r   r   Údestroyr   )r   r   r   r   r   6   s    

zPythonShellPane.destroyN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úidr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      s   r   c               @   sn   e Zd ZdZdZdZeeƒZee	ƒZ
eeƒZeeedddd�dd	d
�eddd
�ƒZdd„ Zdd„ Zdd„ ZdS )ÚPythonShellTaskzB
    A task which provides a simple Python Shell to the user.
    z!pyface.tasks.contrib.python_shellzPython ShellzOpen...ÚopenzCtrl+O)r   ÚmethodZacceleratorZFilez&File)r$   r   ZViewz&Viewc             C   s"   t jdƒ t| j| jd�| _| jS )z0 Create a view pane with a Python shell
        z*Creating Python shell pane in central pane)r   r   )r   r   r   r   r   Úpane)r   r   r   r   Úcreate_central_paneY   s    
z#PythonShellTask.create_central_panec             C   s6   t jdƒ t| jjdd�}|jƒ tkr2| j|jƒ dS )z( Shows a dialog to open a file.
        zPythonShellTask: opening filez*.py)r   ZwildcardN)	r   r   r   Zwindowr   r&   r   Ú
_open_fileÚpath)r   Údialogr   r   r   r&   b   s    
zPythonShellTask.openc             C   s    t jd| ƒ | jjj|ƒ dS )z? Execute the selected file in the editor's interpreter
        z$PythonShellTask: executing file "%s"N)r   r   r(   r   Zexecute_file)r   r+   r   r   r   r*   l   s    zPythonShellTask._open_fileN)r    r!   r"   r#   r$   r   r   r   r   r   r   r   r   r(   r   r   r   Zmenu_barr)   r&   r*   r   r   r   r   r%   ?   s   
	
r%   )r#   ÚloggingZ
traits.apir   r   r   r   Z
pyface.apir   r   r   Zpyface.tasks.apir	   r
   Zpyface.tasks.action.apir   r   r   Ú	getLoggerr   r   r%   r   r   r   r   Ú<module>   s   *