B
    nôb\‹( ã               @   s¦  d Z ddlmZ ddlZddlZddlZddlmZ ddl	Z	ddl
Z
ddlZddlZddlZddlZddlZejZddlmZ e ¡  e ¡  e ¡  dZdZdZejdkrÀddlmZmZmZ yddlZW n ek
rà   Y nX ddlm Z m!Z! ddl"m#Z# dd	l$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z. dd
l/m0Z0m1Z1m2Z2m3Z3m4Z4 ddl5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z> ddlm?Z? ddlm@Z@ yddlAmBZBmCZC W n eDk
rÀ   d ZBZCY nX ddlEmFZF ddlGmHZH eIe)dƒrüe& Je)jKeH Ldd¡¡ ddlMmNZNmOZO ddlPmQZQ eNƒ aRe!r2e2eQdƒƒZSne2eQdƒƒZStR TeS¡ ddlPmUZUmQZQmVZVmWZW eWƒ sÌe=e4eQdƒƒƒZXeX Y¡ ZZeZ [d¡ eX \eZ¡ eX ]¡  eX ^eUdƒe)j_e)j`B e)jaB e0e)jbƒ¡ e7 c¡  ndZXddlmdZdmeZemfZfmgZgmhZhmiZimjZj ddlPmkZkmlZlmmZmmnZnmoZompZpmqZqmrZrmsZsmtZt ddlGmuZu ddlvmwZwmxZx dd lymzZz dd!lm{Z{ dd"l|m}Z}m~Z~mZm€Z€mZ‚ 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ŒmZmŽZŽmZ dd(lm‘Z‘ ydd)l’m“Z“ W n ek
rò   dZ“Y nX dd*lMm”Z”m•Z•m–Z–m—Z—m˜Z˜m™Z™mšZšm›Z›mœZœ dd+lmžZž dd,lŸm Z  dd-l¡m¢Z¢ eŽƒ Z£d.d/„ Z¤d0d1„ Z¥G d2d3„ d3e9ƒZ¦d4d5„ Z§G d6d7„ d7e¨ƒZ©d8d9„ Zªd:d„ Z«e¬d;kr¢e«ƒ  dS )<u&  
Spyder, the Scientific Python Development Environment
=====================================================

Developped and maintained by the Spyder Project
Contributors

Copyright Â© Spyder Project Contributors
Licensed under the terms of the MIT License
(see spyder/__init__.py for details)
é    )Úprint_functionN)ÚrequirementsÚnt)Úset_attached_console_visibleÚis_attached_console_visibleÚset_windows_appusermodelid)ÚAPIÚPYQT5)Úfrom_qvariant)
Ú
QByteArrayÚQCoreApplicationÚQPointÚQSizeÚQtÚQThreadÚQTimerÚQUrlÚSignalÚSlot)ÚQColorÚQDesktopServicesÚQIconÚQKeySequenceÚQPixmap)	ÚQActionÚQApplicationÚQDockWidgetÚQMainWindowÚQMenuÚQMessageBoxÚ	QShortcutÚQSplashScreenÚQStyleFactory)ÚQtSvg)ÚQtWebEngineWidgets)ÚQQuickWindowÚQSGRendererInterface)Ú	FontError)ÚCONFÚAA_EnableHighDpiScalingÚmainZhigh_dpi_scaling)ÚqapplicationÚMENU_SEPARATOR)Úget_image_pathz
spyder.svgz
spyder.png)Ú_r-   ÚDEVÚrunning_under_pytestz
splash.svgé
   zInitializing...)Ú__version__Ú__project_url__Ú__forum_url__Ú__trouble_url__Ú__trouble_url_short__Ú__website_url__Úget_versions)
Úget_conf_pathÚget_module_source_pathÚSTDERRÚDEBUGÚdebug_printÚMAC_APP_NAMEÚget_home_dirÚrunning_in_mac_appÚget_module_pathÚreset_config_files)ÚOPEN_FILES_PORT)Ú
IMPORT_EXTÚis_gtk_desktop)Úget_options)Údependencies)Úis_text_stringÚto_text_stringÚPY3Úqbytearray_to_strÚconfigparser)ÚencodingÚprograms)Úicon_manager)Úmodule_completion)Úis_module_installed)Úselect_portÚgetcwd_or_homeÚget_python_executable)ÚFileSwitcher)ÚWinUserEnvDialog)	Úcreate_actionÚadd_actionsÚget_iconÚadd_shortcut_to_tooltipÚcreate_module_bookmark_actionsÚcreate_program_actionÚDialogManagerÚcreate_python_script_actionÚfile_uri)Úget_shortcut)Úget_spyderplugins_mods)Útourc              C   s   t jdkrTt tjd¡} t | ¡s&dS dd„ t  | ¡D ƒ}|rntt | |d ¡ƒS ntj	}d|d |d f } t | d	¡}t 
|¡rŒt|ƒS dS )
zc
    Return Python documentation path
    (Windows: return the PythonXX.chm path if available)
    r   ÚDocNc             S   s   g | ]}t  d |¡r|‘qS )z(?i)Python[0-9]{3,6}.chm)ÚreÚmatch)Ú.0Úpath© rh   ú4lib/python3.7/site-packages/spyder/app/mainwindow.pyú
<listcomp>Ñ   s    z'get_python_doc_path.<locals>.<listcomp>r   z/usr/share/doc/python%d.%d/htmlé   z
index.html)ÚosÚnameÚospÚjoinÚsysÚprefixÚisdirÚlistdirr_   Úversion_infoÚisfile)Zdoc_pathZ
python_chmZvinfZ
python_docrh   rh   ri   Úget_python_doc_pathÈ   s    


rv   c             C   s€   | dkr*t  tj¡ tdk	r|t tj¡ nR| dkrTt  tj¡ tdk	r|t tj	¡ n(| dkr|t  tj
¡ tdk	r|t tj	¡ dS )z\
    Set the OpenGL implementation used by Spyder.

    See issue 7447 for the details.
    ÚsoftwareNÚdesktopÚgles)r   ÚsetAttributer   ÚAA_UseSoftwareOpenGLr%   ZsetSceneGraphBackendr&   ZSoftwareÚAA_UseDesktopOpenGLZOpenGLÚAA_UseOpenGLES)Úoptionrh   rh   ri   Úset_opengl_implementationÝ   s    r   c            
   @   s2  e Zd ZdZejejB Ze 	¡ Z
edƒZedƒZddedƒfdded	ƒfd
dedƒfddedƒfddedƒfddedƒfddedƒffZdZeƒ Zeƒ Zeƒ ZeeƒZedƒZedƒZd×dd„Zdd„ ZdØd!d"„Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ ZdÙd-d.„Z d/d0„ Z!d1d2„ Z"dÚd3d4„Z#d5d6„ Z$dÛd7d8„Z%d9d:„ Z&d;d<„ Z'e(ƒ d=d>„ ƒZ)e(ƒ d?d@„ ƒZ*dÜdBdC„Z+dDdE„ Z,e(ƒ dFdG„ ƒZ-dHdI„ Z.dJdK„ Z/dLdM„ Z0dNdO„ Z1dPdQ„ Z2dRdS„ Z3dTdU„ Z4e(ƒ dVdW„ ƒZ5dXdY„ Z6dZd[„ Z7d\d]„ Z8d^d_„ Z9d`da„ Z:dbdc„ Z;ddde„ Z<dfdg„ Z=dhdi„ Z>djdk„ Z?dldm„ Z@dndo„ ZAdpdq„ ZBdrds„ ZCdtdu„ ZDdvdw„ ZEdxdy„ ZFdÝdzd{„ZGd|d}„ ZHe(ƒ d~d„ ƒZId€d„ ZJd‚dƒ„ ZKe(ƒ e(eLƒdÞd„d…„ƒƒZMd†d‡„ ZNe(ƒ dˆd‰„ ƒZOdŠd‹„ ZPe(ƒ dŒd„ ƒZQe(ƒ dŽd„ ƒZRdßd‘d’„ZSe(ƒ dàd“d”„ƒZTe(ƒ d•d–„ ƒZUe(ƒ d—d˜„ ƒZVe(ƒ d™dš„ ƒZWd›dœ„ ZXdáddž„ZYdŸd „ ZZdâd¡d¢„Z[d£d¤„ Z\d¥d¦„ Z]d§d¨„ Z^d©dª„ Z_e(ƒ d«d¬„ ƒZ`d­d®„ Zae(ƒ d¯d°„ ƒZbd±d²„ Zcd³d´„ Zddµd¶„ Zee(ƒ d·d¸„ ƒZfd¹dº„ Zgd»d¼„ Zhdãd½d¾„Zid¿dÀ„ Zje(ƒ dÁdÂ„ ƒZkdÃdÄ„ Zle(ƒ dÅdÆ„ ƒZme(ƒ dädÇdÈ„ƒZndÉdÊ„ ZodådËdÌ„ZpdÍdÎ„ ZqdÏdÐ„ ZrdÑdÒ„ Zse(ƒ dædÓdÔ„ƒZtdÕdÖ„ ZudS )çÚ
MainWindowzSpyder main windowrg   Únot_active_pathZPython2z$https://docs.python.org/2/index.htmlzPython2 documentationZPython3z$https://docs.python.org/3/index.htmlzPython3 documentationZnumpyzhttps://docs.scipy.org/doc/zNumpy and Scipy documentationZ
matplotlibz$https://matplotlib.org/contents.htmlzMatplotlib documentationZPyQt5z'http://pyqt.sourceforge.net/Docs/PyQt5/zPyQt5 Reference Guidez;http://pyqt.sourceforge.net/Docs/PyQt5/class_reference.htmlzPyQt5 API ReferenceÚ	winpythonzhttps://winpython.github.io/Z	WinPythoné   ZQResizeEventZ
QMoveEventNc          
   C   sš  t  | ¡ t ¡ }tr"| tj¡ t| 	¡  
¡ ƒ| _tƒ | _|j| _|j| _|j| _|j| _|j| _|j| _|  d¡ d!dd„}tjdkrºydd l}| |d¡ W qÚ tk
r¶   Y qÚX n t tj|¡ tsÚt tj|¡ t j!dkr&t"dƒ}t# $|d	¡}t%t# $|d
d¡ƒ &¡ }| 'd|¡}|  (|¡ g | _)g | _*g | _+g | _,t# -| j.¡rpt/ 0| j.¡\| _*}dd„ | j*D ƒ| _*t# -| j1¡r¢t/ 0| j1¡\| _+}dd„ | j+D ƒ| _+|  2¡  |  3¡  d | _4d | _5d | _6d | _7d | _8d | _9d | _:d | _;d | _<d | _=d | _>d | _?d | _@g | _Ad | _Bd | _Cd | _Dd | _Ed | _Fd | _Gd| _HddlImJ}	mK}
 ddlLmM} ddlNmO} ddlPmQ} |	||
||g| _Rd | _Sd | _TddlUmV}mW} || _X|| _Yd | _Zd | _[d | _\d | _]d | _^d | __d | _`d | _ad | _bd | _cd | _dd | _eg | _fd | _gg | _hd | _ig | _jd | _kg | _ld | _mg | _nd | _og | _pd | _qg | _rd | _sg | _td | _ug | _vd | _wg | _xd | _yd | _zg | _{d | _|d | _}g | _~d | _d | _€g | _g | _‚d | _ƒg | _„d | _…g | _†d | _‡g | _ˆd | _‰g | _Šd | _‹g | _Œd | _g | _Žd | _g | _d | _‘g | _’t“ƒ rt” •ddd¡ |  –¡  t—d kr0t—ƒ }tdt|ƒ ƒ tj˜ ™dd ¡}|d k	rrd}tš| ƒ| _›| j›jœ tžjŸ¡ | j›  |¡ t¡| _¢t” ™ddd¡t£kršt” •ddt£¡ g | _¤d| _¥d| _¦d| _§t” ™dd¡| _¨g | _©d | _ªd | _«d | _¬d | _­d | _®d | _¯d | _°d | _±d | _²d | _³d | _´tjdkrnytµ µtµj¶tµj·tµj¸¡| _¹W n< tºk
rj } zd | _¹t» ¼d dt½dƒ¡ W d d }~X Y nX ntµ µtµj¶tµj·tµj¸¡| _¹|  ¾¡  |  d ¡ d S )"NzStart of MainWindow constructorc             S   s&   t j d|  ¡ t j ¡  t ¡  dS )zHandler for signals.zHandling signal: %s
N)rp   ÚstdoutÚwriteÚflushr   Úquit)ZsignumÚframerh   rh   ri   Úsignal_handler*  s    
z+MainWindow.__init__.<locals>.signal_handlerr   r   TÚdarwinÚspyderZimagesÚappzmac_stylesheet.qssz$IMAGE_PATHc             S   s   g | ]}t  |¡r|‘qS rh   )rn   rr   )rf   rm   rh   rh   ri   rj   O  s    z'MainWindow.__init__.<locals>.<listcomp>c             S   s   g | ]}t  |¡r|‘qS rh   )rn   rr   )rf   rm   rh   rh   ri   rj   T  s    )ÚMainConfigPageÚColorSchemeConfigPage)ÚShortcutsConfigPage)ÚRunConfigPage)ÚMainInterpreterConfigPage)ÚLayoutSaveDialogÚLayoutSettingsDialogr*   Zshow_internal_errorsFzappusermodelid: ZTEST_CI_APPi0u  Zcurrent_versionÚ Úpanes_lockedÚSpyderzðAn error occurred while creating a socket needed by Spyder. Please, try to run as an Administrator from cmd.exe the following command and then restart your computer: <br><br><span style='color: #555555'><b>netsh winsock reset</b></span><br>zEnd of MainWindow constructor)N)¿r   Ú__init__r   Úinstancer	   rz   r   ZAA_UseHighDpiPixmapsÚstrÚstyleÚ
objectNameÚdefault_styler]   Údialog_managerÚworking_directoryÚinit_workdirÚprofileÚmultithreadedÚnew_instanceÚprojectÚopen_projectÚwindow_titler=   rl   rm   Úwin32apiZSetConsoleCtrlHandlerÚImportErrorÚsignalÚSIGTERMr/   ÚSIGINTrp   Úplatformr:   rn   ro   ÚopenÚreadÚreplaceZsetStyleSheetÚshortcut_datarg   r   Úproject_pathru   ÚSPYDER_PATHrM   Ú	readlinesÚSPYDER_NOT_ACTIVE_PATHÚremove_path_from_sys_pathÚadd_path_to_sys_pathÚconsoleÚworkingdirectoryÚeditorÚexplorerÚhelpÚ
onlinehelpÚprojectsÚoutlineexplorerÚ
historylogZ
extconsoleÚ
ipyconsoleÚvariableexplorerÚfindinfilesÚthirdparty_pluginsrb   Útours_availableÚfileswitcherÚcheck_updates_actionÚthread_updatesÚworker_updatesÚgive_updates_feedbackÚspyder.plugins.configdialogr   rŽ   Zspyder.plugins.shortcutsr   Zspyder.plugins.runconfigr   Zspyder.plugins.maininterpreterr‘   Úgeneral_prefsÚprefs_indexÚprefs_dialog_sizeZspyder.plugins.layoutdialogr’   r“   Údialog_layout_saveÚdialog_layout_settingsÚlock_dockwidgets_actionÚshow_toolbars_actionÚclose_dockwidget_actionÚundo_actionÚredo_actionÚcopy_actionÚ
cut_actionÚpaste_actionÚselectall_actionÚmaximize_actionÚfullscreen_actionÚ	file_menuÚfile_menu_actionsÚ	edit_menuÚedit_menu_actionsÚsearch_menuÚsearch_menu_actionsÚsource_menuÚsource_menu_actionsÚrun_menuÚrun_menu_actionsÚ
debug_menuÚdebug_menu_actionsÚconsoles_menuÚconsoles_menu_actionsÚprojects_menuÚprojects_menu_actionsÚ
tools_menuÚtools_menu_actionsÚexternal_tools_menuÚexternal_tools_menu_actionsÚ	view_menuÚplugins_menuÚplugins_menu_actionsÚtoolbars_menuÚ	help_menuÚhelp_menu_actionsÚ
mem_statusÚ
cpu_statusÚvisible_toolbarsÚtoolbarslistÚmain_toolbarÚmain_toolbar_actionsÚfile_toolbarÚfile_toolbar_actionsÚedit_toolbarÚedit_toolbar_actionsÚsearch_toolbarÚsearch_toolbar_actionsÚsource_toolbarÚsource_toolbar_actionsÚrun_toolbarÚrun_toolbar_actionsÚdebug_toolbarÚdebug_toolbar_actionsZlayout_toolbarZlayout_toolbar_actionsr0   r(   ÚsetÚset_window_titler   ÚenvironÚgetr   Ztimer_shutdownÚtimeoutÚconnectÚMAIN_APPr‡   ÚstartÚSPLASHÚsplashr2   Ú
widgetlistÚalready_closedÚis_starting_upÚis_setting_upÚdockwidgets_lockedÚfloating_dockwidgetsÚwindow_sizeÚwindow_positionÚstate_before_maximizingÚcurrent_quick_layoutZprevious_layout_settingsÚlast_pluginÚfullscreen_flagÚmaximized_flagÚsaved_normal_geometryÚlast_focused_widgetÚprevious_focused_widgetÚsocketZAF_INETZSOCK_STREAMZIPPROTO_TCPÚopen_files_serverÚOSErrorr   Úwarningr.   Úapply_settings)ÚselfÚoptionsÚqappr‰   r¦   Zspy_pathZimg_pathZ	mac_styleZ_xr   rŽ   r   r   r‘   r’   r“   ZresZtest_travisZtimer_shutdown_timeÚerh   rh   ri   r—     sb   








zMainWindow.__init__c             C   s   t |ƒ dS )zDebug printsN)r=   )r%  Úmessagerh   rh   ri   r=     s    zMainWindow.debug_printé   c             C   s4   |   |¡}| |¡ | t||ƒ¡ | j |¡ |S )z8Create and return toolbar with *title* and *object_name*)Z
addToolBarÚsetObjectNameZsetIconSizer   r÷   Úappend)r%  ÚtitleZobject_nameZiconsizeÚtoolbarrh   rh   ri   Úcreate_toolbar  s
    

zMainWindow.create_toolbarc       M         s¤  ˆ  d¡ ˆ  d¡ tˆt d¡tdƒˆjtjdˆ_ˆ 	ˆjdd¡ tˆtdƒˆj
tjd	ˆ_ˆ 	ˆjdd
¡ tˆtdƒˆjtjdˆ_tˆtdƒˆjtjdˆ_ˆ 	ˆjdd¡ ˆ 	ˆjdd¡ tˆtdƒt d¡tdƒˆjtjdˆ_ˆj	ˆjddd tˆtdƒt d¡tdƒˆjtjdˆ_ˆj	ˆjdddd ˆjˆjgˆ_‡fdd„}|dtdƒt d¡ƒˆ_|dtdƒt d¡ƒˆ_|d td ƒt d!¡ƒˆ_|d"td"ƒt d#¡ƒˆ_|d$td$ƒt d%¡ƒˆ_|d&td&ƒt d'¡ƒˆ_ˆjˆjd(ˆjˆjˆjˆjgˆ_d(}ˆ  d)¡ ˆ ¡  td*ƒ¡ˆ_ˆ td+ƒd,¡ˆ_ ˆ ¡  td-ƒ¡ˆ_!ˆ td.ƒd/¡ˆ_"ˆ ¡  td0ƒ¡ˆ_#ˆ td1ƒd2¡ˆ_$ˆ ¡  td3ƒ¡ˆ_%ˆ td4ƒd5¡ˆ_&ˆ ¡  td6ƒ¡ˆ_'ˆ td7ƒd8¡ˆ_(ˆ ¡  td9ƒ¡ˆ_)ˆ td:ƒd;¡ˆ_*ˆ ¡  td<ƒ¡ˆ_+ˆ ¡  td=ƒ¡ˆ_,ˆj,j- .ˆj/¡ ˆ ¡  td>ƒ¡ˆ_0ˆ ¡  td?ƒ¡ˆ_1ˆ ¡  td@ƒ¡ˆ_2ˆ 3¡ }| 4dA¡ | 5tdBƒdC¡ ˆ  dD¡ tˆtdEƒt dF¡ˆj6tjdG}ˆj	|ddHddI tˆtdJƒd(t dK¡ˆj7tdLƒt8j9dM}tˆtdNƒdOdP„ tdQƒdR}tˆtdSƒˆj:dT}||gˆ_;t<d(k	r\tˆtdUƒdVtdWƒˆj=dX}ˆj; >|¡ ˆ j;|t?|g7  _;t@tdYƒƒˆ_Ag ˆ_BtˆtdZƒtCd[ƒd\dP„ d]ˆ_DtEjFd^krÆtGd_ƒrÆˆjB >ˆjD¡ g }	x&d`D ]}
tHˆtdaƒ|
ƒ}|rÐP qÐW x&dbD ]}
tHˆtdcƒddƒ}|røP qøW tEjFd^kr,degng }x"||fD ]}|r:|	 >|¡ q:W |	rxtGd_ƒrxˆ jBd(g|	 7  _Bˆ  df¡ g }yLdgdhlImJ} dgdilImK} | Cdj¡}tLˆtdkƒ|dltM Ndmdn¡ƒ}||g7 }W n   Y nX yˆdgdhlImJ} dgdilOmK} | Cdo¡}tLˆtdpƒ|dqtM Ndmdn¡ƒ}|r0||g7 }| Cdr¡}tLˆtdsƒ|dqtM Ndmdt¡ƒ}|rf||g7 }W n   Y nX |rˆ jBd(g| 7  _BtˆduˆjPtjdˆ_Qˆ 	ˆjQddv¡ ˆ R¡  tˆtdwƒˆjStjdˆ_Tˆj	ˆjTddwddI ˆjQˆjTd(||gˆ_Uˆ tdxƒdy¡ˆ_Vˆ  dz¡ dgd{lWmX} |ˆ|ˆjYˆjZˆj[td|ƒd}ˆ_\ˆj\ ]¡  ˆ  d~¡ dgdl^m_} |ˆˆj`ˆd€ˆ_aˆja ]¡  ˆjb >ˆja¡ tc ddd‚¡rÎˆ etdƒƒ¡ dgd„lfmg} |ˆƒˆ_hˆjh ]¡  tc dd…d‚¡r
ˆ etd†ƒ¡ dgd‡limj} |ˆƒˆ_kˆjk ]¡  ˆ etdˆƒ¡ dgd‰llmm} |ˆƒˆ_nˆjn ]¡  tˆtdŠƒt d‹¡tdŒƒˆj\jotjd}ˆ 	|ddŒ¡ tˆtdƒt dŽ¡tdƒˆjptjd}ˆ 	|dd¡ ˆ jqˆjˆjd(||g7  _qˆ edu¡ ˆ  d¡ tc dd‘d‚¡	rˆ etd’ƒ¡ dgd“lrms} |ˆƒˆ_tˆjt ]¡  tc dd”d‚¡	rJˆ etd•ƒ¡ dgd–lumv}  | ˆƒˆ_wˆjw ]¡  ydgd—lxmy}! W n tzk
	rt   d(}!Y nX tc dd˜d‚¡	r°|!d(k		r°ˆ etd™ƒ¡ |!ˆƒˆ_{ˆj{ ]¡  ˆ etdšƒ¡ dgd›l|m}}" |"ˆƒˆ_~ˆj~ ]¡  ˆj~jddœˆ_€tc ddd‚¡
rdgdžlm‚}# |#ˆƒˆ_ƒˆjƒ ]¡  ˆ etdŸƒ¡ dgd l„m…}$ |$ˆƒˆ_†ˆj† ]¡  ˆ etd¡ƒ¡ dgd¢l‡mˆ}% |%ˆƒˆ_‰ˆj‰ ]¡  ˆ etd£ƒ¡ tˆtd¤ƒˆjŠdT}&tˆtd¥ƒˆj‹t d¦¡d§}'tˆtd¨ƒt d©¡ˆjŒd]}(tˆtdªƒˆjdT})tˆtd«ƒˆjŽdTˆ_d¬‰tˆtd­ƒt d®¡‡fd¯dP„d]}*ˆ 	|*dd°¡ ˆjhd(k	rTtˆtd±ƒˆjhjdT}+nd(}+tˆtd²ƒd³ˆj‘d´},t’ “ˆ¡ˆ_’t@tdµƒƒˆ_”g ˆ_•t’ –dg¡ˆ_—x^t˜ˆj—ƒD ]P\}-}.dgˆj—|- d¶< |.d· }/|-ˆfd¸d¹„}0tˆ|/du|0ƒ dº}1ˆ j•|1g7  _•q¦W ˆj” ™ˆj•¡ |*|+|,ˆj”t?|&|(|'ˆj|)t?gˆ_št›ƒ d(k	rVtˆtd»ƒd¼dP„ dT}2ˆjš >|2¡ ˆjhd(k	rÎt@td½ƒˆƒ}3tˆtd¾ƒˆj‰jœdT}4tˆtd¿ƒˆj‰jdT}5tˆtdÀƒˆj‰jždT}6tŸ|3|4|6|5fƒ ˆjš >|3¡ g ‰ ‡ ‡fdÁdÂ„}7tM Nt j¡dÃ¡}8tM ¢|8¡rRxVtE £|8¡D ]H}9dÄ}:t¤ ¥|:|9¡};|;d(k	r|; ¦¡ dg }<|<dÅkr|7|<tM N|8|9¡ƒ qW ˆ r|t@tdÆƒˆƒ}=tŸ|=ˆ ƒ ˆjš >|=¡ t@tdÇƒƒ}>t§ˆˆj¨ƒ}?|? ©dÈd(¡ |? ©dÉd(¡ |? ©dÊd(¡ tŸ|>|?ƒ ˆjš >|>¡ t jª «dË¡rèt¬sèdÌ}@ndÍ}@tHˆtdÎƒ|@ƒ}A|Arˆ jš|Ad(g7  _štˆtdÏƒdÐ t dÑ¡ˆj­d]}Bˆ jšt?|Bg7  _šdgdÒl®m¯}Cm°}D |Cˆ|ƒˆ_±|Dˆ|ƒˆ_²ˆ ³¡  x®t´ƒ D ]¤}EyT|E µˆ¡}Fy|F ¶¡ dg }GW n t·k
r¸   d}GY nX |GrÔˆj¸ >|F¡ |F ]¡  W nH t¹k
r }H z(tºdÓ|Et»|Hƒf t¼dÔ t½j¾t¼dÔ W d(d(}H~HX Y nX q~W t@tdÕƒˆƒˆ_¿t@tdÖƒˆƒˆ_Àt@td×ƒˆƒˆ_Áˆ Â¡  ˆj1 ˆj¿¡ tŸˆj1ˆjˆjˆjQt?fƒ tˆtdØƒˆjÃtjdˆ_Äˆ 	ˆjÄddØ¡ ˆj1 ˆjÀ¡ ˆj1 ÅˆjÄ¡ tŸˆj1t?ˆjÁˆjˆjt?ˆjTfƒ tÆd(k	r$tˆtdÙƒtÆdÚ}I|I ÇtÈƒ ¡ tŸˆj1t?|Ifƒ ˆjBrXtˆtdYƒƒ}J|J ÉˆjA¡ ˆ j;d(|Jg7  _;tŸˆjˆjqƒ tŸˆj!ˆjƒ tŸˆj#ˆjÊƒ tŸˆj%ˆjËƒ tŸˆj'ˆjÌƒ tŸˆj)ˆjÍƒ tŸˆj+ˆjÎƒ tŸˆj,ˆjÏƒ tŸˆj0ˆj;ƒ tŸˆjAˆjBƒ tŸˆj2ˆjšƒ tŸˆjVˆjUƒ tŸˆj ˆjƒ tŸˆj"ˆjÐƒ tŸˆj$ˆjÑƒ tŸˆj&ˆjÒƒ tŸˆj*ˆjÓƒ tŸˆj(ˆjÔƒ ˆ Õ¡  ˆjÖ ×¡  ˆ  dÛ¡ ˆjØdÜdÝ t jªdÞkrÖxLdßD ]D}
tÙˆ|
dà ƒ}K|Kj- .|
f‡fdádP„	¡ |KjÚ .|
f‡fdâdP„	¡ qŽW ˆjÛd(k	rìˆjÛ Ü¡  tc ddãdä¡r4x8ˆ ¡  Ý¡ D ](}LtÞ|Lt@ƒr|Lˆj2kr|L ßd¡ qW xZˆ ¡  Ý¡ D ]J}LtÞ|Lt@ƒrBy |Lj- .ˆjà¡ |Lj- .ˆjá¡ W n tâk
rˆ   Y nX qBW ˆ  då¡ dÜˆ_ãd(S )æzSetup main windowz!*** Start of MainWindow setup ***z  ..core actionsZDialogCloseButtonzClose current pane)ÚiconÚtextÚ	triggeredÚcontextr.   z
Close panez
Lock panes)Útoggledr3  zLock unlock paneszUse next layout)r2  r3  zUse previous layoutzFile switcher...ZfilelistzFast switch between files)r0  Útipr2  r3  zFile switcher)r3  rm   zSymbol finder...Zsymbol_findzFast symbol search in filezsymbol finderT)r3  rm   Úadd_sc_to_tipc                sR   |   d¡}|d  ¡ d |dd … ¡ }tˆ ||ˆ j|tjd}ˆ  |d| ¡ |S )Nú r   r”   rk   )r0  r2  Údatar3  ÚEditor)ÚsplitÚlowerro   rW   Úglobal_callbackr   ZWidgetShortcutÚregister_shortcut)r1  Ztr_textr0  ZtextseqZmethod_nameÚaction)r%  rh   ri   Úcreate_edit_actionY  s    

z,MainWindow.setup.<locals>.create_edit_actionZUndoZundoZRedoZredoZCopyZeditcopyZCutZeditcutZPasteZ	editpastez
Select AllZ	selectallNz  ..toolbarsz&FilezFile toolbarrú   z&EditzEdit toolbarrü   z&SearchzSearch toolbarrþ   zSour&cezSource toolbarr   z&RunzRun toolbarr  z&DebugzDebug toolbarr  z	C&onsolesz	&Projectsz&Toolsz&Viewz&HelpZ	StatusBarzWelcome to Spyder!iˆ  z	  ..toolszPre&ferencesZ	configure)r0  r2  r3  ZPreferences)r6  zPYTHONPATH managerZ
pythonpathzPython Path Manager)r0  r2  r5  ZmenurolezUpdate module names listc               S   s   t  ¡ S )N)rP   Úresetrh   rh   rh   ri   Ú<lambda>»  s    z"MainWindow.setup.<locals>.<lambda>z4Refresh list of module names available in PYTHONPATH)r2  r5  z Reset Spyder to factory defaults)r2  z%Current user environment variables...zwin_env.pngz\Show and edit current user environment variables in Windows registry (i.e. for all sessions))r0  r5  r2  zExternal ToolszWinPython control panelzwinpython.svgc               S   s   t  dd¡S )Nr‚   Zcontrolpanel)rN   Úrun_python_scriptrh   rh   rh   ri   rA  Õ  s    )r0  r2  r   r‚   )zdesigner-qt4ZdesignerzQt Designer)zlinguist-qt4ÚlinguistzQt LinguistrC  z
-no-openglz	  ..sift?r   )Úconfigtools)Úconfigzguidata.svgzguidata examplesÚguidataZtestsr—   z
guiqwt.svgzguiqwt examplesÚguiqwtzsift.svgZSiftZsiftr”   zMaximize panezFullscreen modezMain toolbarrø   z  ..plugin: internal console)ÚConsolezØSpyder Internal Console

This console is used to report application
internal errors and to inspect Spyder
internals with the following commands:
  spy.app, spy.window, dir(spy)

Please don't use it to run your code

)Zexitfuncr    r¡   r)  z  ..plugin: working directory)ÚWorkingDirectory)r*   rº   ÚenablezLoading help...)ÚHelpÚoutline_explorerzLoading outline explorer...)ÚOutlineExplorerzLoading editor...)r9  z&QuitÚexitZQuitz&RestartÚrestartZRestartz  ..widgetsr¹   zLoading file explorer...)ÚExplorerr¾   zLoading history plugin...)Ú
HistoryLog)Ú
OnlineHelpr»   zLoading online help...zLoading project explorer...)ÚProjects)Zat_startÚfind_in_files)ÚFindInFileszLoading namespace browser...)ÚVariableExplorerzLoading IPython console...)ÚIPythonConsolezSetting up main window...zTroubleshooting...zDependencies...Zadvanced)r2  r0  zReport issue...ZbugzSpyder support...zCheck for updates...zhttps://docs.spyder-ide.org/zSpyder documentationZDialogHelpButtonc                  s
   t  ˆ ¡S )N)rN   Ú
start_filerh   )Ú
spyder_docrh   ri   rA  ®  s    zspyder documentationzSpyder tutorialzShortcuts SummaryzMeta+F1)Zshortcutr2  zInteractive toursZlastrm   c                s   ‡ ‡fdd„S )Nc                  s
   ˆ  ˆ ¡S )N)Ú	show_tourrh   )Úir%  rh   ri   rA  Ê  s    z3MainWindow.setup.<locals>.trigger.<locals>.<lambda>rh   )r[  r%  rh   )r[  r%  ri   ÚtriggerÉ  s    z!MainWindow.setup.<locals>.trigger)r5  r2  zPython documentationc               S   s   t  tƒ ¡S )N)rN   rX  rv   rh   rh   rh   ri   rA  Û  s    zIPython documentationzIntro to IPythonzQuick referencezConsole helpc                s^   t |ƒ}tdks|fdd„}n|fdd„}tˆ| dt |¡d dd…  |d}ˆ  |¡ dS )	z6Add installed Python module doc action to help submenuZpysidec             S   s
   t  |¡S )N)rN   rX  )Z_checkedrg   rh   rh   ri   rA  ñ  s    z:MainWindow.setup.<locals>.add_ipm_action.<locals>.<lambda>c             S   s
   t  | ¡S )N)rN   rX  )rg   rh   rh   ri   rA  ó  s    z%s.pngrk   N)r0  r2  )r_   r   rW   rn   Úsplitextr,  )r1  rg   Zslotr>  )Úipm_actionsr%  rh   ri   Úadd_ipm_actionì  s    z(MainWindow.setup.<locals>.add_ipm_actionrc   z3([a-zA-Z\_]*)(doc)?(-dev)?(-ref)?(-user)?.(chm|pdf))ÚPythonzInstalled Python moduleszOnline documentationé   é   é   Zlinuxzassistant-qt4Z	assistantzQt documentationzAbout %s...r–   ZMessageBoxInformation)ÚMemoryStatusÚ	CPUStatusz%s: %s)ÚfileZPanesZToolbarszWindow layoutszShow toolbarsz#Attached console window (debugging))r4  zSetting up window...F)ÚdefaultrŠ   )	rf  ZeditÚsearchÚsourceÚrunÚdebugr¼   ZtoolsÚpluginsZ_menuc                s
   ˆ   | ¡S )N)Úshow_shortcuts)rm   )r%  rh   ri   rA  ˆ  s    c                s
   ˆ   | ¡S )N)Úhide_shortcuts)rm   )r%  rh   ri   rA  Š  s    r*   Ztear_off_menusz*** End of MainWindow setup ***)är=   rW   Úimar0  r.   Úclose_current_dockwidgetr   ÚApplicationShortcutrÑ   r=  Útoggle_lock_dockwidgetsrÏ   Útoggle_next_layoutZtoggle_next_layout_actionÚtoggle_previous_layoutZtoggle_previous_layout_actionÚopen_fileswitcherZfile_switcher_actionÚopen_symbolfinderZsymbol_finder_actionrû   rÒ   rÓ   rÔ   rÕ   rÖ   r×   rÝ   ZmenuBarZaddMenurÚ   r/  rú   rÜ   rü   rÞ   rþ   rà   r   râ   r  rä   r  ræ   rè   ZaboutToShowr  Úvalid_projectrê   rî   rò   Ú	statusBarr+  ÚshowMessageÚedit_preferencesÚpath_manager_callbackr   ZApplicationSpecificRoleÚreset_spyderrë   rV   Úwin_envr,  r,   r   rì   rí   rY   Z	wp_actionrl   rm   rQ   r\   rF  rD  rE  r^   rn   ro   rG  Úmaximize_dockwidgetrØ   Ú#_MainWindow__update_maximize_actionÚtoggle_fullscreenrÙ   rù   rø   Zspyder.plugins.consolerH  Úclosingr    r¡   r¶   Zregister_pluginZspyder.plugins.workingdirectoryrI  rŸ   r·   r÷   r(   r	  Ú
set_splashZspyder.plugins.helprK  rº   Zspyder.plugins.outlineexplorerrM  r½   Zspyder.plugins.editorr9  r¸   r‡   rO  rÛ   Zspyder.plugins.explorerrP  r¹   Zspyder.plugins.historyrQ  r¾   Zspyder.plugins.onlinehelprR  r§   r»   Zspyder.plugins.projectsrS  r¼   Úget_pythonpathr°   Zspyder.plugins.findinfilesrU  rÁ   Zspyder.plugins.variableexplorerrV  rÀ   Zspyder.plugins.ipythonconsolerW  r¿   Útrouble_guideÚshow_dependenciesÚreport_issueÚgoogle_groupÚcheck_updatesrÅ   Zshow_tutorialÚshow_shortcuts_dialogrb   ZAnimatedTourZ
tours_menuZtour_menu_actionsZ	get_toursrÃ   Ú	enumerateZ
addActionsró   rv   Z
show_introZshow_quickrefZshow_guirefrX   rp   rq   rr   rs   rd   re   Úgroupsr[   Ú	BOOKMARKSÚinsertr«   Ú
startswithr	   ÚaboutZspyder.widgets.statusrd  re  rô   rõ   Úapply_statusbar_settingsra   ZPLUGIN_CLASSZcheck_compatibilityÚAttributeErrorrÂ   Ú	ExceptionÚprintr™   r;   Ú	tracebackÚ	print_excrï   rñ   Úquick_layout_menuÚquick_layout_set_menuÚshow_toolbarsrÐ   Z	addActionr   Ú
setCheckedr   ZsetMenurß   rá   rã   rå   rç   ré   rý   rÿ   r  r  r  Úapply_shortcutsÚall_actions_definedÚemitÚsetup_layoutÚgetattrZaboutToHider  ÚhideÚchildrenÚ
isinstanceZsetTearOffEnabledÚupdate_edit_menuÚupdate_search_menuÚ	TypeErrorr  )Mr%  r?  Ú	namespaceÚstatusZprefs_actionZspyder_path_actionZupdate_modules_actionZreset_spyder_actionZwinenv_actionZadditactrm   ZqtdactZqtlactÚargsZactZgdgq_actrD  rE  Zguidata_iconZguidata_actZguiqwt_iconZ
guiqwt_actZ	sift_iconZsift_actrH  rI  rK  rM  r9  Zquit_actionZrestart_actionrP  rQ  rR  rS  rU  rV  rW  Ztrouble_actionZ
dep_actionZreport_actionZsupport_actionZ
doc_actionZ
tut_actionZshortcuts_actionr[  Ztour_availableZ	tour_namer\  Ztemp_actionZ	pydoc_actZipython_menuZintro_actionZquickref_actionZguiref_actionr_  Z	sysdocpthZdocfnZptre   ZpnameZpymods_menuZweb_resourcesZwebres_actionsZqta_exeZqta_actZabout_actionrd  re  ÚmodÚpluginZcheckÚerrorZcmd_actZexternal_tools_actZmenu_objectÚchildrh   )r^  r%  rY  ri   Úsetup'  sœ   









































































































$








zMainWindow.setupc             C   sÞ  | j  ¡  x| jD ]}| d¡ qW tƒ rRt t¡}td|… }t 	d|t g¡ t
 dd¡r˜| js˜| jr˜tj| jd}| d¡ | ¡  | j | j¡ |  ¡  |  ¡  t
 dd¡| _|  ¡  | j | j¡ |  ¡  | jj  ¡ rt!dkr| jj" d¡ | jj #¡  | j$g}| j%dk	r&| &| j%¡ x$|D ]}|j  ¡ r,|j '¡  q,W | j$j(sf| j) *t+d	ƒ¡ | j,r~| j- ,| j,¡ n$| j- .¡  | j- /¡ dkr¢| j0 1¡  t!dkrÌt
 dd
¡rÌd| _2| j3dd |  4¡  d| _5dS )zXActions to be performed only after the main window's `show` method
        was triggeredTNr¬   r*   Úsingle_instance)ÚtargetÚtoolbars_visibleFz
history.pyÚcheck_updates_on_startup)Ústartup)6Úrestore_scrollbar_positionrœ  r  ÚsetFloatingr@   Ú__file__Úindexr>   Ú
subprocessZcallr(   r	  r¢   r!  Ú	threadingZThreadÚstart_open_files_serverZ	setDaemonr  Úsig_open_external_filer  Úopen_external_fileÚcreate_plugins_menuÚcreate_toolbars_menur¯  Úload_last_visible_toolbarsrÏ   r™  r  Úapply_panes_settingsr¶   Ú
dockwidgetÚ	isVisibler/   Útoggle_view_actionrŸ  r¿   rº   r,  Úraise_Z	isvisibler¾   Zadd_historyr9   r¤   r¼   Zreopen_last_projectZget_active_projectr¸   Zsetup_open_filesrÈ   rˆ  Úreport_missing_dependenciesr  )r%  ÚwidgetÚidxZapp_pathÚtZplugins_to_showr©  rh   rh   ri   Úpost_visible_setup¡  sP    






zMainWindow.post_visible_setupc             C   s°   t dk	r$dttjd tjd f }ndtjd tjd f }trL|dt 7 }| jdk	rh|dt| jƒ 7 }| jdk	rš| j ¡ }|rš| 	t
ƒ d¡}d	 ||¡}|| _|  | j¡ dS )
zSet window title.NzSpyder %s (Python %s.%s)r   rk   zSpyder (Python %s.%s)z [DEBUG MODE %d]z -- ú~z	{0} - {1})r/   r2   rp   rt   r<   r¥   rI   r¼   Úget_active_project_pathr®   r?   ÚformatZ
base_titleÚsetWindowTitle)r%  r-  rg   rh   rh   ri   r  õ  s"    



zMainWindow.set_window_titlec             C   s.   t  ¡ }|r*t | tdƒtdƒ| tj¡ dS )z;Show a QMessageBox with a list of missing hard dependenciesÚErroraû  <b>You have missing dependencies!</b><br><br><tt>%s</tt><br><br><b>Please install them to avoid this message.</b><br><br><i>Note</i>: Spyder could work without some of these dependencies, however to have a smooth experience when using Spyder we <i>strongly</i> recommend you to install all the listed missing dependencies.<br><br>Failing to install these dependencies might result in bugs. Please be sure that any found bugs are not the direct result of missing dependencies, prior to reporting a new issue.N)rG   Zmissing_dependenciesr   Úcriticalr.   ÚOk)r%  Zmissing_depsrh   rh   ri   rÃ    s
    z&MainWindow.report_missing_dependenciesFr*   c             C   sÌ   |r
t jnt j}|||d ƒ}|||d ƒ}|r6d}n|||d dƒ}|||d ƒ}|d }	|d }
t ¡  ¡ }| ¡ }| ¡ }||	k s||
k r t  ||d ¡}|||d ƒ}|||d	 ƒ}||||||fS )
zœLoad window layout settings from userconfig-based configuration
        with *prefix*, under *section*
        default: if True, do not restore inner layoutÚsizerÌ   NÚstateÚpositionr   rk   Úis_maximizedÚis_fullscreen)r(   Úget_defaultr	  r   rx   ZgeometryÚwidthÚheight)r%  rq   rg  ÚsectionÚget_funcr  rÌ   ÚhexstateÚposrÕ  rÖ  Zscreen_shapeZcurrent_widthZcurrent_heightrÒ  rÓ  rh   rh   ri   Úload_window_settings!  s$    
zMainWindow.load_window_settingsc             C   st   | j  ¡ | j  ¡ f}|  ¡ }|r(| j}n|  ¡ }| j ¡ | j ¡ f}| j	 ¡ | j	 ¡ f}t
|  ¡ ƒ}||||||fS )zSReturn current window settings
        Symetric to the 'set_window_settings' setter)r  rÕ  rÖ  ÚisFullScreenr  ÚisMaximizedr  ÚxÚyrÌ   rK   Ú	saveState)r%  r  rÓ  rÒ  rÚ  rÌ   rÙ  rh   rh   ri   Úget_window_settings=  s    
zMainWindow.get_window_settingsc             C   s  |   d¡ t|d |d ƒ| _t|d |d ƒ| _t|d |d ƒ| _|  tj¡ |  	| j¡ |  
| j¡ |rÄ|  tƒ  t|ƒ d¡¡¡ x8|  ¡ D ],}t|tƒr”| ¡ r”| j |¡ | d¡ q”W |rÔ|  tj¡ |  ¡  |rè|| _n|rø|  tj¡ |   d¡ dS )zJSet window settings
        Symetric to the 'get_window_settings' accessorFr   rk   zutf-8TN)ÚsetUpdatesEnabledr   r  rÌ   r   r  ÚsetWindowStater   ZWindowNoStateÚresizeZmoveÚrestoreStater   ZfromHexr™   Úencoder   r¡  r   Z
isFloatingr  r,  r³  ZWindowFullScreenÚ%_MainWindow__update_fullscreen_actionr  ÚWindowMaximized)r%  rÙ  r  rÌ   rÚ  rÒ  rÓ  rÄ  rh   rh   ri   Úset_window_settingsM  s.    

zMainWindow.set_window_settingsc             C   sú   | j }| j}t ||d | ¡ | ¡ f¡ t ||d | ¡ | ¡ f¡ t ||d |  ¡ ¡ t ||d |  ¡ ¡ | j}t ||d | 	¡ | 
¡ f¡ | jdd |r¼t ||d d	¡ n|  ¡ }t ||d t|ƒ¡ t ||d
 |  ¡  ¡  ¡ d	S )ziSave current window settings with *prefix* in
        the userconfig-based configuration, under *section*rÏ  rÌ   rÒ  rÓ  rÑ  T)ÚrestorerÐ  NZ	statusbar)r  rÌ   r(   r  rÕ  rÖ  rÝ  rÜ  r  rÞ  rß  r~  rà  rK   rx  ZisHidden)r%  rq   r×  Ú
none_stateZwin_sizeZ
prefs_sizerÚ  Zqbarh   rh   ri   Úsave_current_window_settingsr  s     z'MainWindow.save_current_window_settingsc             C   s   |   |j|j¡ dS )zTabify plugin dockwigdetsN)ZtabifyDockWidgetr¿  )r%  ÚfirstÚsecondrh   rh   ri   Útabify_plugins‰  s    zMainWindow.tabify_pluginsc             C   sZ  d}|   ||¡}|d }d| _|dkræ|  tj¡ d| _|  d|¡ d}|rRtjntj}||dƒ}|rt 	|d	|¡ t 	|d|¡ t 	|d
|¡ x.t
|ƒD ]"\}}	d |¡}| j||dd qšW d}d}| j||dd d| _|  ¡  | j|Ž  xd| jD ]Z}
y|
 ¡  W qø tk
rP } z(td|
t|ƒf td tjtd W dd}~X Y qøX qøW dS )zSetup window layoutzwindow/r   FNTrg  Úquick_layoutsÚorderÚactiveÚnameszlayout_{0}/)rë  zlayout_default/z%s: %s)rf  )rÛ  Zfirst_spyder_runrã  r   rè  Úsetup_default_layoutsr(   rÔ  r	  r  rŠ  rÊ  rì  r  r—  ré  r  Z&initialize_plugin_in_mainwindow_layoutr’  r“  r™   r;   r”  r•  )r%  rg  rq   ÚsettingsrÙ  r×  rØ  rñ  rµ  rm   r©  rª  rh   rh   ri   r  Ž  s>    


zMainWindow.setup_layoutc       3      C   sP  | j dd | j|Ž  |  d¡ t| jƒ\}}}}| j}| j}| j}	| j}
| j	}| j
}| j}| j}| j}| j}| j}| j}||	||g| }| j| j| jg}|gg|gg|
gg|||||g| |	||gggddddgdgdgdgdd	gg|
gg d
œ}|g||	gg|||
|g| ||||gggddgddgddgg|
gg d
œ}||g|
gg|g||	gg||g| |||gggdddgddgddgddggg g d
œ}|g||	||||||
||g
| ggdgddgg|
gg d
œ}|gg||	||||||
||g
| ggddgdgdgg|
gg d
œ}d|||||||||i}|| }|d }g }xB|D ]:}x2|D ]*}x"|D ]} | dk	rN| | ¡ qNW qDW q:W x.|D ]&} |  d¡ | j}!|! | j ¡ ¡ q~W xXtt|ƒd ƒD ]D}"||" ||"d   }#}$|#dk	rº|$dk	rº|  |#j|$jtj¡ qºW xp|D ]h}x`tt|ƒd ƒD ]L}"||" ||"d   }%}&|%dk	r|&dk	r|  |%d j|&d jtj¡ qW qW xŒ|D ]„}x||D ]t}xPtt|ƒd ƒD ]<}"||" ||"d   }#}$|#dk	rš|$dk	rš|  |#|$¡ qšW |d j  ¡  |d j !¡  q„W qzW ||d  }'x |'D ]}(|(dk	r|( "¡  qW ||d  })x"|)D ]} | dk	rB| j "¡  qBW g | _#| j$ %¡ | j$ &¡  }*}+xœt'|ƒD ]\},}x„tt|ƒd ƒD ]p}-||- d } | j}.|. (¡ }/|. )¡ }0| |/|0dœ}1| j# |1¡ t*|d |, |- |+ d ƒ}2|. +|2¡ |. ,|2¡ q W q†W t-| ƒ| _.| j.j/ 0| j1¡ | j. 2d¡ | j. 3d¡ dS )z1Setup default layouts when run for the first timeT)rê  Fg        gš™™™™™á?gÍÌÌÌÌÌÜ?g      ð?gq=
×£pÝ?gHáz®Gá?)Úwidgetszwidth fractionzheight fractionzhidden widgetszhidden toolbarsgš™™™™™É?gš™™™™™Ù?rg  rö  Nrk   r   zhidden toolbarszhidden widgets)rÄ  zdock min heightzdock max heightzheight fractiongffffffî?iˆ  )4r~  ré  râ  ÚrangeÚDEFAULT_LAYOUTSr¸   r¿   r¶   r½   r¼   r¹   rÀ   r¾   rÁ   rº   r»   rÂ   r   rü   rþ   r,  Ztoggle_viewrÁ  r™  r¿  rÀ  ÚlenZsplitDockWidgetr   Z
HorizontalZVerticalrï  ÚshowrÂ  ÚcloseÚ_layout_widget_infor  rÕ  rÖ  rŠ  ZminimumHeightZmaximumHeightÚintÚsetMinimumHeightÚsetMaximumHeightr   Z_custom_layout_timerr
  r  Úlayout_fix_timerZsetSingleShotr  )3r%  rµ  rõ  ZMATLABZRSTUDIOZVERTICALZ
HORIZONTALr¸   Zconsole_ipyZconsole_intZoutlineZexplorer_projectZexplorer_fileZexplorer_variableÚhistoryÚfinderZhelp_pluginÚhelperrl  Zglobal_hidden_widgetsZglobal_hidden_toolbarsZs_layoutZr_layoutZm_layoutZv_layoutZh_layoutZlayoutsZlayoutZwidgets_layoutrö  ÚcolumnÚrowrÄ  r>  r[  rí  rî  Z	first_rowZ
second_rowZhidden_toolbarsr.  Zhidden_widgetsrÕ  rÖ  ÚcÚrr¿  Z
dock_min_hZ
dock_max_hÚinfoZ
new_heightrh   rh   ri   rô  ¿  s   


















z MainWindow.setup_default_layoutsc             C   s|   | j }xf|D ]^}|d j}d|kr>| |d ¡ | |d ¡ d|krb| |d ¡ | |d ¡ | ¡  qW |  d¡ dS )z4Fixes the height of docks after a new layout is set.rÄ  zdock min widthzdock max widthzdock min heightzdock max heightTN)rü  r¿  ZsetMinimumWidthZsetMaximumWidthrþ  rÿ  ZupdateGeometryrâ  )r%  r  r[  r¿  rh   rh   ri   r   œ  s    

zMainWindow.layout_fix_timerc             C   s   |   d¡ dS )r7  ÚpreviousN)Útoggle_layout)r%  rh   rh   ri   rt  «  s    z!MainWindow.toggle_previous_layoutc             C   s   |   d¡ dS )r7  ÚnextN)r
  )r%  rh   rh   ri   rs  °  s    zMainWindow.toggle_next_layoutr  c             C   sº   t j}|ddƒ}|ddƒ}|ddƒ}t|ƒdkr4dS dg}x$|D ]}||kr@| | |¡¡ q@W | j}dd	d
œ}	|dkr|d}||kr| |¡}
nd}
|
|	|  t|ƒ }|  || ¡ dS )r7  rð  ró  rñ  rò  r   Nrg  rk   éÿÿÿÿ)r  r	  )r(   r	  rù  r,  rµ  r  Úquick_layout_switch)r%  Ú	directionr	  ró  rñ  rò  Zlayout_indexrm   Zcurrent_layoutÚdicZcurrent_indexZ	new_indexrh   rh   ri   r
  µ  s&    




zMainWindow.toggle_layoutc       
         sb  t j}|ddƒ}|ddƒ}|ddƒ}g }tˆ tdƒ‡ fdd„dg}xF|D ]>}||krJ| |¡}|ˆ fd	d
„}tˆ ||ƒ d}	||	g7 }qJW tˆ tdƒ‡ fdd„tjdˆ _tˆ tdƒ‡ fdd„tjdˆ _tˆ tdƒˆ j	dˆ _
ˆ  ˆ jdd¡ ˆ  ˆ jdd¡ |dg7 }|ˆ jˆ jˆ j
g7 }ˆ j ¡  tˆ j|ƒ t|ƒdkrRˆ j d¡ nˆ j d¡ dS )r7  rð  ró  rñ  rò  zSpyder Default Layoutc                  s
   ˆ   d¡S )Nrg  )r  rh   )r%  rh   ri   rA  Ý  s    z2MainWindow.quick_layout_set_menu.<locals>.<lambda>)r2  c                s   ‡ ‡fdd„S )Nc                  s
   ˆ  ˆ ¡S )N)r  rh   )r[  r%  rh   ri   rA  å  s    zCMainWindow.quick_layout_set_menu.<locals>.trigger.<locals>.<lambda>rh   )r[  r%  rh   )r[  r%  ri   r\  ä  s    z1MainWindow.quick_layout_set_menu.<locals>.triggerzSave current layoutc                  s   ˆ   ¡ S )N)Úquick_layout_saverh   )r%  rh   ri   rA  ï  s    )r2  r3  zLayout preferencesc                  s   ˆ   ¡ S )N)Úquick_layout_settingsrh   )r%  rh   ri   rA  ó  s    zReset to spyder defaultr.   Nr   FT)r(   r	  rW   r.   rµ  r   rq  Zql_saveZql_preferencesÚreset_window_layoutZql_resetr=  r–  ÚclearrX   rù  Ú
setEnabled)
r%  r	  ró  rñ  rò  Z
ql_actionsrm   rµ  r\  Zqli_actrh   )r%  ri   r—  Ó  s<    












z MainWindow.quick_layout_set_menuc             C   s:   t  | tdƒtdƒt jt jB ¡}|t jkr6| jdd dS )zReset window layout to defaultÚWarningz}Window layout will be reset to default settings: this affects window position, size and dockwidgets.
Do you want to continue?T)rg  N)r   r#  r.   ÚYesÚNor  )r%  Úanswerrh   rh   ri   r    s
    
zMainWindow.reset_window_layoutc       
      C   s  t j}t j}|ddƒ}|ddƒ}|ddƒ}|  | |¡}| ¡ r|j ¡ }||kr‚t | t	dƒt	dƒ| tj
tjB ¡}| |¡}	n<d}d|kr¢| d¡}	|||	< nt|ƒ}	| |¡ | |¡ ||krÐ| |¡ |r| jd	 |	¡dd
 |dd|ƒ |dd|ƒ |dd|ƒ |  ¡  dS )zSave layout dialogrð  ró  rñ  rò  r  zœLayout <b>%s</b> will be                                                overwritten. Do you want to                                                continue?TNz
layout_{}/)r×  )r(   r	  r  rÍ   Úexec_Z	combo_boxZcurrentTextr   r#  r.   r  r  rµ  rù  r,  rì  rÊ  r—  )
r%  r	  Úset_ró  rñ  rò  Údlgrm   r  rµ  rh   rh   ri   r    s<    









zMainWindow.quick_layout_savec             C   s|   t j}t j}d}||dƒ}||dƒ}||dƒ}|  | |||¡}| ¡ rx||d|jƒ ||d|jƒ ||d|jƒ |  ¡  dS )zLayout settings dialogrð  ró  rñ  rò  N)	r(   r	  r  rÎ   r  ró  rñ  rò  r—  )r%  r	  r  r×  ró  rñ  rò  r  rh   rh   ri   r  =  s    


z MainWindow.quick_layout_settingsc          
   C   sÜ   d}yh| j d |¡|d}|\}}}}}}	|dkrj|dkr^|| jkr^t | tdƒtdƒ¡ dS |  ||¡ W n4 tjk
r    t | tdƒtdƒt	|ƒ ¡ dS X | j
|Ž  || _x$| jD ]}
|
j}| |
j ¡ ¡ qºW dS )	z%Switch to quick layout number *index*rð  z
layout_{}/)r×  Nrg  r  zžError opening the custom layout.  Please close Spyder and try again.  If the issue persists, then you must use 'Reset to Spyder default' from the layout menu.z1Quick switch layout #%s has not yet been defined.)rÛ  rÊ  rø  r   rÍ  r.   rô  ÚcpZNoOptionErrorr™   ré  r  r  rÁ  r™  r¿  rÀ  )r%  rµ  r×  rõ  rÙ  r  rÌ   rÚ  rÒ  rÓ  r©  r>  rh   rh   ri   r  O  s,    

zMainWindow.quick_layout_switchc             C   sD   | j rtdƒ}tdƒ}ntdƒ}tdƒ}| j |¡ | j |¡ dS )z,Update the text displayed in the menu entry.zHide toolbarszShow toolbarsN)r¯  r.   rÐ   ÚsetTextÚ
setToolTip)r%  r1  r5  rh   rh   ri   Ú_update_show_toolbars_actionz  s    
z'MainWindow._update_show_toolbars_actionc             C   s4   g }x| j D ]}| | ¡ ¡ qW t dd|¡ dS )z8Saves the name of the visible toolbars in the .ini file.r*   Úlast_visible_toolbarsN)rö   r,  r›   r(   r  )r%  Útoolbarsr.  rh   rh   ri   Úsave_visible_toolbars…  s    z MainWindow.save_visible_toolbarsc             C   s4   g }x$| j D ]}| ¡  ¡ r| |¡ qW || _dS )zCollects the visible toolbars.N)r÷   ÚtoggleViewActionZ	isCheckedr,  rö   )r%  r!  r.  rh   rh   ri   Úget_visible_toolbarsŒ  s
    zMainWindow.get_visible_toolbarsc             C   sx   t jddg d}|rdi }x| jD ]}||| ¡ < q W g }x"|D ]}||kr>| || ¡ q>W || _n|  ¡  |  ¡  dS )z3Loads the last visible toolbars from the .ini file.r*   r   )rg  N)r(   r	  r÷   r›   r,  rö   r$  r  )r%  Ztoolbars_namesr  r.  r!  rm   rh   rh   ri   r½  ”  s    
z%MainWindow.load_last_visible_toolbarsc             C   sf   | j  }t dd|¡ |r$|  ¡  n|  ¡  x&| jD ]}| ¡  |¡ | |¡ q4W || _ |  	¡  dS )zShow/Hides toolbars.r*   r¯  N)
r¯  r(   r  r"  r$  rö   r#  r™  Ú
setVisibler  )r%  Úvaluer.  rh   rh   ri   r˜  ¦  s    
zMainWindow.show_toolbarsc             C   sf   y| j  ¡ }W n tk
r"   dS X t|ƒrb| j  |¡sb|rXt | tdƒtdƒ |¡¡ | j  	¡  dS )z!Handle an invalid active project.NrÌ  zw<b>{}</b> is no longer a valid Spyder project! Since it is the current active project, it will be closed automatically.)
r¼   rÉ  r‘  ÚboolZis_valid_projectr   rÍ  r.   rÊ  Zclose_project)r%  rg   rh   rh   ri   rw  ¸  s    zMainWindow.valid_projectc             C   s   t  ¡  dS )zFree memory after event.N)ÚgcZcollect)r%  rh   rh   ri   Úfree_memoryÊ  s    zMainWindow.free_memoryc             C   s   |   ¡  |  ¡  dS )z,Focus has changed from one plugin to anotherN)r¢  r£  )r%  rh   rh   ri   Úplugin_focus_changedÎ  s    zMainWindow.plugin_focus_changedc             C   s@   x:t | |d ƒD ](}|rt|tƒr|jdk	r| |j¡ qW dS )zShow action shortcuts in menuÚ_menu_actionsN)rž  r¡  r   Ú_shown_shortcutÚsetShortcut)r%  ÚmenuÚelementrh   rh   ri   rm  Ó  s    
zMainWindow.show_shortcutsc             C   s@   x:t | |d ƒD ](}|rt|tƒr|jdk	r| tƒ ¡ qW dS )zHide action shortcuts in menur+  N)rž  r¡  r   r,  r-  r   )r%  r.  r/  rh   rh   ri   rn  Ú  s    
zMainWindow.hide_shortcutsc             C   sb   ddl m} ddlm} t ¡ }d}t|||fƒrZt||ƒ}| ¡  }|oN| }|||f}||fS )z§Get properties of focus widget
        Returns tuple (widget, properties) where properties is a tuple of
        booleans: (is_console, not_readonly, readwrite_editor)r   )ÚTextEditBaseWidget)ÚControlWidgetN)Úspyder.widgets.editorr0  Úspyder.widgets.ipythonconsoler1  r   ÚfocusWidgetr¡  Z
isReadOnly)r%  r0  r1  rÄ  Útextedit_propertiesr¶   Únot_readonlyÚreadwrite_editorrh   rh   ri   Úget_focus_widget_propertiesá  s    



z&MainWindow.get_focus_widget_propertiesc       	      C   sê   |   ¡ \}}|dkrdS |\}}}|s8|r8| j ¡ s8dS x| j ¡ D ]}| d¡ qDW | j d¡ | j |ov| ¡  	¡ ¡ | j
 |oŽ| ¡  ¡ ¡ | ¡ }| j |¡ | j |o²|¡ | j |¡ |sæ|ræx| jjD ]}| d¡ qÔW dS )zUpdate edit menuNFT)r8  r¸   Zis_file_openedrÜ   Úactionsr  r×   rÒ   ZdocumentZisUndoAvailablerÓ   ZisRedoAvailableZhas_selected_textrÔ   rÕ   rÖ   rÝ   )	r%  rÄ  r5  r¶   r6  r7  r«  Zhas_selectionr>  rh   rh   ri   r¢  ñ  s(    


zMainWindow.update_edit_menuc          	   C   s˜   x$| j  ¡ dd… D ]}| d¡ qW |  ¡ \}}|dkr>dS |\}}}|s„x6| j  ¡ D ](}y| d¡ W qX tk
r~   Y qXX qXW | jd  |¡ dS )zUpdate search menuNr  FTé   )rÞ   r9  r  r8  ÚRuntimeErrorrß   )r%  r«  rÄ  r5  r¶   r6  r7  r>  rh   rh   ri   r£    s    

zMainWindow.update_search_menuc             C   sÞ   dddddd dddd	d d
dddd ddg}xn| j D ]d}|j}| |j ¡ ¡ y|j}| |¡}W n tk
rv   d }Y nX |d k	rŠ|||< q0| |¡ q0W |d d … }x"|D ]}t	|ƒt
krª| |¡ qªW || _t| j|ƒ d S )Nr¸   r¶   Zipython_consoleZvariable_explorerrº   r¹   rL  Zproject_explorerrT  r¾   ZprofilerZbreakpointsZpylintr»   Zinternal_console)r  rÁ  r™  r¿  rÀ  ZCONF_SECTIONrµ  Ú
ValueErrorr,  Útyper™   Úremoverð   rX   rï   )r%  rñ  r©  r>  rm   rÚ  r9  rh   rh   ri   r»  0  s,    


zMainWindow.create_plugins_menuc          	   C   sŠ   dddddd dddg	}xb| j D ]X}| ¡ }| ¡ }y| |¡}W n tk
rX   d }Y nX |d k	rl|||< q| |¡ qW t| j|ƒ d S )	Nrú   r  r  rø   zGlobal working directoryrþ   rü   r   )r÷   r#  r›   rµ  r<  r,  rX   rñ   )r%  rñ  r.  r>  rm   rÚ  rh   rh   ri   r¼  I  s    


zMainWindow.create_toolbars_menuc             C   s4   t d| ƒ}| jd d… d | jd g }t||ƒ |S )Nr”   r:  r  )r   ró   rX   )r%  r.  r9  rh   rh   ri   ÚcreatePopupMenuZ  s
    

zMainWindow.createPopupMenuc             C   sV   | j dkrdS |r|  |¡ | j  ¡  | j  |tjtjB tjB ttj	ƒ¡ t
 ¡  dS )zSet splash messageN)r  r=   rú  ry  r   ÚAlignBottomÚAlignCenterÚAlignAbsoluter   Úwhiter   ÚprocessEvents)r%  r)  rh   rh   ri   r‚  a  s    


zMainWindow.set_splashc             C   s    |   d¡r| ¡  n| ¡  dS )zcloseEvent reimplementationTN)r  ÚacceptÚignore)r%  Úeventrh   rh   ri   Ú
closeEventl  s    

zMainWindow.closeEventc             C   s4   |   ¡ s| js|  ¡ | _t | |¡ | j |¡ dS )zReimplement Qt methodN)rÝ  r  rÏ  r  r   ÚresizeEventÚsig_resizedrœ  )r%  rG  rh   rh   ri   rI  s  s    
zMainWindow.resizeEventc             C   s4   |   ¡ s| js|  ¡ | _t | |¡ | j |¡ dS )zReimplement Qt methodN)rÝ  r  rÚ  r  r   Ú	moveEventÚ	sig_movedrœ  )r%  rG  rh   rh   ri   rK  |  s    
zMainWindow.moveEventc             C   s\   y6x$| j D ]}| | j¡r
| d¡ q
W t | |¡ W n  tk
rV   t | |¡ Y nX dS )zReimplement Qt methodTN)r  ÚisAncestorOfr  Úvisibility_changedr   Ú	hideEventr;  )r%  rG  r©  rh   rh   ri   rO  …  s    zMainWindow.hideEventc             C   sD   |dkr,t  ¡ dk	r,t  ¡  ¡  t  ¡ | _n|dk	r:|| _|| _dS )z+To keep track of to the last focused widgetN)r   ZactiveWindowÚsetFocusr4  r  r  )r%  ÚoldZnowrh   rh   ri   Úchange_last_focused_widget  s    z%MainWindow.change_last_focused_widgetc             C   sÌ   | j s| jrdS |rDt dd¡rDt | ddtjtj¡}|tjkrDdS d}|  |¡ t dd¡rn| j	rn| j	 
¡  x| jD ]}| |¡svdS qvW x| jD ]}| |¡s”dS q”W | j ¡  | jrÂ|  ¡  d| _ dS )	z
Exit tasksTr*   Zprompt_on_exitr–   zDo you really want to exit?Fzwindow/r­  )r  r  r(   r	  r   rÍ  r  r  rì  r!  rû  rÂ   Zclosing_pluginr  r   Z	close_allr¯  r"  )r%  Z
cancelableZreplyrq   r©  rÄ  rh   rh   ri   r  ™  s.    





zMainWindow.closingc             C   sH   |  ¡ \}}t dd¡r,| | ¡ tjB ¡ |  ||¡ | j 	|¡ dS )z$Add QDockWidget and toggleViewActionr*   Úvertical_dockwidget_titlebarsN)
Zcreate_dockwidgetr(   r	  ÚsetFeaturesÚfeaturesr   ÚDockWidgetVerticalTitleBarÚaddDockWidgetr  r,  )r%  r«  r¿  Úlocationrh   rh   ri   Úadd_dockwidget³  s    

zMainWindow.add_dockwidgetc             C   s2   t  ¡ }x$| jD ]}| |¡r|j ¡  P qW d S )N)r   r4  r  rM  r¿  rŸ  )r%  rÄ  r©  rh   rh   ri   rp  ¼  s
    

z#MainWindow.close_current_dockwidgetc             C   s    || _ |  ¡  t dd|¡ dS )zLock/Unlock dockwidgetsr*   r•   N)r  r¾  r(   r  )r%  r&  rh   rh   ri   rr  Ä  s    z"MainWindow.toggle_lock_dockwidgetsc             C   sh   | j d kr&tdƒ}tdƒ}t d¡}ntdƒ}tdƒ}t d¡}| j |¡ | j |¡ | j |¡ d S )NzMaximize current paneZmaximizezRestore current panez!Restore pane to its original sizeZ
unmaximize)r  r.   ro  r0  rØ   r  ÚsetIconr  )r%  r1  r5  r0  rh   rh   ri   Z__update_maximize_actionÊ  s    

z#MainWindow.__update_maximize_actionc             C   s(  | j dkrÈ|rdS |  ¡ | _ t ¡ }x(| jD ]}|j ¡  | |¡r,|| _q,W | jdkr`| j	| _| jj 
¡  d¡ |  | j¡ d| j_| j ¡  | j d¡ | j| j	krÆ|  tj| jj¡ | jj ¡  nT| jj | j¡ | jj 
¡  d¡ |  d¡ d| j_|  | j ¡ d| _ | j ¡  ¡  |  ¡  dS )zShortcut: Ctrl+Alt+Shift+M
        First call: maximize current dockwidget
        Second call (or restore=True): restore original window layoutNTF)r  rà  r   r4  r  r¿  rŸ  rM  r  r¸   r#  ÚsetDisabledZsetCentralWidgetZismaximizedrú  rN  rW  r   ZRightDockWidgetArear½   Z	setWidgetr  rå  Zget_focus_widgetrP  r  )r%  rê  Zfocus_widgetr©  rh   rh   ri   r~  ×  s8    








zMainWindow.maximize_dockwidgetc             C   s<   | j rt d¡}n
t d¡}t|ƒr,t|ƒ}| j |¡ d S )NZwindow_nofullscreenZwindow_fullscreen)r  ro  r0  rH   rY   rÙ   rZ  )r%  r0  rh   rh   ri   Z__update_fullscreen_action	  s    
z%MainWindow.__update_fullscreen_actionc             C   sì   | j rTd| _ tjdkr<|  |  ¡ tjtjB A ¡ |  | j	¡ |  
¡  | jrà|  ¡  nŒ|  ¡ | _d| _ |  ¡ | _	tjdkrØ|  |  ¡ tjB tjB ¡ t ¡  ¡ }|  | ¡ d | ¡ d | ¡ d | ¡ d ¡ |  
¡  n|  ¡  |  ¡  d S )NFr   Trk   ra  )r  rl   rm   ZsetWindowFlagsZwindowFlagsr   ZFramelessWindowHintZWindowStaysOnTopHintZsetGeometryr  Z
showNormalr  ZshowMaximizedrÝ  ZnormalGeometryr   rx   ZscreenGeometryÚleftÚtoprÕ  rÖ  ZshowFullScreenrç  )r%  r  rh   rh   ri   r€  	  s,    




,
zMainWindow.toggle_fullscreenc             C   s   |j }|dk	rt||ƒ dS )zAdd widget actions to toolbarN)Ztoolbar_actionsrX   )r%  r.  rÄ  r9  rh   rh   ri   Úadd_to_toolbar5	  s    zMainWindow.add_to_toolbarc             C   sÊ   t ƒ }d}|d r&|d }d||f }t| ƒ}| dj|d |tttt|d |d |d |d	 |d
 |d |d d¡ | t	dƒd ¡ | 
tj¡ | t tddƒ¡¡ | tjtjB ¡ | ¡  dS )z4Create About Spyder dialog with general information.r”   ÚrevisionzJ (<a href='https://github.com/spyder-ide/spyder/commit/%s'>Commit: %s</a>)at
  
            <b>Spyder {spyder_ver}</b> {revision}
            <br>The Scientific Python Development Environment |
            <a href="{website_url}">Spyder-IDE.org</a>
            <br>Copyright &copy; 2009-2019 Spyder Project Contributors and
            <a href="{github_url}/blob/master/AUTHORS.txt">others</a>
            <br>Distributed under the terms of the
            <a href="{github_url}/blob/master/LICENSE.txt">MIT License</a>.

            <p>Created by Pierre Raybaut; current maintainer is Carlos Cordoba.
            <br>Developed by the
            <a href="{github_url}/graphs/contributors">international
            Spyder community</a>.
            <br>Many thanks to all the Spyder beta testers and dedicated users.

            <p>For help with Spyder errors and crashes, please read our
            <a href="{trouble_url}">Troubleshooting Guide</a>, and for bug
            reports and feature requests, visit our
            <a href="{github_url}">Github site</a>.
            For project discussion, see our
            <a href="{forum_url}">Google Group</a>.
            <p>This project is part of a larger effort to promote and
            facilitate the use of Python for scientific and engineering
            software development.
            The popular Python distributions
            <a href="https://www.anaconda.com/download/">Anaconda</a> and
            <a href="https://winpython.github.io/">WinPython</a>
            also contribute to this plan.

            <p>Python {python_ver} {bitness}-bit | Qt {qt_ver} |
            {qt_api} {qt_api_ver} | {os_name} {os_ver}

            <small><p>Certain source files under other compatible permissive
            licenses and/or originally by other authors.
            Spyder 3 theme icons derived from
            <a href="https://fontawesome.com/">Font Awesome</a> 4.7
            (&copy; 2016 David Gandy; SIL OFL 1.1).
            Most Spyder 2 theme icons sourced from the
            <a href="https://www.everaldo.com">Crystal Project iconset</a>
            (&copy; 2006-2007 Everaldo Coelho; LGPL 2.1+).
            Other icons from
            <a href="http://p.yusukekamiyamane.com/">Yusuke Kamiyamane</a>
            (&copy; 2013 Yusuke Kamiyamane; CC-BY 3.0),
            the <a href="http://www.famfamfam.com/lab/icons/silk/">FamFamFam
            Silk icon set</a> 1.3 (&copy; 2006 Mark James; CC-BY 2.5), and
            the <a href="https://www.kde.org/">KDE Oxygen icons</a>
            (&copy; 2007 KDE Artists; LGPL 3.0+).</small>

            <p>See the <a href="{github_url}/blob/master/NOTICE.txt">NOTICE</a>
            file for full legal information.
            r‹   ÚpythonÚbitnessÚqtÚqt_apiÚ
qt_api_verÚsystemÚrelease)Z
spyder_verr_  Zwebsite_urlZ
github_urlZtrouble_urlZ	forum_urlZ
python_verra  Zqt_verrc  rd  Úos_nameZos_verzAbout %sr–   é@   N)r8   r   r  rÊ  r7   r3   r5   r4   rË  r.   ÚsetStandardButtonsrÎ  ZsetIconPixmapÚAPP_ICONZpixmapr   ZsetTextInteractionFlagsr   ZLinksAccessibleByMouseZTextSelectableByMouser  )r%  ÚversionsZrevlinkZrevZmsgBoxrh   rh   ri   r  ;	  s8    
3zMainWindow.aboutc             C   s,   ddl m} |dƒ}| tj¡ | ¡  dS )z%Show Spyder's Dependencies dialog boxr   )ÚDependenciesDialogN)Zspyder.widgets.dependenciesrl  Úset_datarG   ZDEPENDENCIESr  )r%  rl  r  rh   rh   ri   r…  	  s    zMainWindow.show_dependenciesr”   c             C   sz   t ƒ }d}|d r|d }|s"d}|r2d |¡}nd}dj|||d ||d |d |d	 |d
 |d |d t ¡ d}|S )z(Render issue before sending it to Githubr”   r_  z%### What steps reproduce the problem?z(### Traceback
```python-traceback
{}
```a&  ## Description

{description}

{error_section}

## Versions

* Spyder version: {spyder_version} {commit}
* Python version: {python_version}
* Qt version: {qt_version}
* {qt_api_name} version: {qt_api_version}
* Operating System: {os_name} {os_version}

### Dependencies

```
{dependencies}
```
r‹   r`  rb  rc  rd  re  rf  )ÚdescriptionÚerror_sectionZspyder_versionZcommitZpython_versionZ
qt_versionZqt_api_nameZqt_api_versionrg  Z
os_versionrG   )r8   rÊ  rG   r¦  )r%  rn  r”  rk  r_  ro  Zissue_templaterh   rh   ri   Úrender_issue—	  s,    zMainWindow.render_issuec       
      C   s¦   |dkr*ddl m} || dd}| ¡  nx|r¢tr@ddlm} nddlm} ddlm} t	t
d ƒ}|ƒ }	|	 d	||ƒ¡ |rŽ|	 d
||ƒ¡ | |	¡ t |¡ dS )z@Report a Spyder issue to github, generating body text if needed.Nr   )ÚSpyderErrorDialogT)Z	is_report)Úquote)Ú	QUrlQueryz/issues/newÚbodyr-  )Zspyder.widgets.reporterrorrq  rú  rJ   Zurllib.parserr  ZurllibÚqtpy.QtCorers  r   r3   ZaddQueryItemZsetQueryr   ÚopenUrl)
r%  rt  r-  Zopen_webpagerq  Z
report_dlgrr  rs  ÚurlZqueryrh   rh   ri   r†  Ï	  s     

zMainWindow.report_issuec             C   s   t tƒ}t |¡ dS )z3Open Spyder troubleshooting guide in a web browser.N)r   r5   r   rv  )r%  rw  rh   rh   ri   r„  æ	  s    zMainWindow.trouble_guidec             C   s   t tƒ}t |¡ dS )z*Open Spyder Google Group in a web browser.N)r   r4   r   rv  )r%  rw  rh   rh   ri   r‡  ì	  s    zMainWindow.google_groupc             C   sZ   t  ¡ }|  ¡ }t| ¡ tƒ}ddlm} ddlm	} t
|||fƒrRt||ƒƒ  ndS dS )zGlobal callbackr   )r0  )r1  N)r   r4  Zsenderr
   r8  rI   r2  r0  r3  r1  r¡  rž  )r%  rÄ  r>  Úcallbackr0  r1  rh   rh   ri   r<  ò	  s    zMainWindow.global_callbackc             C   s&   |r| j jj ¡  n| j jj ¡  d S )N)r¶   ÚshellÚinterpreterZredirect_stdsZrestore_stds)r%  rÐ  rh   rh   ri   Úredirect_internalshell_stdio 
  s    z'MainWindow.redirect_internalshell_stdioc
          	   C   st   |rpy:t  dd¡rtƒ }
nt  dd¡}
t |||||||
¡ W n0 tk
rn   t | tdƒtdƒt	j
 ¡ Y nX dS )zOpen external consoleZmain_interpreterrg  Ú
executableZRunzDRunning an external system terminal is not supported on platform %s.N)r(   r	  rT   rN   Zrun_python_script_in_terminalÚNotImplementedErrorr   rÍ  r.   rl   rm   )r%  ÚfnameZwdirr§  Zinteractrk  r`  Zpython_argsZsystermZpost_mortemr|  rh   rh   ri   Úopen_external_console
  s    
z MainWindow.open_external_consolec             C   s*   | j }| ¡  | |¡ |r&| j ¡  dS )zb
        Execute lines in IPython console and eventually set focus
        to the Editor.
        N)r¿   Zswitch_to_pluginZexecute_coder¸   )r%  ÚlinesZfocus_to_editorr¶   rh   rh   ri   Úexecute_in_external_console
  s
    
z&MainWindow.execute_in_external_consolec             C   sh   t |ƒ}t |¡d }t |¡r.| j |¡ n6| jdk	rN|tkrN| j 	|¡ n|sdt
|ƒ}t |¡ dS )zÔ
        Open filename with the appropriate application
        Redirect to the right widget (txt -> editor, spydata -> workspace, ...)
        or open file outside Spyder (if extension is not supported)
        rk   N)rI   rn   r]  rM   Zis_text_filer¸   ÚloadrÀ   rD   Zimport_datar_   rN   rX  )r%  r~  ÚexternalZextrh   rh   ri   Ú	open_file$
  s    
zMainWindow.open_filec             C   sP   t  |¡}t |¡r$| j|dd n(t t t|¡¡rL| jt t|¡dd dS )z~
        Open external files that can be handled either by the Editor or the
        variable explorer inside Spyder.
        T)rƒ  N)rM   Zto_unicode_from_fsrn   ru   r„  ro   ÚCWD)r%  r~  rh   rh   ri   rº  4
  s
    

zMainWindow.open_external_filec                s   ‡ fdd„ˆ j D ƒ}|ˆ j S )zReturn Spyder PYTHONPATHc                s   g | ]}|ˆ j kr|‘qS rh   )r   )rf   Úp)r%  rh   ri   rj   B
  s    z4MainWindow.get_spyder_pythonpath.<locals>.<listcomp>)rg   r°   )r%  Zactive_pathrh   )r%  ri   Úget_spyder_pythonpath@
  s    z MainWindow.get_spyder_pythonpathc             C   s(   x"t |  ¡ ƒD ]}tj d|¡ qW dS )zAdd Spyder path to sys.pathrk   N)Úreversedr‡  rp   rg   r  )r%  rg   rh   rh   ri   rµ   E
  s    zMainWindow.add_path_to_sys_pathc             C   s6   x0| j | j D ] }x|tj kr,tj  |¡ qW qW dS )z Remove Spyder path from sys.pathN)rg   r°   rp   r>  )r%  rg   rh   rh   ri   r´   J
  s    z$MainWindow.remove_path_from_sys_pathc             C   sš   ddl m} |  ¡  | j ¡ }|| | j|| jdd}|j | j	¡ | 
¡  |  ¡  y$t | j| j¡ t | j| j¡ W n tk
rŠ   Y nX | j ¡  dS )zSpyder path managerr   )ÚPathManagerT)ÚsyncN)Zspyder.widgets.pathmanagerr‰  r´   r¼   rƒ  rg   r   Zredirect_stdior  r{  r  rµ   rM   Ú
writelinesr±   r³   ÚEnvironmentErrorÚsig_pythonpath_changedrœ  )r%  r‰  r°   Zdialogrh   rh   ri   r{  P
  s    

z MainWindow.path_manager_callbackc             C   s*   |   ¡  | j ¡ | _|  ¡  | j ¡  dS )z,Projects PYTHONPATH contribution has changedN)r´   r¼   rƒ  r°   rµ   r  rœ  )r%  rh   rh   ri   Úpythonpath_changedc
  s    zMainWindow.pythonpath_changedc             C   s   | j  t| ƒ¡ dS )z/Show Windows current user environment variablesN)r   rú  rV   )r%  rh   rh   ri   r}  j
  s    zMainWindow.win_envc             C   sì   t  ¡ }tƒ r8dt ¡ kr8y| d¡ W qp   Y qpX n8t dd| j¡}t 	|¡}|dk	rp| 
d|¡ | |¡ | j}t dd¡rŒ|tjB }t dd¡r¢|tjB }|  |¡ |  ¡  |  ¡  t dd	¡rÜ| t dd
¡¡ n| | j¡ dS )z2Apply settings changed in 'Preferences' dialog boxzGTK+zgtk+r*   Zwindows_styleNrm   Zvertical_tabsZanimated_docksZuse_custom_cursor_blinkingZcustom_cursor_blinking)r   r˜   rE   r"   ÚkeysZsetStyler(   r	  rœ   ZcreateZsetPropertyÚDOCKOPTIONSr   ZVerticalTabsZAnimatedDocksZsetDockOptionsr¾  r  ZsetCursorFlashTimeÚCURSORBLINK_OSDEFAULT)r%  r'  Z
style_namerš   rg  rh   rh   ri   r$  p
  s.    




zMainWindow.apply_settingsc             C   sT   xN| j D ]D}|j}t dd¡r(|tjB }| js8|tjB }|j 	|¡ | 
¡  qW dS )z$Update dockwidgets features settingsr*   rS  N)r  ZFEATURESr(   r	  r   rV  r  ZDockWidgetMovabler¿  rT  Zupdate_margins)r%  r«  rU  rh   rh   ri   r¾  ‘
  s    

zMainWindow.apply_panes_settingsc             C   s~   t  dd¡}|  ¡  |¡ |rvxZ| jdf| jdffD ]<\}}|dk	r4| t  dd| ¡¡ | t  dd| ¡¡ q4W ndS dS )z"Update status bar widgets settingsr*   Úshow_status_barZmemory_usageZ	cpu_usageNz	%s/enablez
%s/timeout)r(   r	  rx  r%  rô   rõ   Zset_interval)r%  r’  rÄ  rm   rh   rh   ri   r  
  s    
z#MainWindow.apply_statusbar_settingsc          
   C   s2  ddl m} || ƒ}|j | j¡ | jdk	r8| | j¡ x,| jD ]"}||| d}| ¡  | 	|¡ q@W x†| j
| j| j| j| j| j| j| j| j| jg
| j D ]P}|dk	ršy | |¡}|dk	rÄ| 	|¡ W qš tk
rè   tjtjd Y qšX qšW | jdk	r| | j¡ | ¡  | ¡  |jj  | j!¡ | "¡  dS )zEdit Spyder preferencesr   )ÚConfigDialogN)r*   )rf  )#rÉ   r“  Zsize_changer  Úset_prefs_sizerÌ   rä  rÊ   Ú
initializeZadd_pager·   r¸   r¼   r¿   r¾   rº   rÀ   r»   r¹   rÁ   rÂ   Zcreate_configwidgetr’  r”  r•  rp   ÚstderrrË   Zset_current_indexrú  Zcheck_all_settingsZpages_widgetZcurrentChangedÚ$_MainWindow__preference_page_changedr  )r%  r“  r  ZPrefPageClassrÄ  r©  rh   rh   ri   rz  «
  s6    


zMainWindow.edit_preferencesc             C   s
   || _ dS )z!Preference page index has changedN)rË   )r%  rµ  rh   rh   ri   Z__preference_page_changedÊ
  s    z$MainWindow.__preference_page_changedc             C   s
   || _ dS )zSave preferences dialog sizeN)rÌ   )r%  rÏ  rh   rh   ri   r”  Î
  s    zMainWindow.set_prefs_sizec             C   s   | j  ||||f¡ dS )zz
        Register QAction or QShortcut to Spyder main application,
        with shortcut (context, name, default)
        N)r¯   r,  )r%  Zqaction_or_qshortcutr3  rm   r6  rh   rh   ri   r=  Ó
  s    
zMainWindow.register_shortcutc          	   C   sÒ   g }x¦t | jƒD ]˜\}\}}}}tt||ƒƒ}yZt|tƒrrtjdkrV|jdkrV||_n
| 	|¡ |r†t
|||ƒ nt|tƒr†| |¡ W q tk
r¦   | |¡ Y qX qW x t|ddD ]}| j |¡ qºW dS )z/Apply shortcuts settings to all widgets/pluginsrŠ   ZmissingT)ÚreverseN)rŠ  r¯   r   r`   r¡  r   rp   r«   r,  r-  rZ   r    ZsetKeyr;  r,  ÚsortedÚpop)r%  Ztoberemovedrµ  Zqobjectr3  rm   r6  Zkeyseqrh   rh   ri   rš  Ü
  s$    




zMainWindow.apply_shortcutsc             C   s    ddl m} |d ƒ}| ¡  d S )Nr   )ÚShortcutsSummaryDialog)Zspyder.widgets.shortcutssummaryr›  r  )r%  r›  r  rh   rh   ri   r‰  ó
  s    z MainWindow.show_shortcuts_dialogc          
   C   s
  | j  tjtjd¡ ttd}t dd|¡ | j  	d|f¡ | j  
d¡ x¼y| j  ¡ \}}W nz tjk
rÖ } zZtjdkr€tjntj}|jd |kr–wJtjdkr¦tjntj}|jd tj|gkrÄd S ‚ W d d }~X Y nX | d	¡}| d
¡}| j |¡ | d¡ qJW d S )Nrk   )Zdefault_portr*   Zopen_files_portz	127.0.0.1é   r   r   i   zutf-8ó    )r!  Z
setsockoptr   Z
SOL_SOCKETZSO_REUSEADDRrR   rC   r(   r  ZbindZlistenrE  rª  rl   rm   ÚerrnoZWSAEINTRZEINTRr§  ZWSAENOTSOCKZENOTSOCKZECONNABORTEDZrecvÚdecoder¹  rœ  Zsendall)r%  ZportZreqZdummyr(  ZeintrZenotsockr~  rh   rh   ri   r¸  ú
  s,    




z"MainWindow.start_open_files_serverc             C   s:   t  | tdƒtdƒt jt jB ¡}|t jkr6| jdd dS )zE
        Quit and reset Spyder and then Restart application.
        r  zSSpyder will restart and reset to default settings: <br><br>Do you want to continue?T)r@  N)r   r#  r.   r  r  rO  )r%  r  rh   rh   ri   r|    s
    
zMainWindow.reset_spyderc          
   C   s\  t dƒ}t |dd¡}tj ¡ }| dd¡}| d¡}t ¡ }tj	}|dk	rV|}d}	nd}	||d< t
|ƒ|d	< t
|	ƒ|d
< t
|ƒ|d< tr¶tjdkr¦d tj¡|d< nd tj¡|d< tjdkrÞt ¡ }
|
 jtjO  _d}nd}
d}d}| ||¡}y,|  d¡r tj||||
d | j ¡  W n4 tk
rV } zt|ƒ t|ƒ W dd}~X Y nX dS )zs
        Quit and Restart Spyder application.

        If reset True it allows to reset spyder on restart.
        r‹   rŒ   z
restart.pyZSPYDER_BOOTSTRAP_ARGSNZSPYDER_ARGSTFZ
SPYDER_PIDZSPYDER_IS_BOOTSTRAPZSPYDER_RESETr   ú;Z
PYTHONPATHú:z"{0}" "{1}")ry  ÚenvÚstartupinfo)rA   rn   ro   rl   r  Úcopyrš  Úgetpidrp   r|  r™   r/   rm   rg   r¶  ZSTARTUPINFOZdwFlagsZSTARTF_USESHOWWINDOWrÊ  r  ÚPopenr¶   r‡   r’  r“  )r%  r@  Zspyder_start_directoryZrestart_scriptr¢  Zbootstrap_argsZspyder_argsÚpidr`  Zis_bootstrapr£  ry  Zcommandrª  rh   rh   ri   rO  #  sF    




zMainWindow.restartc             C   s4   | j dd | j| }| j ||| ¡ | j ¡  dS )zShow interactive tour.T)rê  N)r~  rÃ   rb   Zset_tourZ
start_tour)r%  rµ  Zframesrh   rh   ri   rZ  d  s    
zMainWindow.show_tourc             C   sf   | j dk	r(| j jr(| j  ¡  d| j _dS |rD| j| j _| j  d¡ n| j  d¡ | j  ¡  d| j _dS )z%Open file list management dialog box.NFú@r”   T)rÄ   Z
is_visiblerŸ  r¸   r©  Zset_search_textrú  )r%  Úsymbolrh   rh   ri   ru  l  s    



zMainWindow.open_fileswitcherc             C   s   | j dd dS )z'Open symbol list management dialog box.T)r©  N)ru  )r%  rh   rh   ri   rv  {  s    zMainWindow.open_symbolfinderc             C   sH   | j dkrt| ||||ƒ| _ n| j  ||||¡ | j j | ¡ j¡ dS )z"Add a plugin to the File Switcher.N)rÄ   rU   Z
add_pluginZsig_goto_filer  Zget_current_tab_managerZset_stack_index)r%  r©  Ztabsr8  r0  rh   rh   ri   Úadd_to_fileswitcher  s
    
zMainWindow.add_to_fileswitcherc             C   sˆ  ddl m} | j}| jj}| jj}| jj}td }d}|tj	| d}| 
tdƒ¡ | tdƒ¡ | tj¡ | tj¡ d\}	}
t |	|
¡}| |¡ |d	k	rÈ|}| |¡ | d
¡ | ¡  | ¡ }nœ|r2d}dtjksædtjkrîtdƒ}tdƒ|||f }|d| 7 }| |¡ | d¡ | ¡  | ¡ }n2|rdtdƒ}| |¡ | d
¡ | ¡  | ¡ }t |	|
|¡ | j d
¡ d| _d	S )z"Called by WorkerUpdates when readyr   )ÚMessageCheckBoxz	/releasesz-https://docs.spyder-ide.org/installation.html)r0  ÚparentzSpyder updateszCheck for updates on startup)r*   r°  NFr”   ZAnacondazconda-forgea;  <hr><b>IMPORTANT NOTE:</b> It seems that you are using Spyder with <b>Anaconda/Miniconda</b>. Please <b>don't</b> use <code>pip</code> to update it as that will probably break your installation.<br><br>Instead, please wait until new conda packages are available and use <code>conda</code> to perform the update.<hr>a  <b>Spyder %s is available!</b> <br><br>Please use your package manager to update Spyder or go to our <a href="%s">Releases</a> page to download this new version. <br><br>If you are not sure how to proceed to update Spyder please refer to our  <a href="%s">Installation</a> instructions.z<br>TzSpyder is up to date.)Zspyder.widgets.helperwidgetsr«  rÈ   rÇ   Úupdate_availableÚlatest_releaserª  r3   r   ZInformationrË  r.   Zset_checkbox_textri  rÎ  ZsetDefaultButtonr(   r	  Zset_checkedr  Zset_check_visibler  Z
is_checkedrp   Úversionr  rÅ   r[  )r%  r«  Zfeedbackr­  r®  Z	error_msgZurl_rZurl_iZboxr×  r~   rˆ  ÚmsgZanaconda_msgrh   rh   ri   Ú_check_updates_readyŠ  sT    









zMainWindow._check_updates_readyc             C   s”   ddl m} | j d¡ | jdk	r,| j ¡  t| ƒ| _|| |d| _| jj 	| j
¡ | jj 	| jj¡ | j | j¡ | jj 	| jj¡ | j ¡  dS )zN
        Check for spyder updates on github releases using a QThread.
        r   )ÚWorkerUpdatesTN)r±  )Zspyder.workers.updatesr²  rÅ   r[  rÆ   Z	terminater   rÇ   Z	sig_readyr  r±  r‡   ZmoveToThreadZstartedr  )r%  r±  r²  rh   rh   ri   rˆ  Ø  s    


zMainWindow.check_updatesc             C   s@   |dkrt  tj¡S |dkr(t  tj¡S |dkr<t  tj¡S dS )z,Get the current OpenGL implementation in userw   rx   ry   N)r   ZtestAttributer   r{   r|   r}   )r%  r~   rh   rh   ri   Ú_test_setting_openglî  s    zMainWindow._test_setting_opengl)N)r*  )Fr*   )r*   F)F)r  )F)F)r”   r”   )NNF)F)F)F)F)F)F)vÚ__name__Ú
__module__Ú__qualname__Ú__doc__r   ZAllowTabbedDocksZAllowNestedDocksr  r   ZcursorFlashTimer‘  r9   r±   r³   r.   rŒ  rø  r   r²  r›  r  r™   r¹  rJ  rL  r—   r=   r/  r¬  rÇ  r  rÃ  rÛ  rá  ré  rì  rï  r  rô  r   r   rt  rs  r
  r—  r  r  r  r  r  r"  r$  r½  r˜  rw  r)  r*  rm  rn  r8  r¢  r£  r»  r¼  r?  r‚  rH  rI  rK  rO  rR  r  rY  rp  rr  r  r'  r~  rç  r€  r^  r  r…  rp  r†  r„  r‡  r<  r{  r  r  r„  rº  r‡  rµ   r´   r{  rŽ  r}  r$  r¾  r  rz  r—  r”  r=  rš  r‰  r¸  r|  rO  rZ  ru  rv  rª  r±  rˆ  r³  rh   rh   rh   ri   r€   ô   s  
  
    ~T
% 

1 ^
4++%		


	3	 T
8

!
@
Nr€   c                 s’   t ƒ ‰ ˆ  t¡ G ‡ fdd„dtƒ} ddlm} | |_g fdd„}|t_trZdd„ }|t_	d	gt_
ydd
lm} d|_W n tk
rŒ   Y nX ˆ S )z>Initialize Qt, patching sys.exit and eventually setting up ETSc                   s(   e Zd ZdZ‡ fdd„Zedd„ ƒZdS )z$initialize.<locals>.FakeQApplicationzSpyder's fake QApplicationc                s   ˆ } d S )Nrh   )r%  r§  )rŒ   rh   ri   r—     s    z-initialize.<locals>.FakeQApplication.__init__c               S   s   dS )z5Do nothing because the Qt mainloop is already runningNrh   rh   rh   rh   ri   r  
  s    z*initialize.<locals>.FakeQApplication.exec_N)r´  rµ  r¶  r·  r—   Ústaticmethodr  rh   )rŒ   rh   ri   ÚFakeQApplication  s   r¹  r   )Ú	QtWidgetsc             S   s   d S )Nrh   )Úargrh   rh   ri   Úfake_sys_exit  s    z!initialize.<locals>.fake_sys_exitc             S   s   t  | ||¡ d S )N)rp   Ú__excepthook__)Ztype_r&  Ztbackrh   rh   ri   Úspy_excepthook  s    z"initialize.<locals>.spy_excepthookr”   )Ú	ETSConfigZqt4)r+   ÚsetWindowIconrj  r   Úqtpyrº  rp   rN  r	   Ú
excepthookÚargvZenthought.etsconfig.apir¿  Ztoolkitr§   )r¹  rº  r¼  r¾  r¿  rh   )rŒ   ri   r•  û  s"    

r•  c               @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚSpyz£
    Inspect Spyder internals

    Attributes:
        app       Reference to main QApplication object
        window    Reference to spyder.MainWindow widget
    c             C   s   || _ || _d S )N)rŒ   Úwindow)r%  rŒ   rÅ  rh   rh   ri   r—   1  s    zSpy.__init__c             C   s"   t | j ¡ ƒdd„ t| jƒD ƒ S )Nc             S   s   g | ]}|d  dkr|‘qS )r   r.   rh   )rf   rÞ  rh   rh   ri   rj   6  s    zSpy.__dir__.<locals>.<listcomp>)ÚlistÚ__dict__r  ÚdirÚ	__class__)r%  rh   rh   ri   Ú__dir__4  s    zSpy.__dir__c             C   s   t ƒ S )N)r8   )r%  rh   rh   ri   rk  7  s    zSpy.versionsN)r´  rµ  r¶  r·  r—   rÊ  rk  rh   rh   rh   ri   rÄ  )  s   rÄ  c             C   sò   t |ƒ}y| ¡  W nF tk
rZ   |jdk	rTy|jj ¡  W n tk
rR   Y nX ‚ Y nX | ¡  | ¡  |jrŠt| |d|jjj	j
d< |r¦x|D ]}| |¡ q”W tjdkr¾t tjd¡ tƒ rÒ| j |j¡ | j |j¡ tƒ sî|  ¡  |S )zP
    Create and show Spyder's main window
    Start QApplication event loop
    N)rŒ   rÅ  ZspyrŠ   T)r€   r¬  ÚBaseExceptionr¶   ry  Zexit_interpreterrú  rÇ  rÄ  rz  r¥  rº  rp   r«   r   rz   r   ZAA_DontShowIconsInMenusr@   r¹  r  ZfocusChangedrR  r0   r  )rŒ   r&  r§  r*   Úarh   rh   ri   Ú
run_spyder;  s2    


rÍ  c        
   
   C   s¦  t ƒ r¢yddlm}  W n  tk
r6   ddlm}  Y nX | ƒ }d|_d|_d|_d|_d|_	d|_
d|_t dd¡dkrŒt dd¡}t|ƒ tƒ }t||dƒ}|S tƒ \}}|jrÂ|j}t|ƒ n$t dd¡dkræt dd¡}t|ƒ |jrôtdƒ tdk	r,t|j p(|jp(|jp(|jp(ttƒƒ tƒ }|jrDtƒ  dS |jr\tjd	d
 dS |jrŠddl}tjd|jd gdgd dS t ddd¡rÞtsÞt  ddd¡ t!dk	rÀt! "¡  t# $dddt%ƒ t&t't(t'f ¡ d}yt|||ƒ}W nˆ t)k
r2 } z t# $ddd¡ t  ddd¡ W dd}~X Y nJ t*k
rz   t  ddd	¡ ddl+}	|	j,t-d |	j,t.ddƒd Y nX |dkrœt!dk	r˜t! "¡  dS t/ƒ  dS )zMain functionr   )ÚMockNFr*   ZopenglZ	automaticz…(Deprecated) --show console does nothing, now the default  behavior is to show the console, use --hide-console if you want to hide itT)ZsaveZ
compileallz-O)Úmoduler§  Zp_argsZcrashr–   aH  Spyder crashed during last session.<br><br>If Spyder does not start at all and <u>before submitting a bug report</u>, please try to reset settings to defaults by running Spyder with the command line option '--reset':<br><span style='color: #555555'><b>spyder --reset</b></span><br><br><span style='color: #ff5555'><b>Warning:</b></span> this command will remove all your Spyder configuration files located in '%s').<br><br>If Spyder still fails to launch, you should consult our comprehensive <b><a href="%s">Troubleshooting Guide</a></b>, which when followed carefully solves the vast majority of crashes; also, take the time to search for <a href="%s">known bugs</a> or <a href="%s">discussions</a> matching your situation before submitting a report to our <a href="%s">issue tracker</a>. Your feedback will always be greatly appreciated.z¼Spyder was unable to load the <i>Spyder 3</i> icon theme. That's why it's going to fallback to the theme used in Spyder 2.<br><br>For that, please close this window and start Spyder again.Z
icon_themezspyder 2)rf  zspyder_crash.logÚw)0r0   Zunittest.mockrÎ  r§   Zmockrž   r    r¡   r¢   r£   r¥   Zopengl_implementationr(   r	  r   r•  rÍ  rF   Zshow_consoler“  r   Zhide_consolerB   Zreset_to_defaultsÚoptimizer'  r<   r‹   rN   rB  Ú__path__r/   r  r  rŸ  r   Zinformationr9   r5   r3   r4   r'   rË  r”  r•  r;   r¬   ÚORIGINAL_SYS_EXIT)
rÎ  r&  r~   rŒ   rÅ  r§  r‹   Z
mainwindowZ	fontErrorr”  rh   rh   ri   r*   m  sŽ    





Ú__main__)­r·  Z
__future__r   rž  r(  rl   Úos.pathrg   rn   rd   r¨   r   r¶  rp   r·  r”  rN  rÓ  r‹   r   Z
check_pathZcheck_qtZcheck_spyder_kernelsr   r   r   rm   Zspyder.utils.windowsZrope.base.projectZroper§   rÁ  r   r	   Zqtpy.compatr
   ru  r   r   r   r   r   r   r   r   r   r   Z
qtpy.QtGuir   r   r   r   r   Zqtpy.QtWidgetsr   r   r   r   r   r   r    r!   r"   r#   r$   Zqtpy.QtQuickr%   r&   r’  Zqtawesome.iconic_fontr'   Zspyder.config.mainr(   Úhasattrrz   r)   r	  Zspyder.utils.qthelpersr+   r,   Zspyder.config.baser-   r  rj  rÀ  r.   r/   r0   r  ZfontZSPLASH_FONTZsetPixelSizeZsetFontrú  ry  r@  rA  rB  rC  rD  r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   Zspyder.config.utilsrD   rE   Zspyder.app.cli_optionsrF   rG   Zspyder.py3compatrH   rI   rJ   rK   rL   r  Zspyder.utilsrM   rN   rO   ro  Zspyder.utils.introspectionrP   Zspyder.utils.programsrQ   Zspyder.utils.miscrR   rS   rT   Zspyder.widgets.fileswitcherrU   Zspyder.utils.environrV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   Zspyder.config.guir`   Zspyder.otherpluginsra   Z
spyder.apprb   r…  rv   r   r€   r•  ÚobjectrÄ  rÍ  r*   r´  rh   rh   rh   ri   Ú<module>   sâ   
	0,



$0	
,                      .2~
