a
     ³Ša·  ã                   @   s„   d 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dlmZ dd	lmZ ed
ƒZG dd„ deƒZdS )z
Main interpreter Plugin.
é    N)ÚSlot)ÚPluginsÚSpyderPluginV2)Úon_plugin_available)Úget_translation)ÚMainInterpreterConfigPage)ÚMainInterpreterContainer)Úget_python_executableZspyderc                   @   s¨   e Zd ZdZdZejgZejgZ	e
ZeZeZdZdd„ Zdd„ Zdd	„ Zd
d„ Zeejddd„ ƒZeejddd„ ƒZdd„ Zedd„ ƒZdd„ Zeeƒdd„ ƒZdS )ÚMainInterpreterz"
    Main interpreter Plugin.
    Úmain_interpreterFc                 C   s   t dƒS )NzPython interpreter©Ú_©Úself© r   úDlib/python3.9/site-packages/spyder/plugins/maininterpreter/plugin.pyÚget_name,   s    zMainInterpreter.get_namec                 C   s   t dƒS )Nz)Main Python interpreter to open consoles.r   r   r   r   r   Úget_description/   s    zMainInterpreter.get_descriptionc                 C   s
   |   d¡S )NZpython)Zcreate_iconr   r   r   r   Úget_icon2   s    zMainInterpreter.get_iconc                 C   s|   |   ¡ }|j | j¡ |j | jj¡ |j | j¡ |  	d¡rx|  	d¡}t
 |¡sx|  dd¡ |  dd¡ |  dtƒ ¡ d S )NZcustomZcustom_interpreterFÚdefaultTÚ
executable)Úget_containerZsig_open_preferences_requestedZconnectÚ_open_interpreter_preferencesZsig_interpreter_changedÚ_mainZsig_main_interpreter_changedZ(sig_add_to_custom_interpreters_requestedÚ_add_to_custom_interpretersÚget_confÚospÚisfileÚset_confr	   )r   Ú	containerÚinterpreterr   r   r   Úon_initialize5   s     ÿÿÿ


zMainInterpreter.on_initialize)Zpluginc                 C   s   |   tj¡}| | ¡ d S ©N)Ú
get_pluginr   ÚPreferencesZregister_plugin_preferences)r   Úpreferencesr   r   r   Úon_preferences_availableP   s    z(MainInterpreter.on_preferences_availablec                 C   s    |   tj¡}|r| | j¡ d S r"   )r#   r   Ú	StatusBarZadd_status_widgetÚinterpreter_status)r   Z	statusbarr   r   r   Úon_statusbar_availableV   s    z&MainInterpreter.on_statusbar_availablec                 C   s   |   ¡ }| ¡ S )zGet current interpreter.)r   Zget_main_interpreter)r   r   r   r   r   Úget_interpreter^   s    zMainInterpreter.get_interpreterc                 C   s
   |   ¡ jS r"   )r   r(   r   r   r   r   r(   c   s    z"MainInterpreter.interpreter_statusc                 C   s8   | j  ¡  | j j}| ¡ }|j}| d¡}| |¡ dS )z<Open the Preferences dialog in the main interpreter section.r   N)r   Zshow_preferencesr%   r   ZdialogZget_index_by_nameZset_current_index)r   r%   r   ZdlgÚindexr   r   r   r   h   s    

z-MainInterpreter._open_interpreter_preferencesc                 C   s8   |   d¡}||vr(| |¡ |  d|¡ |  d|¡ dS )z0Add a new interpreter to the list of saved ones.Zcustom_interpreters_listr   N)r   Úappendr   )r   r    Zcustom_listr   r   r   r   q   s
    

z+MainInterpreter._add_to_custom_interpretersN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚNAMEr   r$   ZREQUIRESr'   ZOPTIONALr   ZCONTAINER_CLASSr   ZCONF_WIDGET_CLASSZCONF_SECTIONZ	CONF_FILEr   r   r   r!   r   r&   r)   r*   Úpropertyr(   r   r   Ústrr   r   r   r   r   r
      s,   




	r
   )r0   Úos.pathÚpathr   Zqtpy.QtCorer   Zspyder.api.pluginsr   r   Z)spyder.api.plugin_registration.decoratorsr   Zspyder.api.translationsr   Z'spyder.plugins.maininterpreter.confpager   Z(spyder.plugins.maininterpreter.containerr   Zspyder.utils.miscr	   r   r
   r   r   r   r   Ú<module>   s   