
    G@d                     N    d Z ddlmZmZ ddlmZ ddlmZ  G d de          ZdS )z~
Main widget to use in plugins that show content that comes from the IPython
console, such as the Variable Explorer or Plots.
    )QStackedWidgetQVBoxLayout)_)PluginMainWidgetc                   j     e Zd ZdZ fdZd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Z xZS )ShellConnectMainWidgetac  
    Main widget to use in a plugin that shows console-specific content.

    Notes
    -----
    * This is composed of a QStackedWidget to stack widgets associated to each
      shell widget in the console and only show one of them at a time.
    * The current widget in the stack will display the content associated to
      the console with focus.
    c                 D    t                      j        |i | t          |           | _        i | _        t                      }|                    d           |                    dddd           |                    | j                   | 	                    |           d S )Nr   )
super__init__r   _stack_shellwidgetsr   
setSpacingsetContentsMargins	addWidget	setLayout)selfargskwargslayout	__class__s       Clib/python3.11/site-packages/spyder/api/shellconnect/main_widget.pyr   zShellConnectMainWidget.__init__   s    $)&))) %T** !!!!Q1---%%%v    c                 :    | j                             d           d S )Nz*QStackedWidget {padding: 0px; border: 0px})r   setStyleSheetr   s    r   update_stylez#ShellConnectMainWidget.update_style-   s    !!"NOOOOOr   c                 4    | j                                         S )z
        Return the number of widgets in the stack.

        Returns
        -------
        int
            The number of widgets in the stack.
        )r   countr   s    r   r   zShellConnectMainWidget.count2   s     {  """r   c                 4    | j                                         S )z
        Return the current figure browser widget in the stack.

        Returns
        -------
        QWidget
            The current widget.
        )r   currentWidgetr   s    r   current_widgetz%ShellConnectMainWidget.current_widget=   s     {((***r   c                 *    |                                  S )N)r!   r   s    r   get_focus_widgetz'ShellConnectMainWidget.get_focus_widgetH   s    ""$$$r   c                     t          |          }|| j        vrd|                     |          }| j                            |           || j        |<   |                     |           |                                  dS dS )z[
        Create a new widget in the stack and associate it to
        shellwidget.
        N)idr   create_new_widgetr   r   set_shellwidgetupdate_actionsr   shellwidgetshellwidget_idwidgets       r   add_shellwidgetz&ShellConnectMainWidget.add_shellwidgetM   s    
 K!333++K88FK!!&)))17D~.  ---!!!!! 43r   c                     t          |          }|| j        v rK| j                            |          }| j                            |           |                     |           dS dS )z(Remove widget associated to shellwidget.N)r%   r   popr   removeWidgetclose_widgetr)   s       r   remove_shellwidgetz)ShellConnectMainWidget.remove_shellwidgetZ   si    KT///'++N;;FK$$V,,,f%%%%% 0/r   c                     t          |          }|                                 }|| j        v r?| j        |         }|                     ||           | j                            |           dS dS )zO
        Set widget associated with shellwidget as the current widget.
        N)r%   r!   r   switch_widgetr   setCurrentWidget)r   r*   r+   
old_widgetr,   s        r   r'   z&ShellConnectMainWidget.set_shellwidgetb   su     K((**
T///'7Fvz222K((00000 0/r   c                     t           )z0Create a widget to communicate with shellwidget.NotImplementedError)r   r*   s     r   r&   z(ShellConnectMainWidget.create_new_widgetm       !!r   c                     t           )zClose the widget.r8   r   r,   s     r   r1   z#ShellConnectMainWidget.close_widgetq   r:   r   c                     t           )zSwitch the current widget.r8   )r   r,   r6   s      r   r4   z$ShellConnectMainWidget.switch_widgetu   r:   r   c                     |                                  r*|                                 }|                                 dS dS )zRefresh widgets.N)r   r!   refreshr<   s     r   r?   zShellConnectMainWidget.refreshy   sC    ::<< 	((**FNN	 	r   c                     |                                  }|                                                                 D ]6\  }}|r/|r-|                                }||vr|                    |           7dS )zUpdate the actions.N)r!   get_actionsitemsactions	addAction)r   r,   __actionwidget_actionss        r   r(   z%ShellConnectMainWidget.update_actions   s    $$&&**,,2244 		1 		1JB 1
  1%+^^%5%5N^33((000		1 		1r   )__name__
__module____qualname____doc__r   r   r   r!   r#   r-   r2   r'   r&   r1   r4   r?   r(   __classcell__)r   s   @r   r   r      s        	 	    P P P
	# 	# 	#	+ 	+ 	+% % %
" " "& & &	1 	1 	1" " "" " "" " "  1 1 1 1 1 1 1r   r   N)	rK   qtpy.QtWidgetsr   r   spyder.api.translationsr   spyder.api.widgets.main_widgetr   r    r   r   <module>rQ      s     7 6 6 6 6 6 6 6 & % % % % % ; ; ; ; ; ;x1 x1 x1 x1 x1- x1 x1 x1 x1 x1r   