
    Je                    V   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lBmCZC ddlDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZM ddlNmOZO ddlPmQZQ ddlRmSZS ddlTmUZUmVZV ddlWmXZX ddlYmZZZ ddl[m\Z\m]Z] ddl^m_Z_ ddl`maZambZbmcZc ddldmeZe ddlfmgZgmhZhmiZimjZjmkZk dd llmmZm dd!lnmoZo dd"lpmqZqmrZrmsZsmtZtmuZu dZvdZwdZxe
j                  d#k(  rdd$lzmvZvmxZx  e	j                  e|      Z} ee:        G d% d&e%eCeA      Z~d' Ze|d(k(  r e        yy))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)SpyderMainWindowMixin)	_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	 dAdZdBdZd Zd	 Zd
 Zd Zd ZdCdZ d Z!d Z"dDdZ#dDdZ$d Z%d Z&dBdZ'd Z( fdZ)d Z*d Z+d Z,d Z-d Z.	 dEdZ/	 dEdZ0d Z1d Z2d  Z3d! Z4d" Z5d# Z6d$ Z7d% Z8d& Z9d' Z:d( Z;d) Z<d* Z=d+ Z>d, Z?d- Z@dCd.ZAd/ ZBd0 ZCd1 ZD	 dFd2ZEdFd3ZFd4 ZGd5 ZHd6 ZId7 ZJd8 ZK eL       d9        ZMd: ZNd; ZOdCd<ZPdFd=ZQd> ZRd? ZSd@ ZT xZUS )G
MainWindowzSpyder main windowmain   QResizeEvent
QMoveEventc           
      
   t        j                  |        t        j                         }t	               rd | _        nddlm}  |d       | _        |j                  t        j                         t        j                  dk(  r&|j                  t        j                  dd             t!        |j#                         j%                               | _        || _        t*        j-                  d       dd}t        j                  dk(  r	 dd l}|j1                  |d       nNt5        j4                  t4        j6                  |       t8        s$t5        j4                  t4        j:                  |       g | _        g | _        tA               | _!        tA               | _"        tF        jH                  tF        jJ                  tF        jL                  tF        jN                  tF        jP                  tF        jR                  tF        jT                  tF        jV                  tF        jX                  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| j                  d
d       t        j                         | _K        t         t               }t*        j-                  d|       t        j                  j                  d      }|ft               }	d}
t        |       | _Q        | j                  j                  j                  |	j                         | j                  j                  |
       || _V        | j                  dd      t        k7  r| j                  dt               g | _Y        d| _Z        d| _[        d| _\        d | _]        d | _^        d | __        d | _`        t        j                  dk(  rH	 t        j                  t        j                  t        j                  t        j                        | _e        nFt        j                  t        j                  t        j                  t        j                        | _e        | j                          t*        j-                  d       y # t2        $ r Y w xY w# t        $ rH d | _e        t        j                  d dt        d      j                  t        j                               Y w xY w)Nr   )SpyderProxyStylerK   windows_app_iconT)resamplezStart of MainWindow constructorc                     t         j                  j                  d| z         t         j                  j                          t	        j
                          y)zHandler for signals.zHandling signal: %s
N)sysstdoutwriteflushr   quit)signumframes     7/usr/lib/python3/dist-packages/spyder/app/mainwindow.pysignal_handlerz+MainWindow.__init__.<locals>.signal_handler   s6    JJ4v=>JJ    )	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.qthelpersrU   setAttributer   AA_UseHighDpiPixmapsosnamesetWindowIconr:   get_iconstrstyle
objectNamedefault_style_cli_optionsloggerinfowin32apiSetConsoleCtrlHandlerImportErrorsignalSIGTERMr)   SIGINTshortcut_datashortcut_queuer   _APPLICATION_TOOLBARS_STATUS_WIDGETSrF   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_OSDEFAULTrM   environgetrB   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qapprU   ra   r   restest_appapptimer_shutdown_times              r`   ru   zMainWindow.__init__   sm   T"$$&! $D? 0 6D 	"112 77d? s||,>NO !!8!8!:; $56	  77d?..~tD MM&...9 fmm^<    &1]"*}
 &66&66 ' 8 8!00 ' 8 8(("<<~~
*
& #%  "&%)"    $ !##% #%  ""$ !$&!#% !%'"
!MM0%8%1%A%A%C"%1,.CKK,c2 ::>>-0.C"'"(,D''//9%%&9: ==*B=7;FMM+[9  $"!# $( '+$
 77d?)/v~~7=7I7I7=7I7I*K&" &,]]6>>393E3E393E3E&GD"
 	 	34e  r  )-&## ( )
 *0 - @ @ *0 *B
s&   S< 	AT <	T	T	AUUc                 `    |t         v rt        j                  |      S |rt        d| d      y)zI
        Return a plugin instance by providing the plugin class.
        zPlugin "z" not found!N)r%   
get_pluginrE   )r   plugin_nameerrors      r`   r   zMainWindow.get_plugina  s7     /)"--k:: 8K=!EFFrb   c                     g }t         D ]A  }t        j                  |      }t        |t        t        f      s/|j                  ||f       C |S )z#Get a list of all dockable plugins.)r%   r   
isinstancerI   rJ   append)r   dockable_pluginsr   plugins       r`   get_dockable_pluginszMainWindow.get_dockable_pluginsm  sS    * 	?K$//<F&#79K"LM ''f(=>	?  rb   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_enabledv  s    00==rb   c                 ,    t        j                  |      S )z)Determine if a given plugin is available.)r%   is_plugin_availabler   s     r`   r   zMainWindow.is_plugin_availablez  s    22;??rb   c                 j    | j                         }|j                         r|j                  ||       yy)z>
        Show a status message in Spyder Main Window.
        N)	statusBar	isVisibleshowMessage)r   messager   
status_bars       r`   show_status_messagezMainWindow.show_status_message~  s1     ^^%
!""7G4 "rb   c                 t   t        |       }|j                  t        j                         |j	                  t        j
                         |j                  t        d             |j                  t        d      j                  ||             |j                  t         j                         |j                          t        j                         j                         }|j!                         |j!                         z
  dz  }|j#                         |j#                         z
  dz  }|j%                  ||       y)z/
        Show a compatibility message.
        zPlugin compatibility checkzEIt was not possible to load the {} plugin. The problem was:<br><br>{}   N)r   setWindowModalityr   NonModalry   WA_DeleteOnClosesetWindowTitler(   setTextr   setStandardButtonsOkshowr   desktopscreenGeometrywidthheightmove)r   r   r   
messageBoxscreen_geometryxys          r`   !show_plugin_compatibility_messagez,MainWindow.show_plugin_compatibility_message  s     !&
 	$$R[[1 3 34!!!$@"AB    &{G <	
 	%%knn5
 	 '..0??A""$z'7'7'99Q>##%
(9(9(;;q@1rb   c                 6    t        j                  |       j                  t        d      j	                  j                                      t        j                  dj	                  j                               j                         \  }}|_
        j                          |s! j                  j                         |       yj                  j                   j                         j                   j                   j"                         j$                  j                   j&                         j(                  j                   j*                         j,                  j                   j.                         j0                  j                   j2                         j4                  j                   j6                         j4                  t8           j                   j6                         t;        t<              rij>                  j                   j@                         jB                  j                   jD                         jF                  j                   fd        jH                  j                  jJ                          jL                  j                  jN                          jP                  j                  jR                         jU                  |       t;        t<              rF jW                         d} jY                  d      r jY                  d      }j[                  |       |t\        j^                  k(  r/ j`                  D ]  \  }}}	 jc                  |||	        g  _0        t        j                  dj	                  j                               je                         jg                         D ]  \  }	}ti        |d	j                        xs j                  }ti        |d
d      s9t;        |	tj              r|	jl                  }	t\        j^                  t         v r jc                  |||	        j`                  jo                  |||	f        t;        t<              r	 d}dj	                  jp                        }
ty        t{                 fd      }|j}                  t~        j                         |_A        t\        j^                  t         v r1 jc                  |
        jc                  j                  ||
       y j`                  jo                  |
f        j`                  jo                  j                  ||
f       yy# tr        jt                  tr        jv                  f$ r Y w xY w)z:
        Register a plugin in Spyder Main Window.
        zLoading {}...Nc                  &     j                        S rt   )set_ancestorr   r   s   r`   <lambda>z,MainWindow.register_plugin.<locals>.<lambda>  s    ++D1 rb   	omit_confr   use_custom_margincustom_marginzRegistering shortcuts for {}...shortcut_contextregister_shortcutTr(   switch to {}c                  &    j                         S rt   )switch_to_pluginr  s   r`   r  z,MainWindow.register_plugin.<locals>.<lambda>  s    4#8#8#@ rb   )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   rI   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_marginsrF   	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/*11&//2CDEO**6;;78 "(!;!;!=w, 226??3DgN 	%%--d.C.CD((001A1AB!!))$**5$$,,T\\:++33--	/++33D4L4LM..66t7M7MN..v6>>""	$ f23$$,,T-F-FG1199%%'008813 	v::;  !>!>?%%--//	1 	9-f23' F}}017!!&)'+++040C0C E,&&vwDE"$D5<<V[[IJ#)#5#5#7#=#=#? 
	OKv'96;;G & ++  v2D9k40"-"3"3K$$7**67KH''../MN
	O f23%,,V-@-@A <>4@BBMM"001!F  O3&&r7D9&&--w> ##**B+>?##**..>@% 4 %%r'7'78 s   U2 2#VVc                    t         j                  dj                  |j                               |j                  |j
                  |j                  g}|D ]  }	 |j                           t         j                  dj                  |j                               |j                         j                         D ]G  \  }}t        |d|j                        xs |j                  }| j                  j                  |||       I d}	 d}dj                  |j                        }| j                  |||j                        }|@| j                  j                  |j"                  dj                  |j                               t         j                  d	j                  |j                               | j%                  |       |j'                          y# t        $ r Y w xY w# t         $ r Y w xY w)
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	TypeErrorr3  r4  r5  	shortcutsunregister_shortcutr7  get_shortcut	Exceptionr=  remove_dockwidget_unregister)	r   r   signalssigrC  rA  rB  shortcutr|   s	            r`   unregister_pluginzMainWindow.unregister_plugin   s    	%,,V[[9: %%////
  	C 	 	7>>v{{KL#)#5#5#7#=#=#? 	MKv'96;;G & ++ NN..vwL	M 		G!(()<)<=D(("// ) H NN..  %%f&9&9: 	/66v{{CDv&E  (  		s$   G;G  	GG 	G,+G,c                     | j                   }|j                  '|$|j                  ||      }|j                          |S yy)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_widget4  sM     22##/M4M 226=IK""$ 5N/rb   c                 >    | j                   j                  ||       y)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)rk   r  )r   r   r[  s      r`   r  zMainWindow.switch_to_plugin>  s     	%%f+%Frb   c                 v    || j                   j                          y| j                   j                  |       y)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)rk   unmaximize_dockwidgetunmaximize_other_dockwidget)r   not_this_plugins     r`   r#  zMainWindow.unmaximize_pluginJ  s4     "LL..0LL44 / 5 1rb   c                     | j                  |j                         	 | j                  j                  |       y# t        $ r Y yw xY w)zC
        Remove a plugin QDockWidget from the main window.
        N)removeDockWidget
dockwidgetr   remove
ValueError)r   r   s     r`   rN  zMainWindow.remove_dockwidgetY  sA     	f//0	OO""6* 		s   9 	AAc                 n    | j                  t        j                  d      }|r|j                  |       yy)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   rF   r   r  )r   
error_datarc   s      r`   r  zMainWindow.handle_exceptionc  s0    < //'///?$$Z0 rb   c                    t         D ]  }t        j                  |      }t        |t              s)	 |j                  }|r5|j                  }	 d}dj                  |      }| j                  |||      }n
t               }|j                  |        y# t
        $ r |j                  }Y lw xY w# t        j                  t        j                  f$ r t               }Y ^w xY w)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  rG  N)r%   r   r   rI   r>  AttributeError_toggle_view_actionr7  r   rL  r8  r9  r:  r   setShortcut)	r   r   r   r   rA  sectionrB  r|   rR  s	            r`   _update_shortcuts_in_panes_menuz*MainWindow._update_shortcuts_in_panes_menu  s     + 	-K$//<F&"678#66F
 $11G2"%-44W=#'#4#4 'w $5 $@
  ,~H""8,-	- & 8#77F8 --r/?/?@ 2#/>2s#   B'B-B*)B*--CCc           
          t         j                  j                   fd       t        j                          ddlm}m} t        j                  d       t        j                  d        j                  dd      } j                  d	d      }|d
k(  r|t               s/t        j                         }|j                   j                         t        t               } j#                  |        j%                         j#                  |       |}nL|dk(  r{t               s/t        j                         }|j                   j                         t        t               } j#                  |        j%                         j#                  |       |}n|dk(  rt'        |      s{t               s/t        j                         }|j                   j                         t        t               } j#                  |        j%                         j#                  |       |}nAt        t               } j#                  |        j%                         j#                  |       |} j)                  dd        j%                         }	|	j+                  d       |	j-                  t/        d      d       t        j                  d        j1                          t3               }
t5               }|
j7                         }|j9                  |j7                                i }i }i }|j;                         D ]  }|j<                  } j>                  j@                  rd|v r*| jB                  v r jB                  |   n|}||v r||f||<   n||f||<   	  j                  d|      r|||<   t        jD                  |        t        jL                  |       t        jN                  |       |D ]5  }||v s||   }tQ        |tR              st        jT                   |d       7  jW                  tX        jZ                        }|j\                  j                   j\                         |D ]P  }||v s||   }tQ        |t^              st        jT                   |d      } j`                  jc                  |       R |
D ]%  }||v s|
|   }	 t        jT                   |d      }'  jo                  t/        d             tq               D ]  }	 t        jT                   |d      }|js                         d   rtu        |d      r j`                  jc                  |       tu        |d      s jv                  jy                  |       |jz                  }|j}                  dd      }|j~                  r|j~                  }n|j                         }t        j                  |||ddt        j                            j                          t        j                  d!       dd"lFmG}mH}  j                  }|j                  d#       _K        |j                  d$       _L        |j                  d%       _M         j                  j                  j                   j                         |j                  d&       _P        |j                  d'       _Q        t         t/        d(      t        j                  d)      t/        d*       j                  t        j                  d+,       _X         j                   j                  dd-.       t         t/        d/      t        j                  d0      t/        d1       j                  t        j                  d2,       _[         j                   j                  dd3d4        fd5} |d6t/        d6      t        j                  d7             _\         |d8t/        d8      t        j                  d9             _]         |d:t/        d:      t        j                  d;             _^         |d<t/        d<      t        j                  d=             __         |d>t/        d>      t        j                  d?             _`         |d@t/        d@      t        j                  dA             _a         xj                   j                   j                  d j                   j                   j                   j                  dgz  c_b         jW                  tX        j                  dB      r) xj                   j                  j                  z  c_b         j                   j                  g}|D ]5  } |j                  | |j                  |j                  |j                  C       7  jo                  d       t        j                  dD        j                  }!|!j                  dE       _k        |!j                  dF       _l        |!j                  dG       _m         jo                  t/        dH             t         j                   j                         t         j                   j                         t         j                   j                         t         j                   j                         t         j                   j                          j                  j                          y# tF        jH                  tF        jJ                  f$ r |||<   t        jD                  |       Y w xY w# td        $ rD}tg        |dt        |      th               tk        jl                  th               Y d}~d}~ww xY w# t        $ r Y td        $ rD}tg        |dt        |      th               tk        jl                  th               Y d}~d}~ww xY w)IzSetup main window.c                 *    j                  | |      S )Nr  )rE  )r   r	  r   s     r`   r  z"MainWindow.setup.<locals>.<lambda>  s    4+?+?y ,@ ,2 rb   r   )CSS_PATHDARK_CSS_PATHz!*** Start of MainWindow setup ***zApplying theme configuration...ui_theme
appearancerm  selecteddarklight	automaticcss_path	StatusBarzWelcome to Spyder!i  zLoading switcher...helpenableFr?  Tz: fileNz"Loading old third-party plugins...CONFIGWIDGET_CLASSCOMPLETION_PROVIDER_NAMEr(   -ro   )kindzCreating Menus...)ApplicationMenusFileMenuSectionsr   r   r   r   r   zFile switcher...filelistzFast switch between filesfile_switcher)icontip	triggeredrB  id_zFile switcher)rB  r|   zSymbol finder...symbol_findzFast symbol search in filesymbol_finderzsymbol finder)rB  r|   add_shortcut_to_tipc                     | j                  d      }|d   j                         dj                  |dd        z   }t        ||j                  |t
        j                        }j                  |d|        |S )N r   ro      )r  r  datarB  Editor)splitlowerjoinr?   global_callbackr   WidgetShortcutr  )texttr_textr  textseqmethod_namerA  r   s         r`   create_edit_actionz,MainWindow.setup.<locals>.create_edit_actionz  su    jjoG!!***,rwwwqr{/CCK"4(,-1-A-A(3+-+<+<	>F
 ""68T:Mrb   UndoundoRedoredoCopyeditcopyCuteditcutPaste	editpastez
Select All	selectallrg  )menu_idrm  before_sectionzCreating toolbars...r   r   r   zSetting up main window...)ur%   sig_plugin_readyr   set_main#spyder.plugins.help.utils.sphinxifyrq  rr  r   r   r   r/   r   rv   setStylerw   r   rD   setStyleSheetr   r1   r   setObjectNamer   r(   create_switcherr   r   copyupdatevaluesr  r   no_web_widgetsr   set_plugin_enabledr8  r:  r9  set_all_internal_pluginsset_all_external_plugins
issubclassrH   rE  r   rF   PythonpathManagersig_pythonpath_changedrG   preferencesregister_plugin_preferencesrM  printr0   	traceback	print_excr  r6   r  hasattrr   r   __name__replaceDESCRIPTIONget_plugin_titler   addPLUGINrI  set_window_titlespyder.plugins.mainmenu.apir  r  mainmenuget_application_menur   r   r   aboutToShowupdate_source_menur   r   r?   r:   r  open_switcherr   r<  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   rq  rr  rs  color_schemer   dark_qssrz  	light_qssstatusexternal_pluginsinternal_pluginsall_pluginsenabled_pluginsregistry_internal_pluginsregistry_external_pluginsr   r   plugin_main_attribute_namePluginClassppmr]  r   modmoduler|   descriptionr  r  r  r  switcher_actionsswitcher_actionr  s"   `                                 r`   setupzMainWindow.setup  s'
   ((002	3 	  & 	P7856==\=B}}Z}Fv')#,,.d//0>*Hx(NN**84$H ')#,,.d//0N+Iy)NN**95H$%l3+-'002DMM$"3"34~.""8, ..x8(/	""9- ..y9# 	j(LA ![)112D9 	)* 1202&++-+0023 $&!$&!!((* 	@F ++K   //[( $"@"@@ ..{;  ' ...:8)+6 /:8)+6@==3M=N39OK0#66{C+	@4 	001JK001JK , 	DKo-.{;k>:#33D+=BD		D oog778""**4+F+FG , 	)Ko-.{;k<8&5&E&EkE';O$$@@')	) , 	5Ko-.{;5&5&E&EkD':O		5 	>?@)+ 	1C1(88sBFH--/2v';<((DDVL"6+EF//66v> !\\F!>>#s3D))&,&8&8&,&=&=&? $$VT;%'L4G4GI'	1: 	 	'(	0==!66{C#88G#88G$$,,T-D-DE 55jA"77E %2 !*%-.((**%
! 	t88#$3 	 	5$1!&'-(./,,**%
! 	t88#$3 	 	O		 .fai.1hhv.>@-fai.1hhv.>@-fai.1hhz.BD,UAeH-0XXi-@B.w'
/2xx/DF 2<34\?3688K3H!J 	4#3#3T5E5E#'$:J:J#'#4#4d6K6K#'#) 	) ??7>>?7""dkk&C&CC" %%%%
  0 	O11(--(11/77	 2 	 	 	*+,,#;;NK"::=I$<<_M567 	DNND$:$:;D$$d&>&>?D$$d&>&>?DMM4#8#89DOOT%<%<= 	  %%'[ $$b&7&78 @/5,22;?@H ! 5k3u:>VL''V4454   1#s5z2@##001sI   	-k2l6C)n2=l32l36	n?9m>>n	oo9ooc                     	 || j                   j                         v r | j                  | j                   |   d      S | j                  |      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.
        Frg  )r   keysr   rE   super__getattr__)r   attr	__class__s     r`   r  zMainWindow.__getattr__  sx    	t55::<<2248 ' G G??4(( 		w"4((s   ;A A 	AAc                 \   t         j                  d       t        D ](  }t        j                  |      }	 |j	                          * | j                  | j                  j                          | j                         j                         D ]^  }t        |t              s	 |j                  j                  | j                         |j                  j                  | j                         ` | j"                  | j"                  j%                          | j"                  -| j'                  dd      r| j"                  j	                          | j"                  | j"                  j)                          t         j                  d       d| _        y# t
        $ r Y ~w xY w# t         $ r Y w xY w)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/staterp   z*** End of MainWindow setup ***F)r   r   r%   r   before_mainwindow_visiblerj  r   hidemenuBarchildrenr   r   r  r   update_edit_menuupdate_search_menurI  rk   register_custom_layoutsr   tabify_new_pluginsr   )r   r   r]  childs       r`   pre_visible_setupzMainWindow.pre_visible_setup  sa    	*+* 	K-88EO99;	 ;;"KK \\^,,. 	E%'%%--d.C.CD%%--d.E.EF		 <<#LL002 LL$nd;LL224 <<#LL++-56#I "  ! s$   F A
F	FF	F+*F+c                 *   | j                   j                          t        j                          | j                  | j                  j                          | j                          t        D ]P  }|t        j                  k7  st        j                  |      }	 |j                          t        j                          R | j                  j                          | j                  d      r~| j                  j                   sh| j"                  r\t%        j&                  | j(                        }d|_        |j-                          | j.                  j1                  | j2                         | j5                          | j7                          | j9                         j;                          t<        (dt>        j@                  vsJ dt>        j@                  vsJ | jC                          d| _"        | jF                  j                          y# t        $ r Y w xY w)zj
        Actions to be performed only after the main window's `show` method
        is triggered.
        Nsingle_instance)targetTpandas
matplotlibF)$rk   on_mainwindow_visibler   processEventsr   r  move_to_primary_screenr%   rF   r   r   rj  restore_scrollbar_positionr  r   r   new_instancer   	threadingThreadstart_open_files_serverdaemonr   sig_open_external_filer   open_external_filern  reopen_last_sessionr  raise_r)   rY   modulesrestore_undocked_pluginsr   sig_setup_finished)r   r   r   ts       r`   post_visible_setupzMainWindow.post_visible_setup  s    	**, 	""$;;"KK 	##% + 	Kgnn,(33K@002 ..0	 	'',,. MM+,!!..""  (D(DEAAHGGI ''//0G0GH 	,,. 	  " 	 ?3;;...s{{222 	%%' #$$&W & s   $H	HHc                    | j                  t        j                  d      }| j                  t        j                  d      }d}|r|j	                         d}nd}|r+|r(t
        j                  d       |j                  d       yyy)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.
        Frg  NTz0Restoring opened files from the previous session)close_previous_files)r   rF   r   r  get_active_projectr   r   setup_open_files)r   ri   r  r  s       r`   r  zMainWindow.reopen_last_sessionI  s     ??7#3#35?Au=#**,4&*#"&)KKJK###? *6rb   c                 B   t         j                  d       t        D ]  }t        j                  |      }t	        |t
              r%|j                  dd      s<|j                          Mt	        |t              s^|j                  dd      sr|j                           y)z;Restore plugins that were undocked in the previous session.z4Restoring undocked plugins from the previous sessionundocked_on_window_closeFrp   N)r   r   r%   r   r   rI   r   r   rJ   
get_option_create_window)r   r   r   s      r`   r  z#MainWindow.restore_undocked_plugins^  s    JK* 	,K$//<F&"67??#=u?M((*F$67$$%?-2 % 4))+	,rb   c                    t         3dt        dt        j                  d   dt        j                  d   d}nBt	               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  }| j                  t        j                  d      }|r>|j                         }|r,|j                  t               d      }dj!                  ||      }|| _        | j%                  | j"                         y)zSet window title.NzSpyder z	 (Python r   .r  )rr   zSpyder (Python z [DEBUG MODE %d]z -- Frg  ~z	{0} - {1})r)   r   rY   version_infor.   r-   r+   r   window_titler7   r   rF   r   get_active_project_pathr  r,   r   
base_titler   )r   titler$  ri   paths        r`   r  zMainWindow.set_window_titlel  s   ?3>363C3CA3F363C3CA3FHE  !Z\E &2 140@0@0C030@0@0CEE (?+<<<E((55#W~l;;;E ??7#3#35?A335D||LND9$++D%8DOO,rb   c                 x    | j                  t        j                  d      }|r|j                  |||||       y y NFrg  )r  r   )r   rF   r2  r  r   qaction_or_qshortcutrB  r|   r  r   rJ  s          r`   r  zMainWindow.register_shortcut  sD    OOG$5$5UOC	''$$7' (  rb   c                 x    | j                  t        j                  d      }|r|j                  |||||       y y r*  )r   rF   r2  rK  r+  s          r`   rK  zMainWindow.unregister_shortcut  sD    OOG$5$5UOC	))$$7' *  rb   c                 :    | j                   j                  |       S )N)parent)applicationget_application_context_menur   s    r`   createPopupMenuzMainWindow.createPopupMenu  s    <<D<IIrb   c                 h    | j                  d      r|j                          y|j                          y)zcloseEvent reimplementationTN)closingacceptignorer   events     r`   
closeEventzMainWindow.closeEvent  s     <<LLNLLNrb   c                     | j                         s/| j                  j                         s| j                         | _        t        j                  | |       | j                  j                  |       y)Reimplement Qt methodN)	isMaximizedrk   get_fullscreen_flagsizer   r   resizeEventr+  r  r8  s     r`   r@  zMainWindow.resizeEvent  sQ    !$,,*J*J*L#yy{De, 	e$rb   c                    t        | d      rK| j                  ?| j                         s/| j                  j                         s| j	                         | _        t        j                  | |       | j                  j                  |       y)r<  rk   N)
r  rk   r=  r>  posr   r   	moveEventr)  r  r8  s     r`   rC  zMainWindow.moveEvent  sa    4#(@$$&88:'+xxz$dE*E"rb   c                    	 | j                   | j                  z   D ]=  }	 |j                         j                  | j                        r|j                  d       ? t        j                  | |       y# t        $ r/ |j                  | j                        r|j                  d       Y w xY w# t        $ r t        j                  | |       Y yw xY w)r<  TN)r   r   
get_widgetisAncestorOfr   change_visibilityrj  _visibility_changedr   	hideEventRuntimeError)r   r9  r   s      r`   rI  zMainWindow.hideEvent  s    	/??T-D-DD 
99((*77 446006
9 !!$. & 9**4+C+CD22489  	/!!$.	/s4   B- :A2B- 25B*'B- )B**B- -CCc                     	 | j                  t        j                  d      }|r|j                          yy# t        $ r Y yw xY w)z1Update source menu options that vary dynamically.Frg  N)r   rF   r  refresh_formatter_namerj  )r   r  s     r`   r  zMainWindow.update_source_menu  sC    	__W^^5_AF--/  		s   37 	AAc                 ,    t        j                          y)zFree memory after event.N)gccollectr2  s    r`   r  zMainWindow.free_memory  s    


rb   c                 D    | j                          | j                          y)z,Focus has changed from one plugin to anotherN)r  r  r2  s    r`   r&  zMainWindow.plugin_focus_changed  s    !rb   c                     |j                         }|D ]h  }t        |dd      r)|j                  |j                  |j                         9|j	                          | j                  |j	                                ij y)zShow action shortcuts in menu._shown_shortcutFN)actionsr5  rR  rl  menushow_shortcutsr   rT  menu_actionsrA  s       r`   rU  zMainWindow.show_shortcuts  sn    ||~" 
	Fv0%8))5&&v'='=>*##FKKM2 
	rb   c                     |j                         }|D ]f  }t        |dd      r'|j                  |j                  t	                      7|j                          | j                  |j                                gh y)zHide action shortcuts in menu.rR  FN)rS  r5  rR  rl  r   rT  hide_shortcutsrV  s       r`   rY  zMainWindow.hide_shortcuts  sj    ||~" 
	Fv0%8))5&&|~6*##FKKM2 
	rb   c                 P   | j                   | j                  z   D ]a  }|j                  dk(  r5| j                  j	                         }|j
                  j                          G	 |j                  j                          c y# t        $ r |j                  j                          Y w xY w)z3Hide options menu when menubar is pressed in macOS.r  N)
r   r   r7  r  get_current_editorstackrT  r  options_menurj  _options_menu)r   r   editorstacks      r`   hide_options_menuszMainWindow.hide_options_menus  s    oo(?(?? 
	0F""h."kkAAC  %%'0'',,.
	0 & 0((--/0s   "A??#B%$B%c                     ddl m} ddlm} t	        j
                         }d}t        |||f      r)t        ||      }|j                          }|xr | }|||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.baserb  %spyder.plugins.ipythonconsole.widgetsrd  r   focusWidgetr   
isReadOnly)r   rb  rd  widgettextedit_propertiesrc   not_readonlyreadwrite_editors           r`   get_focus_widget_propertiesz&MainWindow.get_focus_widget_properties  ss     	JG))+"f1=AB 7G%0022L+;G#*L:J"K***rb   c                    | j                         \  }}|y|\  }}}t        | d      r+|s)|r'| j                  r| j                  j                         sy| j                  j                         D ]  }|j                  d        | j                  j                  d       | j                  j                  |xr |j                         j                                | j                  j                  |xr |j                         j                                |j                         }| j                  j                  |       | j                  j                  |xr |       | j                   j                  |       |sR|rO| j#                  t$        j&                  d      r-| j                  j(                  D ]  }|j                  d        yyyy)zUpdate edit menuNr  FTrg  )rm  r  r  is_file_openedr   rS  
setEnabledr   r   documentisUndoAvailabler   isRedoAvailablehas_selected_textr   r   r   r   rF   r  r   )	r   ri  rj  rc   rk  rl  r  has_selectionrA  s	            r`   r  zMainWindow.update_edit_menu+  s   &*&F&F&H##& 3F//4" KK668 ^^++- 	$EU#	$ 	((. 	##$4 %L(.(9(I(I(K	M##$4 %L(.(9(I(I(K	M 002##M2""=#A\B$$\2 <w~~U;"kk;; ,F%%d+, < (wrb   c                    | j                   j                         dd D ]  }|j                  d        | j                         \  }}|y|\  }}}|s1| j                   j                         D ]  }	 |j                  d        t        | j                        dkD  r| j                  d   j                  |       yy# t        $ r Y Zw xY w)zUpdate search menuNFT   )r   rS  rp  rm  rJ  lenr   )r   r  ri  rj  rc   rk  rl  rA  s           r`   r  zMainWindow.update_search_menuS  s     %%--/4 	$EU#	$ '+&F&F&H##& 3F// **224 %%d+ t''(1,$$Q'223CD -	 $ s   0B;;	CCc                    | j                   y|rt        j                  |       | j                   j                          | j                   j	                  |t        t        j                  t        j                  z  t        j                  z        t        t        j                               t        j                          y)zSet splash messageN)r   r   r   r   r   intr   AlignBottomAlignCenterAlignAbsoluter   whiter   r  )r   r   s     r`   r  zMainWindow.set_splashn  s    ;;KK  #BNNR^^$C$&$4$4%5 !6 &rxx 0	2 	""$rb   c                     |Wt        j                         Ct        j                         j                          t        j                         | _        || _        y||| _        || _        y)z+To keep track of to the last focused widgetN)r   activeWindowsetFocusrg  r   r   )r   oldnows      r`   change_last_focused_widgetz%MainWindow.change_last_focused_widget{  s\    KL557C%%'002'3'?'?'AD$ ),$ _'*D$(+$rb   c                    | j                   s| j                  ry| j                  j                          t        | _        |rZ| j                  d      rIt        j                  | ddt        j                  t        j                        }|t        j                  k(  ry| j
                  j                  t        j                  h|      }|s|syd}| j                  | j                  j                  |       	 | j                  j                         }|r |j!                          |j#                          | j                  j#                          | j
                  j%                  t        j                  d       d| _         | j                  d	      r&| j(                  r| j(                  j!                          t+        j,                          y# t&        $ r Y ^w xY w)
z
Exit tasksTprompt_on_exitrr   zDo you really want to exit?F)	excludingclose_immediatelyzwindow/)teardownr  )r   r   rk   save_visible_pluginsr%   plugin_registryr   r   criticalYesNodelete_all_pluginsrF   r   save_current_window_settingsget_containerr  deleteLaterdelete_pluginrJ  r   r   r  )r   
cancelabler  reply	can_closeprefixlayouts_containers          r`   r5  zMainWindow.closing  s   $"5"5))+.$--(89((x)F)4+..JE &((;;~~&/ < 1	 !2
  <<#LL55f=	$(LL$>$>$@!$%++-%113((*$$22NNU 3 4
 #==*+0F0F""((*""$   s   6BG
 
	GGc                 \   	 |j                   rB|j                  |       \  }}| j                  ||       | j                  j	                  |       yy# t
        $ rQ |j                  rB|j                         \  }}| j                  ||       | j                  j	                  |       Y yY yw xY w)z>
        Add a plugin QDockWidget to the main window.
        N)r  create_dockwidgetaddDockWidgetr   r   rj  _is_compatible_create_dockwidget)r   r   rc  locations       r`   r0  zMainWindow.add_dockwidget  s    	/##'-'?'?'E$
H""8Z8&&v. $  	/$$'-'@'@'B$
H""8Z8&&v. %	/s   AA AB+*B+c                     t        j                         }| j                         }t        |j	                         t
              }ddlm} ddlm	} t        |||f      r t        ||              yy)zGlobal callbackr   ra  rc  N)r   rg  senderr   r  r7   re  rb  rf  rd  r   r5  )r   ri  rA  callbackrb  rd  s         r`   r  zMainWindow.global_callback  sU    ))+ ?IGf1=AB%GFH%'rb   c                     | j                  t        j                  d      }|r$|r|j                          y |j	                          y y )NFrg  )r   rF   r   redirect_stdsrestore_stds)r   staterc   s      r`   r   z'MainWindow.redirect_internalshell_stdio  s;    //'///?%%'$$&	 rb   c
           
      `   |rc	 | j                  dd      rt               }
n| j                  dd      }
| j                  ddd      }t        j                  |||||||
|       yy# t        $ r= t        j                  | t        d	      t        d
      t        j                  z         Y yw xY w)zOpen external consolerq   main_interpreterru  
executablespyder_pythonpathNpythonpath_manager)rq   rm  RunzDRunning an external system terminal is not supported on platform %s.)
r   r=   r9   run_python_script_in_terminalNotImplementedErrorr   r  r(   r{   r|   )r   fnamewdirargsinteractdebugpythonpython_argssystermpost_mortemr  pypaths               r`   open_external_consolez MainWindow.open_external_console  s     4==4F=G!6!8J!%$ 2 "/ "J ':D/C ' E664x   ' 4$$T1U8%& (J &)+-77&344s   A!A' 'AB-,B-c                    t        |      }t        j                  |      d   }| j                  t        j
                  d      }| j                  t        j                  d      }t        j                  |      r|r|j                  |       yy|(|t        v r |j                         j                  |       y|st        |      }t        |       yy)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  Frg  N)r7   ospsplitextr   rF   r  r   r8   is_text_fileloadr4   rE  import_datarA   rC   )r   r  r?  extr  rf   s         r`   	open_filezMainWindow.open_file  s     u%ll5!!$u=??$$E + 3   'E" )cZ.?'')55e<UOEu rb   c                     | j                   S )z%Return the initial working directory.)INITIAL_CWDr2  s    r`   get_initial_working_directoryz(MainWindow.get_initial_working_directory
  s    rb   c           	      H   t        j                  |      }| j                         }t        j                  t        j
                  ||            rt        j
                  ||      }nt        j                  |      r|}nyt        j                  dk(  rd|v ryt        j                  |      r| j                  |d       yt        j                  |      rNt        j                  | t        d      t        d      j                  t        j                  |      |             yy)	z~
        Open external files that can be handled either by the Editor or the
        variable explorer inside Spyder.
        Ndarwinz
bin/spyderTr~  ErrorzcTo open <code>{fpath}</code> as a project with Spyder, please use <code>spyder -p "{fname}"</code>.)fpathr  )r8   to_unicode_from_fsr  r  existsr  rY   platformisfiler  isdirr   r   r(   r   normpath)r   r  initial_cwdr  s       r`   r  zMainWindow.open_external_file  s     ++E288:::chh{E23HH[%0EZZE <<8#(=::eNN54N0YYuaj A Bcll51?	 rb   c                 `    | j                  t        j                        }|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   rF   r  get_spyder_pythonpath)r   r  s     r`   r  z MainWindow.get_spyder_pythonpath,  s'     oog778((**rb   c                    t        j                         }t               r(dt        j                         v r	 |j                  d       | j                  }| j                  d      r|t        j                  z  }| j                  |       | j                          | j                  d      r!|j                  | j                  d             y|j                  | j                         y#  Y xY w)zApply main window settings.zGTK+zgtk+vertical_tabsuse_custom_cursor_blinkingcustom_cursor_blinkingN)r   rv   r5   r   r  r  DOCKOPTIONSr   r   VerticalTabssetDockOptionsapply_panes_settingssetCursorFlashTimer   )r   r   rq   s      r`   r   zMainWindow.apply_settings:  s    $$& =+=+=+?!?f% ""==)k666GG$!!#==56##679 ##D$>$>?s   C& &C*c                 L   | j                   | j                  z   D ]i  }|j                  j                  }|j                  j	                  |       	 d}| j                  d      r| j                  d      }|j                  |       k y# t        $ r |j                          Y w xY w)z%Update dockwidgets features settings.r   r
  r  N)	r   r   rc  FEATURESsetFeaturesr   r1  rj  _update_margins)r   r   featuresr@  s       r`   r  zMainWindow.apply_panes_settingsS  s    )@)@@ 	)F((11H))(3)==!45!]]?;F%%f-	) " )&&()s   5BB#"B#c                 N    | j                   j                  | j                         y)zEdit Spyder preferences.N)r  open_dialogr   r2  s    r`   show_preferenceszMainWindow.show_preferencesd  s     	$$T%;%;<rb   c                     || _         y)zSave preferences dialog size.N)r   )r   r?  s     r`   set_prefs_sizezMainWindow.set_prefs_sizei  s
    !%rb   c                    | j                   j                  t        j                  t        j                  d       t        t              }| j                  d|       	 | j                   j                  d|f       | j                   j                  d       	 	 | j                   j                         \  }}|j/                  d      }|j1                  d	      }| j2                  j5                  |       |j7                  d
       m# t        $ r
 d | _         Y y w xY w# t        j                  $ r}t        j                  dk(  rt        j                   nt        j"                  }|j$                  d   |k(  rY d }~t        j                  dk(  rt        j&                  nt        j(                  }|j$                  d   t        j*                  |fv rY d }~y | j,                  rY d }~y  d }~ww xY w)Nr  )default_portopen_files_portz	127.0.0.1   rK   r   i   zutf-8    )r   
setsockoptr   
SOL_SOCKETSO_REUSEADDRr;   r2   r   bindr   listenr6  r   r{   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_servero  s   ))&*;*;*0*=*=q	B8'.
	""''d(;< 	%%b)!33::<
U  HHTNELL)E'',,U3KK+   	%)D"	 <<  +-''T/u{{66!9%13DE--!& 66!9!3!3X >>&&s>   D D DDG&,AG!6AG!G! G!!G&c                 >    | j                   j                  ||       y)z4Wrapper to handle plugins request to restart Spyder.)resetr  N)r0  r  )r   r  r  s      r`   r  zMainWindow.restart  s!      +< 	! 	>rb   c                    | j                   O| j                   j                         r5| j                   j                          | j                   j                          y|r| j                   j	                  d       n5| j                   j	                  d       | j                   j                          | j                   j                          | j                  j                  j                         j                         | j                         j                         j                         z   dz   }| j                   j                  |       y)zOpen switcher dialog box.N@ro      )r   r   clearr  set_search_textr  r   r  toolbars_menugeometryr   r  set_position)r   symbol	delta_tops      r`   r  zMainWindow.open_switcher  s    ==$)@)@)BMM!MM MM))#.MM))"-MM! \\//88:AAC\\^,,.5578:;<	 	""9-rb   c                 (    | j                  d       y)z'Open symbol list management dialog box.T)r  N)r  r2  s    r`   r  zMainWindow.open_symbolfinder  s    $'rb   c                 X    | j                   ddlm}  ||       | _         | j                   S )z Create switcher dialog instance.r   )r  )r   spyder.widgets.switcherr  )r   r  s     r`   r  zMainWindow.create_switcher  s$    == 8$TNDM}}rb   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 y)z,Get the current OpenGL implementation in usesoftwarer   glesN)r   testAttributer   AA_UseSoftwareOpenGLAA_UseDesktopOpenGLAA_UseOpenGLES)r   options     r`   _test_setting_openglzMainWindow._test_setting_opengl  sd    Z#11"2I2IJJy #11"2H2HIIv#11"2C2CDD rb   )NN)T)FFrt   )TN)F)Vr  
__module____qualname____doc__r7  r   AllowTabbedDocksAllowNestedDocksAnimatedDocksr  DEFAULT_LAYOUTSr<   r  r
   r  r  r  r   r  r+  r)  r$  sig_layout_setup_readyr  r-  ru   r   r   r   r   r   r  rE  rS  rY  r  r#  rN  r  rn  r  r  r  r  r  r  r  r  rK  r3  r:  r@  rC  rI  r  r  r&  rU  rY  r_  rm  r  r  r  r  r5  r0  r  r   r  r  r  r  r  r   r  r   r  r  r  r  r  r  r  r  __classcell__)r  s   @r`   rO   rO      s
   
 L 	$${'C'CC!!	"  O "K "( (#C[(K|$I#F^ $FF3%f~x5x
 >@56]@~2h
G1 1H$-LN(`)&0$dE'N@*,-D AE
 CG
J%
#/*	"
0+ &,PE6%,/b/"' AF42* <
+@2)" 
V= =&'V>..(Erb   rO   c                    t               rYt        j                  dd      dk7  r!t        j                  dd      }t        |       t	               }t        t        |d| d      }|S | j                  rt        d       t        Ut        | j                   xs= | j                  xs/ | j                  xs! | j                  xs t        t                            | j                   r| j                   }t        |       n:t        j                  dd      dk7  r!t        j                  dd      }t        |       t#        t$        d      r8t'        j(                  t$        j*                  t        j                  dd             t               dkD  r
t-                t/        |        t	               }t1               }||j3                          |j5                  t7        d	      t9        t$        j:                  t$        j<                  z  t$        j>                  z        tA        t$        jB                               tE        jF                          | j                  rt        j                          y| j                  r,ddl$}tK        jL                  d
|jN                  d   gdg       ytQ        d      }d}tS        jT                  |      rGtW        |d      5 }	|	jY                         }ddd       	 tQ        d      }
t[        j\                  ||
       t        j`                  dd|       tc        |       d}	 | jd                  r?ddl3}tW        |d      5 }	|ji                  |	       t        t        ||| |      }ddd       nt        t        ||| |      }|||jq                          yts                y# 1 sw Y   xY w# t^        $ r Y w xY w# 1 sw Y   DxY w# tj        $ r1 tm        jn                  ddd       t        j`                  ddd       Y w xY w)zMain functionrP   openglry  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.logro   rzfaulthandler.log.oldprevious_crashwr  rr   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.rt  
icon_themezspyder 2):r/   r3   r   r$   r   r   rO   show_consoler  rL   hide_consolereset_config_filesreset_to_defaultsoptimizeboolr+   opengl_implementationr  r   r   ry   r!  r    r#   r   r   r   r(   r{  r|  r}  r~  r   r  r   r  spyderr9   run_python_script__path__r*   r  r  openreadshutilr   rM  setr"   report_segfaultfaulthandlerr}  r   r   informationr  r   )r   r  r  r   windowr   r0  faulthandler_filer&  fdst
mainwindowr8  s                r`   rP   rP     s    88FH%4XXfh/F%f- "z3gtD    	! $/$)=)=%= &@(/(B(B&@(/(A(A&@ )0(8(8&@ )-_->(?		A $$..!&)88FH%4XXfh/F%f- r,-%%b&@&@&*hhv7I&J	L 1 ' 
C "#F /"2B2BBC288	

 	""$   			"",)/);(<dV	M &&89N
zz#$#S) 	&QVVXN	&	 67CKK)3/ 	HHV%~6 C J9""'- ###+*VWd
  'z3NJ KKMS	& 	&  		   9(I	
 	|Z89sH   N)%!N5 +O &O-O )N25	O OO	O 7P
	P
__main__)r  collectionsr   configparserr8  enumr   r  rN  loggingr{   os.pathr(  r  r5  r   r   rY   r
  r  r0  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.api.widgets.mixinsr'   spyder.config.baser(   r)   r*   r+   r,   r-   r.   r/   r0   spyder.config.guir1   spyder.config.mainr2   spyder.config.managerr3   spyder.config.utilsr4   r5   spyder.otherpluginsr6   spyder.py3compatr7   spyder.utilsr8   r9   spyder.utils.icon_managerr:   spyder.utils.miscr;   r<   r=   spyder.utils.paletter>   rx   r?   r@   rA   rB   rC   spyder.utils.stylesheetrD   spyder.api.exceptionsrE   spyder.api.pluginsrF   rG   rH   rI   rJ   rL   is_attached_console_visiblerM   r|   spyder.utils.windows	getLoggerr  r   rO   rP    rb   r`   <module>rc     sc  
 $    	  	     
  
      
 &1 1 +6 6  $ +  2   D @ ;> > > 1 . & : 6 + + )6 6 .> > 2 1   $ " ! 77d?B 
		8	$
 ) *MEMEf2up zF rb   