
    Je                     V    d Z 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  G d de      Zy)z1
IPython Console restart dialog for preferences.
    )Qt)QButtonGroup	QCheckBoxQDialogQLabelQPushButtonQVBoxLayout)_c                   :     e Zd ZdZdZdZdZ fdZd Zd Z	 xZ
S )ConsoleRestartDialogzP
    Dialog to apply preferences that need a restart of the console kernel.
             c                    t         t        |   |       | j                  t        j
                  t        j                  z         || _        | j                  | _	        | j                  t        d      | j                  t        d      | j                  t        d      i| _        t        t        d      |       | _        | j                  j!                  d       | j                  j#                  d       t%        t        d      |       | _        t%        t        d      |       | _        t+        |       | _        | j,                  j/                  d	       | j,                  j1                  | j&                  | j                  
       | j,                  j1                  | j(                  | j                  
       t3        | j                  | j                     |       | _        t7        |       }|j9                  | j                         |j;                  d       |j9                  | j&                         |j9                  | j(                         |j;                  d       |j9                  | j4                  dt        j<                         |j?                  dddd       | jA                  |       | j,                  jB                  jE                  | jF                         | j4                  jH                  jE                  | jJ                         y )NzKeep Existing KernelszRestart Current KernelzRestart All Kernelsa  By default, some IPython console preferences will be applied to new consoles only. To apply preferences to existing consoles, select from the options below.<br><br>Please note: applying changes to running consoles will force a kernel restart and all current work will be lost.Ti  z+Apply to current console and restart kernelz6Apply to all existing consoles and restart all kernelsF)id)parent   
   r      )&superr   __init__setWindowFlagsr   DialogWindowTitleHint_parent
NO_RESTART_actionr
   RESTART_CURRENTRESTART_ALL_action_stringr   _text_labelsetWordWrapsetFixedWidthr   _restart_current_restart_allr   _checkbox_groupsetExclusive	addButtonr   _action_buttonr	   	addWidget
addSpacing
AlignRightsetContentsMargins	setLayoutbuttonToggledconnectupdate_action_button_textclickedaccept)selfr   layout	__class__s      U/usr/lib/python3/dist-packages/spyder/plugins/ipythonconsole/widgets/restartdialog.pyr   zConsoleRestartDialog.__init__   sy   "D26:BII(:(::;OOQ67  !$<"=a 56 " E F
  	$$T*&&s+ !*;<d!D%FGO+D1))%0&&!!d&:&: 	' 	<&&$"2"2 	' 	4 *0? T"))*!../**+",,a?!!"b"b1v 	**22**	,##++DKK8    c                    | j                   j                  |      }|r| j                  |   }| j                   j                  j	                  | j
                         | j                  j                  d       | j                  j                  d       |j                  d       | j                   j                  j                  | j
                         n| j                  | j                     }| j                  j                  |       y)zo
        Update action button text.

        Takes into account the given checkbox to update the text.
        FTN)r&   r   r    r/   
disconnectr1   r$   
setCheckedr%   r0   r   r)   setText)r4   checkbox
is_checkedcheckbox_idtexts        r7   r1   z.ConsoleRestartDialog.update_action_button_textS   s     **--h7&&{3D  ..99..0!!,,U3((/%  ..66..0 &&t7D##D)r8   c                     | j                   j                         }| j                  j                         }t        ||g       }|||fS )zR
        Return tuple indicating True or False for the available actions.
        )r$   	isCheckedr%   any)r4   restart_currentrestart_all
no_restarts       r7   get_action_valuez%ConsoleRestartDialog.get_action_valueg   sK     //99;''113k?;<<
OZ77r8   )__name__
__module____qualname____doc__r   r   r   r   r1   rG   __classcell__)r6   s   @r7   r   r      s)    
 JOK39j*(8r8   r   N)rK   qtpy.QtCorer   qtpy.QtWidgetsr   r   r   r   r   r	   spyder.config.baser
   r    r8   r7   <module>rQ      s,   
 6 6 !Z87 Z8r8   