
    G@do                    P   d Z ddlm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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mZ  ej                     ddlmZ ddlmZmZmZmZmZmZ ddl m!Z!m"Z" dd	l#m$Z$m%Z%m&Z&m'Z'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m0Z0 ddl1m2Z2m3Z3 ddl4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z= ddl>m?Z? ddl@mAZA ddlBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZK ddlLmMZM ddlNmOZO ddlPmQZQ ddlRmSZSmTZT ddlUmVZV ddlWmXZX ddlYmZZZm[Z[ ddl\m]Z] ddl^m_Z_m`Z`maZa ddlbmcZc ddldmeZemfZfmgZgmhZhmiZi ddljmkZk dd llmmZm dd!lnmoZompZpmqZqmrZrmsZs dZtdZudZve
jw        d"k    rdd#lxmtZtmvZv  e	jy        ez          Z{ ee:            G d$ d%e%eA          Z|d& Z}ezd'k    r e}             dS dS )(u%  
Spyder, the Scientific Python Development Environment
=====================================================

Developed 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)
    )OrderedDictN)Enum)requirements)from_qvariant)QCoreApplicationQtQTimerSignalSlotqInstallMessageHandler)QColorQKeySequence)QApplicationQMainWindowQMenuQMessageBox	QShortcutQStyleFactory)QtSvg)QtWebEngineWidgets)	FontError)__version__)dependencies)find_external_pluginsfind_internal_plugins)	create_applicationcreate_splash_screencreate_windowORIGINAL_SYS_EXITdelete_debug_log_filesqt_message_handlerset_links_colorsetup_loggingset_opengl_implementation)PLUGIN_REGISTRY)SpyderConfigurationAccessor)	_DEVget_conf_pathget_debug_levelget_home_dir
is_pynsistrunning_in_mac_apprunning_under_pytestSTDERR)is_dark_font_color)OPEN_FILES_PORT)CONF)
IMPORT_EXTis_gtk_desktop)get_spyderplugins_mods)to_text_string)encodingprograms)ima)select_portgetcwd_or_homeget_python_executable)QStylePalette)create_actionadd_actionsfile_uriqapplication
start_file)APP_STYLESHEET)SpyderAPIError)PluginsSpyderPluginSpyderPluginV2SpyderDockablePluginSpyderPluginWidgetnt)set_attached_console_visibleset_windows_appusermodelidc                       e Zd ZdZdZej        ej        z  ej        z  Z	dZ
 e            Z e            Z e            Z e            Z ee          Z ed          Z ed          Z ee          Z eee          Z ee          Z	 dDdZdEd	Zd
 Zd Zd Zd Zd ZdFdZ d Z!d Z"dGdZ#dGdZ$d Z%d Z&dEdZ'd Z( fdZ)d Z*d Z+d Z,d Z-d Z.	 dHdZ/	 dHd Z0d! Z1d" Z2d# Z3d$ Z4d% Z5d& Z6d' Z7d( Z8d) Z9d* Z:d+ Z;d, Z<d- Z=d. Z>d/ Z?d0 Z@dFd1ZAd2 ZBd3 ZCd4 ZD	 dId5ZEdId6ZFd7 ZGd8 ZHd9 ZId: ZJd; ZK eL            d<             ZMd= ZNd> ZOdFd?ZPdId@ZQdA ZRdB ZSdC ZT xZUS )J
MainWindowzSpyder main windowmain   QResizeEvent
QMoveEventNc           
      
   t          j        |            t          j                    }t	                      rd | _        nddlm}  |d           | _        |                    t          j
                   t          j        dk    r)|                    t          j        dd                     t!          |                                                                          | _        || _        t*                              d           dd}t          j        dk    r,	 dd l}|                    |d           nU# t2          $ r Y nIw xY wt5          j        t4          j        |           t8          st5          j        t4          j        |           g | _        g | _        tA                      | _!        tA                      | _"        tF          j$        tF          j%        tF          j&        tF          j'        tF          j(        tF          j)        tF          j*        tF          j+        tF          j,        d		| _-        g | _.        d | _/        d | _0        d | _1        d | _2        d | _3        d | _4        d | _5        d | _6        d | _7        d | _8        g | _9        d | _:        g | _;        d | _<        g | _=        d | _>        g | _?        d | _@        g | _A        d | _B        g | _C        d | _D        g | _E        d | _F        g | _G        g | _H        t	                      r| I                    d
d           t          jJ                    | _K        t          )t                      }t*                              d|           t          jM        N                    d          }|bt                      }	d}
t          |           | _Q        | jQ        jR        S                    |	jT                   | jQ        U                    |
           || _V        | W                    dd          t          k    r| I                    dt                     g | _Y        d| _Z        d| _[        d| _\        d | _]        d | _^        d | __        d | _`        t          j        dk    r	 t          ja        t          jb        t          jc        t          jd                  | _e        n# t          $ rK d | _e        t          jh        d dt          d          j                    t          jl                             Y n=w xY wt          ja        t          jb        t          jc        t          jd                  | _e        | m                                 t*                              d           d S )Nr   )SpyderProxyStylerJ   windows_app_iconT)resamplezStart of MainWindow constructorc                     t           j                            d| z             t           j                                         t	          j                     dS )zHandler for signals.zHandling signal: %s
N)sysstdoutwriteflushr   quit)signumframes     5lib/python3.11/site-packages/spyder/app/mainwindow.pysignal_handlerz+MainWindow.__init__.<locals>.signal_handler   sG    J4v=>>>J    )	consolemaininterpreteroutlineexplorervariableexplorer
ipyconsoleworkingdirectoryprojectsfindinfileslayoutsshow_internal_errorsFzappusermodelid: %sTEST_CI_APPi0u  current_version defaultSpyderzAn 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: {color}'><b>netsh winsock reset </b></span><br>)colorzEnd of MainWindow constructorN)nr   __init__r   instancer.   _proxy_stylespyder.utils.qthelpersrT   setAttributer   AA_UseHighDpiPixmapsosnamesetWindowIconr9   get_iconstrstyle
objectNamedefault_style_cli_optionsloggerinfowin32apiSetConsoleCtrlHandlerImportErrorsignalSIGTERMr(   SIGINTshortcut_datashortcut_queuer   _APPLICATION_TOOLBARS_STATUS_WIDGETSrE   ConsoleMainInterpreterOutlineExplorerVariableExplorerIPythonConsoleWorkingDirectoryProjectsFindLayout_INTERNAL_PLUGINS_MAPPINGthirdparty_pluginsswitcherprefs_dialog_sizeprefs_dialog_instanceundo_actionredo_actioncopy_action
cut_actionpaste_actionselectall_action	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file_toolbarfile_toolbar_actionsrun_toolbarrun_toolbar_actionsdebug_toolbardebug_toolbar_actionsmenusset_confcursorFlashTimeCURSORBLINK_OSDEFAULTrL   environgetrA   r	   timer_shutdowntimeoutconnectr\   startsplashget_confr   
widgetlistalready_closedis_starting_upis_setting_upwindow_sizewindow_positionlast_focused_widgetprevious_focused_widgetsocketAF_INETSOCK_STREAMIPPROTO_TCPopen_files_serverOSErrorr   warningr'   formatr=   COLOR_BACKGROUND_4apply_settings)selfr   optionsqapprT   r`   r   restest_appapptimer_shutdown_times              r_   rt   zMainWindow.__init__   s)   T"""$&&!! 	7 $D?????? 0 0 6 6D 	"1222 7d?? s|,>NNNOOO !!8!8!:!:;; $5666	  	  	  	  7d??..~tDDDD    M&..999 = fm^<<<    &1]]"*}}
 &6&6 ' 8!0 ' 8("<~
*
 
*
& #%  "&%)"    $ !##% #%  ""$ !$&!#% !%'"
!! 	9MM0%888%1%A%C%C"%1,..CKK,c222 :>>-00..C"'"(,,D'//999%%&9::: ==*B=77;FFMM+[999  $"!# $( '+$
 7d??)/v~7=7I7=7I*K *K&&    )-&# ( ) )
 *0 - @ *0 *B *B
 
 
 
 
 &,]6>393E393E&G &GD"
 	 	344444s%   D5 5
EE 9R AS/.S/Tc                 j    |t           v rt          j        |          S |rt          d| d          dS )zI
        Return a plugin instance by providing the plugin class.
        zPlugin "z" not found!N)r%   
get_pluginrD   )r   plugin_nameerrors      r_   r   zMainWindow.get_plugin\  sH     /))"-k::: 	G !EK!E!E!EFFFtra   c                     g }t           D ]I}t          j        |          }t          |t          t          f          r|                    ||f           J|S )z#Get a list of all dockable plugins.)r%   r   
isinstancerH   rI   append)r   dockable_pluginsr   plugins       r_   get_dockable_pluginszMainWindow.get_dockable_pluginsh  s`    * 	? 	?K$/<<F&#79K"LMM ? ''f(=>>>ra   c                 *    t          j        |          S )z2Determine if a given plugin is going to be loaded.)r%   is_plugin_enabledr   r   s     r_   r   zMainWindow.is_plugin_enabledq  s    0===ra   c                 *    t          j        |          S )z)Determine if a given plugin is available.)r%   is_plugin_availabler   s     r_   r   zMainWindow.is_plugin_availableu  s    2;???ra   c                     |                                  }|                                r|                    ||           dS dS )z>
        Show a status message in Spyder Main Window.
        N)	statusBar	isVisibleshowMessage)r   messager   
status_bars       r_   show_status_messagezMainWindow.show_status_messagey  sM     ^^%%
!! 	5""7G44444	5 	5ra   c                 t   t          |           }|                    t          j                   |                    t          j                   |                    t          d                     |                    |           |	                    t           j
                   |                                 dS )z/
        Show a compatibility message.
        zCompatibility CheckN)r   setWindowModalityr   NonModalrx   WA_DeleteOnClosesetWindowTitler'   setTextsetStandardButtonsOkshow)r   r   
messageBoxs      r_   !show_plugin_compatibility_messagez,MainWindow.show_plugin_compatibility_message  s     !&&
$$R[111 3444!!!$9":":;;;7###%%kn555ra   Fc                      t          j        |                               t          d                                                                                   t                              d                    j                             	                                \  }}|_
                                         |s                     |           dS j                             j                   j                             j                   j                             j                   j                             j                   j                             j                   j                             j                   j                             j                   j        t8                                        j                   t;          t<                    r\j                             j                    j!                             j"                   j#                             fd            j$                            j%                    j&                            j'                    j(                            j)                   *                    |           t;          t<                    rV +                               d} ,                    d          r ,                    d          }-                    |           |t\          j/        k    r, j0        D ]\  }}}	 1                    |||	           g  _0        t                              d                    j                             2                                3                                D ]\  }	}ti          |d	j                  pj        }ti          |d
d          rdt;          |	tj                    r|	j6        }	t\          j/        t           v r 1                    |||	           z j0        7                    |||	f           t;          t<                    r	 d}d                    j8                  }
n!# tr          j:        tr          j;        f$ r Y nw xY wty          t{                        fd          }|>                    t~          j@                   |_A        t\          j/        t           v r5 1                    |||
            1                    jB        ||
           dS  j0        7                    |||
f            j0        7                    jB        ||
f           dS dS )z:
        Register a plugin in Spyder Main Window.
        zLoading {}...Nc                  .                                    S rs   )set_ancestorr   r   s   r_   <lambda>z,MainWindow.register_plugin.<locals>.<lambda>  s    ++D11 ra   	omit_confr   use_custom_margincustom_marginzRegistering shortcuts for {}...shortcut_contextregister_shortcutTr'   switch to {}c                  .                                    S rs   )switch_to_pluginr   s   r_   r   z,MainWindow.register_plugin.<locals>.<lambda>  s    4#8#8#@#@ ra   )Cr%   r   
set_splashr'   r   get_namer   r   NAMEcheck_compatibilityis_compatibleget_descriptionr   sig_exception_occurredr   handle_exceptionsig_free_memory_requestedfree_memorysig_quit_requestedclosesig_restart_requestedrestartsig_redirect_stdio_requestedredirect_internalshell_stdiosig_status_message_requestedr   sig_unmaximize_plugin_requestedunmaximize_pluginobjectr   rH   sig_focus_changedplugin_focus_changedsig_switch_to_plugin_requestedr  sig_update_ancestor_requested	sig_movedsig_mainwindow_movedsig_resizedsig_mainwindow_resizedsig_window_state_changedsig_mainwindow_state_changed	_registeradd_dockwidgetr   update_marginsrE   	Shortcutsr   r  get_actionsitemsgetattrr   valuer   CONF_SECTIONcpNoSectionErrorNoOptionErrorr   r   
setContextr   ApplicationShortcut	_shortcuttoggle_view_action)r   r   externalr   r  r   marginactioncontextaction_namer{   scr   s   `           @r_   register_pluginzMainWindow.register_plugin  s    !+K88/**11&//2C2CDDEEEO**6;77888 "(!;!;!=!=w,    	227;;;F 	%--d.CDDD(001ABBB!))$*555$,,T\:::+33-	/ 	/ 	/+33D4LMMM.66t7MNNN.v6>>"	$ 	$ 	$ f233 	3$,,T-FGGG199%' ' '088111113 3 3 	v:;;;  !>???%--/	1 	1 	1 	9---f233 	*''' F}}011 877!!&)))'+++040C E E,&&vwDDDD"$D5<<V[IIJJJ#)#5#5#7#7#=#=#?#? 
	O 
	OKv'96;GG & +  v2D99 Ok400 4"-"3K$77**67KHHHH'../MNNNf233 	@%,,V-@AA%r'78    <>>4@@@@@B BBMM"0111!F O33&&r7D999&&-w> > > > > #**B+>???#**.>@ @ @ @ @%	@ 	@s   0R R+*R+c                    t                               d                    |j                             |j        |j        |j        g}|D ]'}	 |                                 # t          $ r Y $w xY wt                               d                    |j                             |	                                
                                D ]>\  }}t          |d|j                  p|j        }| j                            |||           ?d}	 d}d                    |j                  }|                     |||j                  }n# t           $ r Y nw xY w|9| j                            |j        |d                    |j                             t                               d	                    |j                             |                     |           |                                 dS )
zB
        Unregister a plugin from the Spyder Main Window.
        zUnloading {}...z!Unregistering shortcuts for {}...r  Nr'   r  r   zSwitch to {}zRemoving {} dockwidget...)r   r   r   r	  r  r  r  
disconnect	TypeErrorr)  r*  r+  	shortcutsunregister_shortcutr-  get_shortcut	Exceptionr3  remove_dockwidget_unregister)	r   r   signalssigr9  r7  r8  shortcutr{   s	            r_   unregister_pluginzMainWindow.unregister_plugin  s    	%,,V[99::: %//
  	 	C        	7>>v{KKLLL#)#5#5#7#7#=#=#?#? 	M 	MKv'96;GG & + N..vwLLLL 		G!(()<==D(("/ )  HH
  	 	 	D	 N.. %%f&9::   	/66v{CCDDDv&&&s$   A!!
A.-A.9E 
EEc                     | j         }|j        .|.|                    ||          }|                                 |S dS dS )z>
        Create configuration dialog box page widget.
        N)r   CONF_WIDGET_CLASS
initialize)r   r   config_dialogconf_widgets       r_   create_plugin_conf_widgetz$MainWindow.create_plugin_conf_widget   sU     2#/M4M 226=IIK""$$$ 0/4M4Mra   c                 >    | j                             ||           dS )z
        Switch to `plugin`.

        Notes
        -----
        This operation unmaximizes the current plugin (if any), raises
        this plugin to view (if it's hidden) and gives it focus (if
        possible).
        )force_focusN)rj   r  )r   r   rQ  s      r_   r  zMainWindow.switch_to_plugin*  s%     	%%f+%FFFFFra   c                 v    || j                                          dS | j                             |           dS )z
        Unmaximize currently maximized plugin, if any.

        Parameters
        ----------
        not_this_plugin: SpyderDockablePlugin, optional
            Unmaximize plugin if the maximized one is `not_this_plugin`.
        N)plugin_instance)rj   unmaximize_dockwidgetunmaximize_other_dockwidget)r   not_this_plugins     r_   r  zMainWindow.unmaximize_plugin6  sP     "L..00000L44 / 5 1 1 1 1 1ra   c                     |                      |j                   	 | j                            |           dS # t          $ r Y dS w xY w)zC
        Remove a plugin QDockWidget from the main window.
        N)removeDockWidget
dockwidgetr   remove
ValueError)r   r   s     r_   rD  zMainWindow.remove_dockwidgetE  s^     	f/000	O""6***** 	 	 	DD	s   8 
AAc                 z    |                      t          j        d          }|r|                    |           dS dS )a  
        This method will call the handle exception method of the Console
        plugin. It is provided as a signal on the Plugin API for convenience,
        so that plugin do not need to explicitly call the Console plugin.

        Parameters
        ----------
        error_data: dict
            The dictionary containing error data. The expected keys are:
            >>> error_data= {
                "text": str,
                "is_traceback": bool,
                "repo": str,
                "title": str,
                "label": str,
                "steps": str,
            }

        Notes
        -----
        The `is_traceback` key indicates if `text` contains plain text or a
        Python error traceback.

        The `title` and `repo` keys indicate how the error data should
        customize the report dialog and Github error submission.

        The `label` and `steps` keys allow customizing the content of the
        error dialog.
        Fr   N)r   rE   r   r  )r   
error_datarb   s      r_   r  zMainWindow.handle_exceptionO  sG    < //'//?? 	1$$Z00000	1 	1ra   c                    t           D ]}t          j        |          }t          |t                    r	 |j        }n# t
          $ r
 |j        }Y nw xY w|rg|j        }	 d}d                    |          }| 	                    |||          }n=# t          j        t          j        f$ r t                      }Y nw xY wt                      }|                    |           dS )aV  
        Display the shortcut for the "Switch to plugin..." on the toggle view
        action of the plugins displayed in the Help/Panes menu.

        Notes
        -----
        SpyderDockablePlugins provide two actions that function as a single
        action. The `Switch to Plugin...` action has an assignable shortcut
        via the shortcut preferences. The `Plugin toggle View` in the `View`
        application menu, uses a custom `Toggle view action` that displays the
        shortcut assigned to the `Switch to Plugin...` action, but is not
        triggered by that shortcut.
        r'   r  r=  N)r%   r   r   rH   r4  AttributeError_toggle_view_actionr-  r   rB  r.  r/  r0  r   setShortcut)	r   r   r   r   r7  sectionr8  r{   rH  s	            r_   _update_shortcuts_in_panes_menuz*MainWindow._update_shortcuts_in_panes_menus  s    + 	- 	-K$/<<F&"677 -8#6FF% 8 8 8#7FFF8  
.$1G2"%-44W==#'#4#4 'w $5 $@ $@-r/?@ 2 2 2#/>>2  ,~~H""8,,,-	- 	-s!   <AA/B)B98B9c           
          t           j                             fd           t          j                    ddlm}m} t                              d           t                              d            	                    dd          } 	                    d	d          }|d
k    rt                      s-t          j                    }|                     j                   t          t                     }                     |                                                                |           |}n|dk    rt                      s-t          j                    }|                     j                   t          t                     }                     |                                                                |           |}n|dk    rt'          |          st                      s-t          j                    }|                     j                   t          t                     }                     |                                                                |           |}nRt          t                     }                     |                                                                |           |}                     d|d                                            }	|	                    d           |	                    t/          d          d           t                              d                                             t3                      }
t5                      }|
                                }|                    |                                           i }i }i }|                                D ]}|j        } j        j         rd|v r| j!        v r j!        |         n|}||v r||f||<   n||f||<   	  	                    d|          r|||<   t          j"        |           w# tF          j$        tF          j%        f$ r |||<   t          j"        |           Y w xY wt          j&        |           t          j'        |           |D ]:}||v r4||         }tQ          |tR                    rt          j*         |d           ; +                    tX          j-                  }|j.                             j.                   |D ]T}||v rN||         }tQ          |t^                    r1t          j*         |d          } j0        1                    |           U|
D ]}||v rz|
|         }	 t          j*         |d          }'# td          $ rL}tg          |dt          |          th                     tk          j6        th                     Y d}~xd}~ww xY w 7                    t/          d                     tq                      D ]Q}	 t          j*         |d          }|9                                d         rtu          |d          r j0        1                    |           tu          |d          s j;        <                    |           |j=        }|>                    dd          }|j?        r|j?        }n|@                                }t          jB        |||ddt          jC                    # t          $ r Y td          $ rM}tg          |dt          |          th                     tk          j6        th                     Y d}~Kd}~ww xY w E                                 t                              d!           dd"lFmG}mH}  jI        }|J                    d#           _K        |J                    d$           _L        |J                    d%           _M         jM        jN                             jO                   |J                    d&           _P        |J                    d'           _Q        t           t/          d(          t          jT        d)          t/          d*           jU        t          jW        d+,           _X         Y                     jX        dd-.           t           t/          d/          t          jT        d0          t/          d1           jZ        t          jW        d2,           _[         Y                     j[        dd3d4            fd5} |d6t/          d6          t          jT        d7                     _\         |d8t/          d8          t          jT        d9                     _]         |d:t/          d:          t          jT        d;                     _^         |d<t/          d<          t          jT        d=                     __         |d>t/          d>          t          jT        d?                     _`         |d@t/          d@          t          jT        dA                     _a         xjb         j\         j]        d j_         j^         j`         ja        dgz  c_b         +                    tX          jc        dB          r xjb         jd        jb        z  c_b         jX         j[        g}|D ]*} |e                    | |jf        |jg        |jh        C           + 7                    d           t                              dD            ji        }!|!j                    dE           _k        |!j                    dF           _l        |!j                    dG           _m         7                    t/          dH                     t           jK         jb                   t           jL         jo                   t           jM         jp                   t           jP         jq                   t           jQ         jr                    js        t                                 dS )IzSetup main window.c                 2                         | |          S )Nr   )r;  )r   r   r   s     r_   r   z"MainWindow.setup.<locals>.<lambda>  s"    4+?+?y ,@ ,2 ,2 ra   r   )CSS_PATHDARK_CSS_PATHz!*** Start of MainWindow setup ***zApplying theme configuration...ui_theme
appearancerc  selecteddarklight	automaticcss_path	StatusBarzWelcome to Spyder!i  zLoading switcher...helpenableFr5  Tz: fileNz"Loading old third-party plugins...CONFIGWIDGET_CLASSCOMPLETION_PROVIDER_NAMEr'   -rn   )kindzCreating Menus...)ApplicationMenusFileMenuSectionsr   r   r   r   r   zFile switcher...filelistzFast switch between filesfile_switcher)icontip	triggeredr8  id_zFile switcher)r8  r{   zSymbol finder...symbol_findzFast symbol search in filesymbol_finderzsymbol finder)r8  r{   add_shortcut_to_tipc                    |                      d          }|d                                         d                    |dd                    z   }t          ||j        |t
          j                  }                    |d|            |S )N r   rn      )r  r  datar8  Editor)splitlowerjoinr>   global_callbackr   WidgetShortcutr  )texttr_textr  textseqmethod_namer7  r   s         r_   create_edit_actionz,MainWindow.setup.<locals>.create_edit_actionf  s    jjooG!!***,,rwwwqrr{/C/CCK"4(,-1-A(3+-+<	> > >F
 ""68T:::Mra   UndoundoRedoredoCopyeditcopyCuteditcutPaste	editpastez
Select All	selectallr]  )menu_idrc  before_sectionzCreating toolbars...r   r   r   zSetting up main window...)ur%   sig_plugin_readyr   set_main#spyder.plugins.help.utils.sphinxifyrg  rh  r   r   r   r.   r   ru   setStylerv   r~   rC   setStyleSheetr   r0   r   setObjectNamer   r'   create_switcherr   r   copyupdatevaluesr	  r   no_web_widgetsr   set_plugin_enabledr.  r0  r/  set_all_internal_pluginsset_all_external_plugins
issubclassrG   r;  r   rE   PythonpathManagersig_pythonpath_changedrF   preferencesregister_plugin_preferencesrC  printr/   	traceback	print_excr  r5   r
  hasattrr   r   __name__replaceDESCRIPTIONget_plugin_titler   addPLUGINr?  set_window_titlespyder.plugins.mainmenu.apir{  r|  mainmenuget_application_menur   r   r   aboutToShowupdate_source_menur   r   r>   r9   r  open_switcherr   r2  file_switcher_actionr  open_symbolfindersymbol_finder_actionr   r   r   r   r   r   r   r  editoradd_item_to_application_menuFileSwitcherRestarttoolbarget_application_toolbarr   r   r   r?   r   r   r   r   all_actions_definedemit)"r   rg  rh  ri  color_schemer   dark_qssrp  	light_qssstatusexternal_pluginsinternal_pluginsall_pluginsenabled_pluginsregistry_internal_pluginsregistry_external_pluginsr   r   plugin_main_attribute_namePluginClassppmrS  r   modmoduler{   descriptionr{  r|  r  r  switcher_actionsswitcher_actionr  s"   `                                 r_   setupzMainWindow.setup  s   (002 2 2 2	3 	3 	3 	 &&& 	POOOOOOO78885666==\=BB}}Z}FFv')) 1#,..d/000>**Hx(((NN**8444$HH  ')) 1#,..d/000N++Iy)))NN**9555HH$$%l33 $+-- 5'022DMM$"3444~..""8,,,  ..x888(//	""9---  ..y999# 	j(LAAA !![)))1122D999 	)*** 122022&++--+0022333 $&!$&!!((** 	@ 	@F +K  / [(( $"@@@ .{;;  ' ....:8)+66 /:8)+6@==3M=NN D39OK0#6{CCC$b&78 @ @ @/5,2;?????@ 	01JKKK01JKKK , 	D 	DKo--.{;k>:: D#3D+=BD D D D oog788"**4+FGGG , 	) 	)Ko--.{;k<88 )&5&EkE'; '; ';O$@@') ) ) , 	5 	5Ko--.{;5&5&EkD': ': ':OO  5 5 5kkk3u:::>VLLLL'V4444444445 . 	>??@@@)++ 	1 	1C1(8sBFH H H--//2 Iv';<< M(DDVLLL"6+EFF ?/66v>>> !\F!>>#s33D) @&,&8&,&=&=&?&? $VT;%'L4GI I I I    1 1 1###s5zzz2@@@@#0000000001
 	 	'(((	0 	0 	0 	0 	0 	0 	0 	0=!66{CC#88GG#88GG$,,T-DEEE 55jAA"77EE %2 !!*%%-..(*%
 %
 %
! 	t8#$3 	 	5 	5 	5$1!&''-((.//,*%
 %
 %
! 	t8#$3 	 	O 	O 	O		 		 		 		 		 .-faii.1hv.>.>@ @--faii.1hv.>.>@ @--faii.1hz.B.BD D,,UAeHH-0Xi-@-@B B..w'

/2x/D/DF F 2 2<34\??368K3H3H!J !J 	4#3T5E#'$:J#'#4d6K#'#) 	) ??7>?77 	D""dk&CC"" %%
  0 	 	O11(-(1/7	 2     	 	*+++,#;;NKK"::=II$<<_MM566777 	DND$:;;;D$d&>???D$d&>???DM4#8999DOT%<=== 	 %%'''''sK   	0P::4Q10Q1?V
W-!AW((W-%C)\
]1	]1$A],,]1c                    	 || j                                         v r"|                     | j         |         d          S |                     |          S # t          $ r Y nw xY wt	                                          |          S )z
        Redefinition of __getattr__ to enable access to plugins.

        Loaded plugins can be accessed as attributes of the mainwindow
        as before, e.g self.console or self.main.console, preserving the
        same accessor as before.
        Fr]  )r   keysr   rD   super__getattr__)r   attr	__class__s     r_   r  zMainWindow.__getattr__  s    	t5::<<<<248 ' G G G??4((( 	 	 	D	ww""4(((s   <A  A 
A"!A"c                 L   t                               d           t          D ];}t          j        |          }	 |                                 ,# t
          $ r Y 8w xY w| j        | j                                         |                                 	                                D ]g}t          |t                    rP	 |j                            | j                   |j                            | j                   W# t           $ r Y cw xY wh| j        | j                                         | j        0|                     dd          r| j                                         | j        | j                                         t                               d           d| _        dS )z
        Actions to be performed before the main window is visible.

        The actions here are related with setting up the main window.
        zSetting up window...Nzwindow/statero   z*** End of MainWindow setup ***F)r   r   r%   r   before_mainwindow_visibler`  r   hidemenuBarchildrenr   r   r  r   update_edit_menuupdate_search_menur?  rj   register_custom_layoutsr   tabify_new_pluginsr   )r   r   rS  childs       r_   pre_visible_setupzMainWindow.pre_visible_setup  s    	*+++* 	 	K-8EEO99;;;;!    ;"K \\^^,,.. 	 	E%'' %--d.CDDD%--d.EFFFF    D	 <#L00222 L$nd;; % L22444 <#L++---5666#s#   A
AA<>C;;
DDc                    | j                                          t          j                     | j        | j                                         t          D ]_}|t          j        k    rMt          j	        |          }	 |                                 t          j                     O# t          $ r Y [w xY w`| j                                         |                     d          rg| j        j        s[| j        rTt#          j        | j                  }d|_        |                                 | j                            | j                   |                                  |                                  |                                                                  t:           dt<          j        vsJ dt<          j        vsJ |                                   d| _!        | j"                                         dS )zj
        Actions to be performed only after the main window's `show` method
        is triggered.
        Nsingle_instance)targetTpandas
matplotlibF)#rj   on_mainwindow_visibler   processEventsr   r  r%   rE   r   r   r`  restore_scrollbar_positionr  r   r   new_instancer   	threadingThreadstart_open_files_serverdaemonr   sig_open_external_filer   open_external_filerd  reopen_last_sessionr  raise_r(   rX   modulesrestore_undocked_pluginsr   sig_setup_finished)r   r   r   ts       r_   post_visible_setupzMainWindow.post_visible_setup  s    	**,,, 	"$$$;"K + 	 	Kgn,,(3K@@00222 .0000%   D - 	',,... MM+,,	I!.	I "	I
  (DEEEAAHGGIII '//0GHHH 	,,... 	  """ 	 ?3;....s{2222 	%%''' #$$&&&&&s   ;'B##
B0/B0c                 4   |                      t          j        d          }|                      t          j        d          }d}|r|                                d}nd}|r4|r4t
                              d           |                    d           dS dS dS )z
        Reopen last session if no project is active.

        This can't be moved to on_mainwindow_visible in the editor because we
        need to let the same method on Projects run first.
        Fr]  NTz0Restoring opened files from the previous session)close_previous_files)r   rE   r   r  get_active_projectr   r   setup_open_files)r   rh   r  r  s       r_   r  zMainWindow.reopen_last_session1  s     ??7#35?AAu==# 	'**,,4&*#"& 	@) 	@KKJKKK###?????	@ 	@ 	@ 	@ra   c                 x   t                               d           t          D ]}t          j        |          }t	          |t
                    r,|                    dd          r|                                 Wt	          |t                    r+|	                    dd          r|
                                 dS )z;Restore plugins that were undocked in the previous session.z4Restoring undocked plugins from the previous sessionundocked_on_window_closeFro   N)r   r   r%   r   r   rH   r   r   rI   
get_option_create_window)r   r   r   s      r_   r  z#MainWindow.restore_undocked_pluginsF  s    JKKK* 	, 	,K$/<<F&"677 ,??#=u?MM +((***F$677 ,$$%?-2 % 4 4 ,))+++	, 	,ra   c                    t           2dt          dt          j        d         dt          j        d         d}nHt	                      st                      rd}n)d	t          j        d         dt          j        d         d}t                      r|d
t                      z  z  }| j        j        }||dt          |          z   z  }| 
                    t          j        d          }|rN|                                }|r8|                    t                      d          }d                    ||          }|| _        |                     | j                   dS )zSet window title.NzSpyder z	 (Python r   .r  )rq   zSpyder (Python z [DEBUG MODE %d]z -- Fr]  ~z	{0} - {1})r(   r   rX   version_infor-   r,   r*   r   window_titler6   r   rE   r   get_active_project_pathr  r+   r   
base_titler   )r   titler  rh   paths        r_   r  zMainWindow.set_window_titleT  sj   ??3>;;363CA3F3F3F363CA3F3F3FHEE  !! 	EZ\\ 	EEE	E 140@0C0C0C030@0C0C0CEE  	=(?+<+<<<E(5#W~l;;;;E ??7#35?AA 	93355D 9||LNND99$++D%88DO,,,,,ra   c                     |                      t          j        d          }|r|                    |||||           d S d S NFr]  )r  r   )r   rE   r(  r  r   qaction_or_qshortcutr8  r{   r  r   r@  s          r_   r  zMainWindow.register_shortcutu  sb    OOG$5UOCC	 	''$$7' (     	 	ra   c                     |                      t          j        d          }|r|                    |||||           d S d S r  )r   rE   r(  rA  r   s          r_   rA  zMainWindow.unregister_shortcut  sb    OOG$5UOCC	 	))$$7' *     	 	ra   c                 8    | j                             |           S )N)parent)applicationget_application_context_menur   s    r_   createPopupMenuzMainWindow.createPopupMenu  s    <<D<IIIra   c                     |                      d          r|                                 dS |                                 dS )zcloseEvent reimplementationTN)closingacceptignorer   events     r_   
closeEventzMainWindow.closeEvent  s8    << 	LLNNNNNLLNNNNNra   c                     |                                  s2| j                                        s|                                 | _        t          j        | |           | j                            |           dS )Reimplement Qt methodN)	isMaximizedrj   get_fullscreen_flagsizer   r   resizeEventr!  r  r-  s     r_   r5  zMainWindow.resizeEvent  sm    !! 	+$,*J*J*L*L 	+#yy{{De,,, 	e$$$$$ra   c                    t          | d          rM| j        F|                                 s2| j                                        s|                                 | _        t          j        | |           | j        	                    |           dS )r1  rj   N)
r  rj   r2  r3  posr   r   	moveEventr  r  r-  s     r_   r8  zMainWindow.moveEvent  s    4## 	2(@$$&&288::2 (,xxzz$dE***E"""""ra   c                    	 | j         | j        z   D ]}	 |                                                    | j                  r|                    d           E# t          $ r2 |                    | j                  r|                    d           Y w xY wt          j	        | |           dS # t          $ r t          j	        | |           Y dS w xY w)r1  TN)r   r   
get_widgetisAncestorOfr   change_visibilityr`  _visibility_changedr   	hideEventRuntimeError)r   r.  r   s      r_   r>  zMainWindow.hideEvent  s    	/?T-DD 
9 
99((**77 46 6 700666% 9 9 9**4+CDD 92248889
 !$..... 	/ 	/ 	/!$......	/s5   B, AAB, 9BB, BB, ,CCc                     	 |                      t          j        d          }|r|                                 dS dS # t          $ r Y dS w xY w)z1Update source menu options that vary dynamically.Fr]  N)r   rE   r  refresh_formatter_namer`  )r   r  s     r_   r  zMainWindow.update_source_menu  sj    	__W^5_AAF 0--/////0 0 	 	 	DD	s   7= 
A
Ac                 ,    t          j                     dS )zFree memory after event.N)gccollectr'  s    r_   r  zMainWindow.free_memory  s    

ra   c                 V    |                                   |                                  dS )z,Focus has changed from one plugin to anotherN)r  r  r'  s    r_   r  zMainWindow.plugin_focus_changed  s,    !!!!!ra   c                    |                                 }|D ]q}t          |dd          r"|j        |                    |j                   5|                                (|                     |                                           qrdS )zShow action shortcuts in menu._shown_shortcutFN)actionsr+  rG  rb  menushow_shortcutsr   rI  menu_actionsr7  s       r_   rJ  zMainWindow.show_shortcuts  s    ||~~" 
	 
	Fv0%88 	)5&&v'=>>>*##FKKMM2222 
	 
	ra   c                 $   |                                 }|D ]x}t          |dd          r)|j        !|                    t	                                 <|                                (|                     |                                           xydS )zHide action shortcuts in menu.rG  FN)rH  r+  rG  rb  r   rI  hide_shortcutsrK  s       r_   rN  zMainWindow.hide_shortcuts  s    ||~~" 
	 
	Fv0%88 	)5&&|~~666*##FKKMM2222 
	 
	ra   c                 ,   | j         | j        z   D ]}|j        dk    r3| j                                        }|j                                         @	 |j                                         [# t          $ r |j	                                         Y w xY wdS )z3Hide options menu when menubar is pressed in macOS.r  N)
r   r   r-  r  get_current_editorstackrI  r  options_menur`  _options_menu)r   r   editorstacks      r_   hide_options_menuszMainWindow.hide_options_menus  s    o(?? 
	0 
	0F"h.."kAACC %%''''0',,....% 0 0 0(--/////0
	0 
	0s   A++#BBc                     ddl m} ddlm} t	          j                    }d}t          |||f          r/t          ||          }|                                 }|o| }|||f}||fS )zGet 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.plugins.editor.widgets.baserW  %spyder.plugins.ipythonconsole.widgetsrY  r   focusWidgetr   
isReadOnly)r   rW  rY  widgettextedit_propertiesrb   not_readonlyreadwrite_editors           r_   get_focus_widget_propertiesz&MainWindow.get_focus_widget_properties  s     	JIIIIIGGGGGG)++"f1=ABB 	L 77G%00222L+;G#*L:J"K***ra   c                    |                                  \  }}|dS |\  }}}t          | d          r&|s$|r"| j        r| j                                        sdS | j                                        D ]}|                    d           | j                            d           | j                            |o%|	                                
                                           | j                            |o%|	                                                                           |                                }| j                            |           | j                            |o|           | j                            |           |sG|rG|                     t$          j        d          r(| j        j        D ]}|                    d           dS dS dS dS )zUpdate edit menuNr  FTr]  )rb  r  r  is_file_openedr   rH  
setEnabledr   r   documentisUndoAvailabler   isRedoAvailablehas_selected_textr   r   r   r   rE   r  r   )	r   r^  r_  rb   r`  ra  r  has_selectionr7  s	            r_   r  zMainWindow.update_edit_menu  s"   &*&F&F&H&H##&F 3F//4"" 	    K6688 ^++-- 	$ 	$EU####((... 	##$4 %L(.(9(9(I(I(K(K	M 	M 	M##$4 %L(.(9(9(I(I(K(K	M 	M 	M 0022##M222""=#A\BBB$$\222  	,< 	,w~U;; ,"k; , ,F%%d++++		, 	, 	, 	,, ,, ,ra   c                    | j                                         dd         D ]}|                    d           |                                 \  }}|dS |\  }}}|sB| j                                         D ](}	 |                    d           # t          $ r Y %w xY wt          | j                  dk    r"| j        d                             |           dS dS )zUpdate search menuNFT   )r   rH  re  rb  r?  lenr   )r   r  r^  r_  rb   r`  ra  r7  s           r_   r  zMainWindow.update_search_menu;  s    %--//4 	$ 	$EU####&*&F&F&H&H##&F 3F//  	*2244  %%d++++#   D t'((1,,$Q'223CDDDDD -,s   9B
BBc                 p   | j         dS |rt                              |           | j                                          | j                             |t          t          j        t          j        z  t          j	        z            t          t          j                             t          j                     dS )zSet splash messageN)r   r   r   r   r   intr   AlignBottomAlignCenterAlignAbsoluter   whiter   r  )r   r   s     r_   r  zMainWindow.set_splashV  s    ;F 	!KK    #BNR^$C$&$4%5 !6 !6 &rx 0 0	2 	2 	2 	"$$$$$ra   c                     |Qt          j                    >t          j                                                     t          j                    | _        n	||| _        || _        dS )z+To keep track of to the last focused widgetN)r   activeWindowsetFocusr\  r   r   )r   oldnows      r_   change_last_focused_widgetz%MainWindow.change_last_focused_widgetc  s_    KL577C%''00222'3'?'A'AD$$_'*D$(+$$$ra   c                    | j         s| j        rdS | j                                         t          | _        |rS|                     d          r>t          j        | ddt          j	        t          j
                  }|t          j
        k    rdS | j                            t          j        h|          }|s|sdS d}| j        | j                            |           	 | j                                        }|r(|                                 |                                 | j                                         | j                            t          j        d	           n# t&          $ r Y nw xY wd| _         |                     d
          r | j        r| j                                         t+          j                     dS )z
Exit tasksTprompt_on_exitrq   zDo you really want to exit?F)	excludingclose_immediatelyzwindow/N)teardownr  )r   r   rj   save_visible_pluginsr%   plugin_registryr   r   criticalYesNodelete_all_pluginsrE   r   save_current_window_settingsget_containerr  deleteLaterdelete_pluginr?  r   r   r  )r   
cancelabler~  reply	can_closeprefixlayouts_containers          r_   r*  zMainWindow.closingm  s    	$"5 	4))+++. 	$--(899 	(x)F)4+.J JE &&u(;;~&/ < 1 1	  	!2 	5
  <#L55f===	$(L$>$>$@$@!$ 4%++---%11333((***$22NU 3 4 4 4 4    #==*++ 	+0F 	+"((***"$$$ts   BE 
E,+E,c                 n   	 |j         rJ|                    |           \  }}|                     ||           | j                            |           dS dS # t
          $ rU |j        rJ|                                \  }}|                     ||           | j                            |           Y dS Y dS w xY w)z>
        Add a plugin QDockWidget to the main window.
        N)r  create_dockwidgetaddDockWidgetr   r   r`  _is_compatible_create_dockwidget)r   r   rY  locations       r_   r&  zMainWindow.add_dockwidget  s    	/# /'-'?'?'E'E$
H""8Z888&&v...../ /  	/ 	/ 	/$ /'-'@'@'B'B$
H""8Z888&&v....../ / /	/s   AA AB43B4c                    t          j                    }|                                 }t          |                                t
                    }ddlm} ddlm	} t          |||f          r t          ||                       dS dS )zGlobal callbackr   rV  rX  N)r   r\  senderr   r  r6   rZ  rW  r[  rY  r   r+  )r   r^  r7  callbackrW  rY  s         r_   r  zMainWindow.global_callback  s    )++ ??IIIIIIGGGGGGf1=ABB 	%GFH%%'''''Fra   c                     |                      t          j        d          }|r.|r|                                 d S |                                 d S d S )NFr]  )r   rE   r   redirect_stdsrestore_stds)r   staterb   s      r_   r  z'MainWindow.redirect_internalshell_stdio  sc    //'//?? 	' '%%'''''$$&&&&&		' 	'ra   c
           
         |r	 |                      dd          rt                      }
n|                      dd          }
|                      ddd          }t          j        |||||||
|           dS # t          $ rA t          j        | t          d	          t          d
          t          j	        z             Y dS w xY wdS )zOpen external consolerp   main_interpreterrk  
executablespyder_pythonpathNpythonpath_manager)rp   rc  RunzDRunning an external system terminal is not supported on platform %s.)
r   r<   r8   run_python_script_in_terminalNotImplementedErrorr   r  r'   rz   r{   )r   fnamewdirargsinteractdebugpythonpython_argssystermpost_mortemr  pypaths               r_   open_external_consolez MainWindow.open_external_console  s     	44==4F=GG !6!8!8JJ!%$ 2 "/ " "J ':D/C ' E E64x     ' 4 4 4$T1U88%& (J &) &)+-7&34 4 4 4 4 44!	4 	4s   A0A6 6AC Cc                    t          |          }t          j        |          d         }|                     t          j        d          }|                     t          j        d          }t          j        |          r|r|	                    |           dS dS |2|t          v r)|                                                    |           dS |s t          |          }t          |           dS 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)
        r  Fr]  N)r6   ospsplitextr   rE   r  r   r7   is_text_fileloadr3   r:  import_datar@   rB   )r   r  r5  extr  re   s         r_   	open_filezMainWindow.open_file  s    u%%l5!!!$u==??$E + 3 3  '' 	 #E"""""# #)cZ.?.?''))55e<<<<< 	UOOEu	 	ra   c                     | j         S )z%Return the initial working directory.)INITIAL_CWDr'  s    r_   get_initial_working_directoryz(MainWindow.get_initial_working_directory  s    ra   c           	      b   t          j        |          }|                                 }t          j        t          j        ||                    rt          j        ||          }nt          j        |          r|}ndS t          j        dk    rd|v rdS t          j        |          r| 	                    |d           dS t          j
        |          rYt          j        | t          d          t          d                              t          j        |          |                     dS dS )	z~
        Open external files that can be handled either by the Editor or the
        variable explorer inside Spyder.
        Ndarwinz
bin/spyderTrt  ErrorzcTo open <code>{fpath}</code> as a project with Spyder, please use <code>spyder -p "{fname}"</code>.)fpathr  )r7   to_unicode_from_fsr  r  existsr  rX   platformisfiler  isdirr   r   r'   r   normpath)r   r  initial_cwdr  s       r_   r  zMainWindow.open_external_file  s6    +E2288:::ch{E2233 	H[%00EEZ 	EEF <8##(=(=F:e 	NN54N00000Yu 	ajj A B Bcl511??	    	 	ra   c                 h    |                      t          j                  }|                                S )z
        This is here to provide compatibility for plugins that make use of the
        Pythonpath managed by Spyder.

        Notes
        -----
        This  method is going to be removed in Spyder 6.
        )r   rE   r  get_spyder_pythonpath)r   r  s     r_   r  z MainWindow.get_spyder_pythonpath  s*     oog788((***ra   c                    t          j                    }t                      r3dt          j                    v r	 |                    d           n#  Y nxY w| j        }|                     d          r|t          j	        z  }| 
                    |           |                                  |                     d          r*|                    |                     d                     dS |                    | j                   dS )zApply main window settings.zGTK+zgtk+vertical_tabsuse_custom_cursor_blinkingcustom_cursor_blinkingN)r   ru   r4   r   r  r  DOCKOPTIONSr   r   VerticalTabssetDockOptionsapply_panes_settingssetCursorFlashTimer   )r   r   rp   s      r_   r   zMainWindow.apply_settings"  s   $&&  	=+=+?+?!?!?f%%%%"==)) 	7k66GG$$$!!###==566 	@##6779 9 9 9 9 ##D$>?????s   A Ac                 B   | j         | j        z   D ]}|j        j        }|j                            |           	 d}|                     d          r|                     d          }|                    |           k# t          $ r |                                 Y w xY wdS )z%Update dockwidgets features settings.r   r   r  N)	r   r   rY  FEATURESsetFeaturesr   r'  r`  _update_margins)r   r   featuresr6  s       r_   r  zMainWindow.apply_panes_settings;  s    )@@ 	) 	)F(1H))(333)==!455 <!]]?;;F%%f----! ) ) )&&((((()	) 	)s   AA;;BBc                 D    | j                             | j                   dS )zEdit Spyder preferences.N)r  open_dialogr   r'  s    r_   show_preferenceszMainWindow.show_preferencesL  s$     	$$T%;<<<<<ra   c                     || _         dS )zSave preferences dialog size.N)r   )r   r4  s     r_   set_prefs_sizezMainWindow.set_prefs_sizeQ  s    !%ra   c                    | j                             t          j        t          j        d           t          t                    }|                     d|           	 | j                             d|f           n# t          $ r d | _         Y d S w xY w| j         
                    d           	 	 | j                                         \  }}n# t          j        $ r}t          j        dk    rt          j        nt          j        }|j        d         |k    rY d }~lt          j        dk    rt          j        nt          j        }|j        d         t          j        |fv rY d }~d S | j        rY d }~d S  d }~ww xY w|                    d          }|                    d	          }| j                            |           |                    d
           %)Nr  )default_portopen_files_portz	127.0.0.1   rJ   r   i   zutf-8    )r   
setsockoptr   
SOL_SOCKETSO_REUSEADDRr:   r1   r   bindr   listenr+  r   rz   r{   errnoWSAEINTREINTRr  WSAENOTSOCKENOTSOCKECONNABORTEDr   recvdecoder  r  sendall)r   portreqdummyeeintrenotsockr  s           r_   r  z"MainWindow.start_open_files_serverW  s   ))&*;*0*=q	B 	B 	B888'...
	"''d(;<<<< 	 	 	%)D"FF	
 	%%b)))	!3::<<
UU<    +-'T//u{6!9%%HHHH13DE--!& 6!9!3X >>>FFFFF& FFFFF HHTNNELL))E',,U333KK+	s=   A: :BB.C E49E/AE/!E/.E//E4c                 >    | j                             ||           dS )z4Wrapper to handle plugins request to restart Spyder.)resetr~  N)r%  r  )r   r  r~  s      r_   r  zMainWindow.restart  s2      +< 	! 	> 	> 	> 	> 	>ra   c                    | j         M| j                                         r4| j                                          | j                                          dS |r| j                             d           n3| j                             d           | j                                          | j                                          | j        j        	                                
                                |                                 	                                
                                z   dz   }| j                             |           dS )zOpen switcher dialog box.N@rn      )r   r   clearr  set_search_textr  r   r  toolbars_menugeometryheightr  set_position)r   symbol	delta_tops      r_   r  zMainWindow.open_switcher  s   =$)@)@)B)B$M!!!M   F 	"M))#....M))"---M!!! \/88::AACC\\^^,,..55778:;<	 	""9-----ra   c                 2    |                      d           dS )z'Open symbol list management dialog box.T)r  N)r  r'  s    r_   r  zMainWindow.open_symbolfinder  s    $'''''ra   c                 J    | j         ddlm}  ||           | _         | j         S )z Create switcher dialog instance.Nr   )r  )r   spyder.widgets.switcherr  )r   r  s     r_   r  zMainWindow.create_switcher  s3    = 888888$HTNNDM}ra   c                     |dk    rt          j        t          j                  S |dk    rt          j        t          j                  S |dk    rt          j        t          j                  S dS )z,Get the current OpenGL implementation in usesoftwaredesktopglesN)r   testAttributer   AA_UseSoftwareOpenGLAA_UseDesktopOpenGLAA_UseOpenGLES)r   options     r_   _test_setting_openglzMainWindow._test_setting_opengl  sg    Z#1"2IJJJy  #1"2HIIIv#1"2CDDD ra   )NN)T)FFrs   )TN)F)Vr  
__module____qualname____doc__r-  r   AllowTabbedDocksAllowNestedDocksAnimatedDocksr  DEFAULT_LAYOUTSr;   r  r
   r  r	  r  r~   r  r!  r  r  sig_layout_setup_readyr  r#  rt   r   r   r   r   r   r   r;  rI  rO  r  r  rD  r  rd  r  r  r  r  r  r  r  r  rA  r(  r/  r5  r8  r>  r  r  r  rJ  rN  rT  rb  r  r  r  rz  r*  r&  r  r  r  r  r  r  r  r   r  r   r  r  r  r  r  r  r  r  __classcell__)r  s   @r_   rN   rN   ~   s       L 	${'CC!	"  O .""K "( &((#VC[[&((K|$$I#VF^^ $VFF33%vf~~x5 x5 x5 x5x
 
 
 
     > > >@ @ @5 5 5
 
 
]@ ]@ ]@ ]@~2 2 2h  
G 
G 
G 
G1 1 1 1   1  1  1H$- $- $- $-LN( N( N(`) ) ) ) )&0$ 0$ 0$dA' A' A'F@ @ @*, , ,- - -D AE
 
 
 
 CG
 
 
 
J J J  % % %
# 
# 
#/ / /*	 	 	  " " "
    0 0 0+ + + &, &, &,PE E E6% % %, , ,/ / / /b/ / /"  ' ' ' AF4 4 4 42   *       <
+ 
+ 
+@ @ @2) ) )" 
TVV= = V=& & &' ' 'V> > > >. . . ..( ( (  E E E E E E Era   rN   c                    t                      ret          j        dd          dk    r$t          j        dd          }t          |           t	                      }t          t          |d| d          }|S | j        rt          d           t          Et          | j
         p/| j        p(| j        p!| j        pt          t                                           | j        r| j        }t          |           n=t          j        dd          dk    r$t          j        dd          }t          |           t#          t$          d          r2t'          j        t$          j        t          j        dd                     t                      dk    rt-                       t/          |            t	                      }t1                      }||                                 |                    t7          d	          t9          t$          j        t$          j        z  t$          j        z            tA          t$          j!                             tE          j#                     | j        rt          j                     dS | j        r*ddl$}tK          j&        d
|j'        d         gdg           dS tQ          d          }d}tS          j*        |          rrtW          |d          5 }	|	,                                }ddd           n# 1 swxY w Y   	 tQ          d          }
t[          j.        ||
           n# t^          $ r Y nw xY wt          j0        dd|           tc          |           d}	 | j2        r[ddl3}tW          |d          5 }	|4                    |	           t          t          ||| |          }ddd           n# 1 swxY w Y   nt          t          ||| |          }n<# tj          $ r/ tm          j7        ddd           t          j0        ddd           Y nw xY w|||8                                 dS ts                       dS )zMain functionrO   openglro  Nz(Deprecated) --show console does nothing, now the default  behavior is to show the console, use --hide-console if you want to hide itAA_EnableHighDpiScalinghigh_dpi_scalingr   zInitializing...
compileallz-O)r  r  p_argszfaulthandler.logrn   rzfaulthandler.log.oldprevious_crashwru  rq   zSpyder 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.rj  
icon_themezspyder 2):r.   r2   r   r$   r   r   rN   show_consoler  rK   hide_consolereset_config_filesreset_to_defaultsoptimizeboolr*   opengl_implementationr  r   r   rx   r  r    r#   r   r   r   r'   rp  rq  rr  rs  r   rt  r   r  spyderr8   run_python_script__path__r)   r  r  openreadshutilmoverC  setr"   report_segfaultfaulthandlerrs  r   r   informationr  r   )r   r  r  r   windowr   r'  faulthandler_filer  fdst
mainwindowr0  s                r_   rO   rO     s     8FH%%44Xfh//F%f--- ""z3gtDD  !   	! 	! 	! $/$)=%= &@(/(B&@(/(A&@ )0(8&@ )-_->->(?(?		A 	A 	A $ ..!&))))8FH%%44Xfh//F%f--- r,-- L%b&@&*hv7I&J&J	L 	L 	L 1   ' 

C "##F  /"2BBCC28	
 	
 	

 	"$$$  	   		 ",)/);(<dV	M 	M 	M 	M &&899N
z#$$ 	#S)) 	&QVVXXN	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&	 677CK)3//// 	 	 	D	HV%~666 C J9" 	O'-- ###+++*VWd 
               'z3NNJ 9 9 9(I	
 	
 	
 	|Z888889 KKMMMsZ   K;;K?K?$L, ,
L98L9$O ?/N:.O :N>>O N>O 6PP__main__)~r  collectionsr   configparserr.  enumr   r  rC  loggingrz   os.pathr  r  r,  r   r   rX   r  r  r'  r   check_qtqtpy.compatr   qtpy.QtCorer   r   r	   r
   r   r   
qtpy.QtGuir   r   qtpy.QtWidgetsr   r   r   r   r   r   qtpyr   r   qtawesome.iconic_fontr   r   r   spyder.app.find_pluginsr   r   spyder.app.utilsr   r   r   r   r    r!   r"   r#   r$   'spyder.api.plugin_registration.registryr%   spyder.api.config.mixinsr&   spyder.config.baser'   r(   r)   r*   r+   r,   r-   r.   r/   spyder.config.guir0   spyder.config.mainr1   spyder.config.managerr2   spyder.config.utilsr3   r4   spyder.otherpluginsr5   spyder.py3compatr6   spyder.utilsr7   r8   spyder.utils.icon_managerr9   spyder.utils.miscr:   r;   r<   spyder.utils.paletter=   rw   r>   r?   r@   rA   rB   spyder.utils.stylesheetrC   spyder.api.exceptionsrD   spyder.api.pluginsrE   rF   rG   rH   rI   rK   is_attached_console_visiblerL   r{   spyder.utils.windows	getLoggerr  r   rN   rO    ra   r_   <module>rZ     s  
 
 $ # # # # #            				  				          



        
            
 & % % % % %1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 + + + + + + + +6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6       $ # # # # # + + + + + +            2 2 2 2 2 2 2 2                      D C C C C C @ @ @ @ @ @> > > > > > > > > > > > > > > > > > > > > > 1 0 0 0 0 0 . . . . . . & & & & & & : : : : : : : : 6 6 6 6 6 6 + + + + + + + + + + + + + + ) ) ) ) ) )6 6 6 6 6 6 6 6 6 6 . . . . . .> > > > > > > > > > > > > > 2 2 2 2 2 2 1 0 0 0 0 0               $ " ! 7d??B B B B B B B B 
	8	$	$
  ) * * *vE vE vE vE vE9 vE vE vEx1u u up zDFFFFF ra   