B
    nôb\RÁ  ã               @   s^  d Z ddlmZ ddlZddlmZmZmZmZm	Z	m
Z
 ddlmZmZmZmZmZmZmZmZ ddlmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z# ddl$m%Z%m&Z& ddl'm(Z( dd	l)m*Z*m+Z+ G d
d„ de,ƒZ-ddd„Z.dd„ Z/G dd„ deƒZ0G dd„ de0ƒZ1G dd„ de0ƒZ2G dd„ de#ƒZ3G dd„ deƒZ4dd„ Z5e6dkrZe5ƒ  dS )zSpyder interactive toursé    )ÚdivisionN)ÚQEasingCurveÚQPointÚQPropertyAnimationÚQRectFÚQtÚSignal)ÚQBrushÚQColorÚQIconÚQPainterÚQPainterPathÚQPenÚQPixmapÚQRegion)ÚQActionÚQApplicationÚ	QComboBoxÚQDialogÚQGraphicsOpacityEffectÚQHBoxLayoutÚQLabelÚQLayoutÚQMainWindowÚQMenuÚQPushButtonÚQSpacerItemÚQToolButtonÚQVBoxLayoutÚQWidget)Ú_Úget_image_path)Úto_binary_string)Úadd_actionsÚcreate_actionc               @   s\   e 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d
Zd
Zd
Zd
Zd
Zd
Zd
Zd
Zd
ZdS )ÚSpyderWidgetsz/List of supported widgets to highlight/decorateZ
ipyconsoleÚeditorz*editor.get_current_editor().linenumberareaz*editor.get_current_editor().scrollflagareaZexplorerÚhelpÚvariableexplorerZ
historylogÚ N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úipython_consoler&   Úeditor_line_number_areaZeditor_scroll_flag_areaÚfile_explorerÚhelp_pluginÚvariable_explorerÚhistory_logZtoolbarsZtoolbars_activeZtoolbar_fileZtoolbar_editZtoolbar_runZtoolbar_debugZtoolbar_mainZ
status_barZmenu_barZ	menu_fileZ	menu_edit© r4   r4   ú.lib/python3.7/site-packages/spyder/app/tour.pyr%   &   s(   r%   c             C   s   t | ƒS )zY
    Get the list of available tours (if index=None), or the your given by
    index
    )Úget_tour)Úindexr4   r4   r5   Ú	get_toursA   s    r8   c             C   s|  t }d}ddddœdddgd	gd
dœdddgdgd
dœdddgd
dœdddgdgddœg}tdƒtdƒddœtdƒtdƒ|jg|jgdœtdƒtdƒ |¡|jgddgdœtdƒtdƒ|jgd
dœtdƒtdƒ|jgd
dœtdƒtd ƒ|jgd
dœtd!ƒtd"ƒ|j	gd
dœg}d#td$ƒd%dœtdƒtd&ƒd'gd(œg}td)ƒ|d*œtd+ƒ|d*œg}| d,kr^|S | d-krn|gS ||  gS d,S ).a§  
    This function generates a list of tours.
    
    The index argument is used to retrieve a particular tour. If None is
    passed, it will return the full list of tours. If instead -1 is given,
    this function will return a test tour

    To add more tours a new variable needs to be created to hold the list of
    dicts and the tours variable at the bottom of this function needs to be
    updated accordingly
    z5https://qtconsole.readthedocs.io/en/stable/index.htmlz#Welcome to Spyder introduction tourzã<b>Spyder</b> is an interactive development                          environment. This tip panel supports rich text. <br>                         <br> it also supports image insertion to the right so                         farztour-spyder-logo.png)ÚtitleÚcontentÚimagezWidget displayzdThis show how a widget is displayed. The tip panel is adjusted based on the first widget in the listÚbutton1Úbutton2T)r9   r:   ÚwidgetsÚ
decorationÚinteract)r9   r:   r>   r@   zWidget display and highlightz)This shows how a highlighted widget looksÚbuttonFz Welcome to the Introduction toura  <b>Spyder</b> is a powerful Interactive Development Environment (or IDE) for the Python programming language.<br><br>Here we are going to guide you through its most important features.<br><br>Please use the arrow keys or click on the buttons below to move along the tour.z
The Editoraï  This is the pane where you write Python code before evaluating it. You can get automatic suggestions and completions while writing, by pressing the <b>Tab</b> key next to a given text.<br><br>The Editor comes with a line number area (highlighted here in red), where Spyder shows warnings and syntax errors. They can help you to detect potential problems before running the code.<br><br>You can also set debug breakpoints in the line number area, by doing a double click next to a non-empty line.)r9   r:   r>   r?   zThe IPython consoleaï  This is one of panes where you can run or execute the code you wrote on the Editor. To do it you need to press the <b>F5</b> key.<br><br>This console comes with several useful features that greatly improve your programming workflow (like syntax highlighting and inline plots). If you want to know more about them, please follow this <a href="{0}">link</a>.<br><br>Please click on the button below to run some simple code in this console. This will be useful to show you other important features.zli = list(range(100))zd = {'a': 1, 'b': 2})r9   r:   r>   ÚrunzThe Variable Explorera{  In this pane you can view and edit the variables generated during the execution of a program, or those entered directly in one of Spyder consoles.<br><br>As you can see, the Variable Explorer is showing the variables generated during the last step of this tour. By doing a double-click on any of them, a new window will be opened, where you can inspect and modify their contents.ZHelpa#  This pane displays documentation of the functions, classes, methods or modules you are currently using in the Editor or the Consoles.<br><br>To use it, you need to press <b>Ctrl+I</b> in front of an object. If that object has some documentation associated with it, it will be displayed here.zThe File Explorera/  This pane lets you navigate through the directories and files present in your computer.<br><br>You can also open any of these files with its corresponding application, by doing a double click on it.<br><br>There is one exception to this rule: plain-text files will always be opened in the Spyder Editor.zThe History LogzMThis pane records all commands introduced in the Python and IPython consoles.zNew features in Spyder 3.0zD<b>Spyder</b> is an interactive development environment based on blaz
spyder.pngz=Spyder is an interactive development environment based on blar(   )r9   r:   r>   zIntroduction tour)ÚnameÚtourzNew features in version 3.0Néÿÿÿÿ)
r%   r    r&   r/   Úformatr.   r2   r1   r0   r3   )r7   ÚswZqtconsole_linkÚtestZintroZfeat30Ztoursr4   r4   r5   r6   I   s‚    


	
,

r6   c                   s–   e Zd ZdZeƒ Z‡ fdd„Zdd„ Zdd„ Zdd	„ Z	d
d„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Z‡  ZS ) ÚFadingDialogz>A general fade in/fade out QDialog with some builtin functionsc                sŠ   t t| ƒ |¡ || _t|ƒ| _t|ƒ| _|d | _|d | _	|d | _
|d | _d | _d | _d| _g | _g | _g | _g | _|  d¡ d S )Nr   rE   F)ÚsuperrI   Ú__init__ÚparentÚminÚopacity_minÚmaxÚopacity_maxÚduration_fadeinÚduration_fadeoutÚeasing_curve_inÚeasing_curve_outÚeffectÚanimÚ_fade_runningÚ_funcs_before_fade_inÚ_funcs_after_fade_inÚ_funcs_before_fade_outÚ_funcs_after_fade_outÚsetModal)ÚselfrL   ÚopacityÚdurationÚeasing_curve)Ú	__class__r4   r5   rK     s     





zFadingDialog.__init__c             C   s   x|D ]
}|ƒ  qW dS )ú Nr4   )r]   ÚfuncsÚfuncr4   r4   r5   Ú_run(  s    
zFadingDialog._runc             C   s   |   | j¡ dS )rb   N)re   rX   )r]   r4   r4   r5   Ú_run_before_fade_in-  s    z FadingDialog._run_before_fade_inc             C   s   |   | j¡ dS )rb   N)re   rY   )r]   r4   r4   r5   Ú_run_after_fade_in1  s    zFadingDialog._run_after_fade_inc             C   s   |   | j¡ dS )rb   N)re   rZ   )r]   r4   r4   r5   Ú_run_before_fade_out5  s    z!FadingDialog._run_before_fade_outc             C   s   |   | j¡ dS )rb   N)re   r[   )r]   r4   r4   r5   Ú_run_after_fade_out9  s    z FadingDialog._run_after_fade_outc             C   s
   d| _ dS )rb   FN)rW   )r]   r4   r4   r5   Ú_set_fade_finished=  s    zFadingDialog._set_fade_finishedc             C   s2   d| _ t| ƒ| _|  | j¡ t| jtdƒƒ| _dS )rb   Tr^   N)rW   r   rU   ÚsetGraphicsEffectr   r"   rV   )r]   r4   r4   r5   Ú_fade_setupA  s    
zFadingDialog._fade_setupc             C   s”   |   ¡  |  ¡  |  ¡  |  ¡  | j | j¡ | j | j¡ | j 	| j
¡ | j | j¡ | jj |¡ | jj | j¡ | jj | j¡ | j ¡  dS )rb   N)rf   rl   ÚshowÚraise_rV   ÚsetEasingCurverS   ÚsetStartValuerN   ÚsetEndValuerP   ÚsetDurationrQ   ÚfinishedÚconnectrj   rg   Ústart)r]   Úon_finished_connectr4   r4   r5   Úfade_inI  s    zFadingDialog.fade_inc             C   s„   |   ¡  |  ¡  | j | j¡ | j | j¡ | j | j¡ | j 	| j
¡ | jj |¡ | jj | j¡ | jj | j¡ | j ¡  dS )rb   N)rh   rl   rV   ro   rT   rp   rP   rq   rN   rr   rR   rs   rt   rj   ri   ru   )r]   rv   r4   r4   r5   Úfade_outX  s    zFadingDialog.fade_outc             C   s   | j S )rb   )rW   )r]   r4   r4   r5   Úis_fade_runninge  s    zFadingDialog.is_fade_runningc             C   s
   || _ dS )rb   N)rX   )r]   rc   r4   r4   r5   Úset_funcs_before_fade_ini  s    z%FadingDialog.set_funcs_before_fade_inc             C   s
   || _ dS )rb   N)rY   )r]   rc   r4   r4   r5   Úset_funcs_after_fade_inm  s    z$FadingDialog.set_funcs_after_fade_inc             C   s
   || _ dS )rb   N)rZ   )r]   rc   r4   r4   r5   Úset_funcs_before_fade_outq  s    z&FadingDialog.set_funcs_before_fade_outc             C   s
   || _ dS )rb   N)r[   )r]   rc   r4   r4   r5   Úset_funcs_after_fade_outu  s    z%FadingDialog.set_funcs_after_fade_out)r*   r+   r,   r-   r   Úsig_key_pressedrK   re   rf   rg   rh   ri   rj   rl   rw   rx   ry   rz   r{   r|   r}   Ú__classcell__r4   r4   )ra   r5   rI     s"   rI   c                   sj   e Zd ZdZd‡ fdd„	Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Z‡  ZS )ÚFadingCanvasz=The black semi transparent canvas that covers the applicationNc                sâ   t tˆ ƒ ||||¡ |ˆ _|ˆ _|ˆ _tjˆ _dˆ _	dˆ _
dˆ _dˆ _dˆ _dˆ _dˆ _dˆ _dˆ _dˆ _dˆ _ˆ  tjtjB ¡ ˆ  tj¡ ˆ  tj¡ ˆ  d¡ ˆ  tj¡ ˆ  ˆ jg¡ ˆ  ‡ fdd„‡ fdd„g¡ dS )z;Create a black semi transparent canvas that covers the app.é   NFc                  s
   ˆ   d ¡S )N)Úupdate_widgetsr4   )r]   r4   r5   Ú<lambda>  s    z'FadingCanvas.__init__.<locals>.<lambda>c                  s
   ˆ   d ¡S )N)Úupdate_decorationr4   )r]   r4   r5   rƒ   ž  s    ) rJ   r€   rK   rL   rD   Úcolorr   ZredÚcolor_decorationÚstroke_decorationÚregion_maskZregion_subtractZregion_decorationr>   r?   Úinteraction_onÚpath_currentÚpath_subtractÚ	path_fullÚpath_decorationÚsetWindowFlagsÚDialogÚFramelessWindowHintÚsetAttributeÚWA_TranslucentBackgroundÚWA_TransparentForMouseEventsr\   ÚsetFocusPolicyÚNoFocusrz   Úupdate_canvasr}   )r]   rL   r^   r_   r`   r…   rD   )ra   )r]   r5   rK   |  s2    
zFadingCanvas.__init__c             C   s
   || _ dS )rb   N)r‰   )r]   Úvaluer4   r4   r5   Úset_interaction   s    zFadingCanvas.set_interactionc             C   sX  | j  ¡  ¡ | j  ¡  ¡  }}tƒ | _tƒ | _tƒ | _tdd||ƒ| _	| j 
dd||¡ | jdk	r*x²| jD ]¨}tƒ }|dk	rð| ¡  | ¡  | ¡ }| ¡ | ¡  }}| | j tddƒ¡}| ¡ | ¡  }	}
| 
t|	|
||ƒ¡ t|	|
||ƒ}| jr| j	 |¡| _	| j |¡| _qlW | j | j¡| _n| j| _| jdk	r&xø| jD ]Ú}tƒ }| ¡  | ¡  | ¡ }| ¡ | ¡  }}| | j tddƒ¡}| ¡ | ¡  }	}
| 
t|	|
||ƒ¡ t|	d |
d |d |d ƒ}t|	d |
d |d |d ƒ}| |¡}| jr| j	 |¡| _	| j |¡| _qFW n| j 
dddd¡ |  | j	¡ |  ¡  |  ¡  dS )rb   r   Né   r   )rL   ÚsizeÚwidthÚheightr   rŒ   r‹   r   r   rˆ   ZaddRectr>   rn   rm   ÚframeGeometryZmapTor   ÚxÚyr   r‰   Z
subtractedZunitedrŠ   r?   ZsetMaskÚupdateZrepaint)r]   ÚwÚhÚwidgetZ	temp_pathÚgeor›   rœ   Úpointrž   rŸ   Ztemp_regionZtemp_region_1Ztemp_region_2r4   r4   r5   r–   ¤  sV    
zFadingCanvas.update_canvasc             C   s
   || _ dS )rb   N)r>   )r]   r>   r4   r4   r5   r‚   ã  s    zFadingCanvas.update_widgetsc             C   s
   || _ dS )rb   N)r?   )r]   r>   r4   r4   r5   r„   ç  s    zFadingCanvas.update_decorationc             C   sD   t | ƒ}| t j¡ | | jt| jƒ¡ | | jt	| j
| jƒ¡ dS )zOverride Qt methodN)r   ÚsetRenderHintÚAntialiasingÚfillPathrŠ   r	   r…   Ú
strokePathr   r   r†   r‡   )r]   ÚeventÚpainterr4   r4   r5   Ú
paintEventë  s
    zFadingCanvas.paintEventc             C   s"   |   ¡ stj}|| _| j ¡  dS )zOverride Qt methodN)ry   r   Ú
Key_EscapeÚkey_pressedr~   Úemit)r]   Úkeyr4   r4   r5   Úreject÷  s    zFadingCanvas.rejectc             C   s   dS )zOverride Qt methodNr4   )r]   rª   r4   r4   r5   ÚmousePressEventþ  s    zFadingCanvas.mousePressEventc             C   s   |   ¡ r| j ¡  dS )zOverride Qt method.N)ÚhasFocusrD   Ú
gain_focus)r]   rª   r4   r4   r5   ÚfocusInEvent  s    zFadingCanvas.focusInEventc             C   s   | j jdkr| j  ¡  dS )zOverride Qt method.r   N)rD   Ústep_currentÚ
lost_focus)r]   rª   r4   r4   r5   ÚfocusOutEvent  s    zFadingCanvas.focusOutEvent)N)r*   r+   r,   r-   rK   r˜   r–   r‚   r„   r¬   r±   r²   rµ   r¸   r   r4   r4   )ra   r5   r€   z  s   #?r€   c                   s|   e Zd ZdZd‡ fdd„	Zdd„ Zdd„ Zdd	d
„Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Z‡  ZS )ÚFadingTipBoxrb   Nc                s”  t t| ƒ ||||¡ | j| _|| _|| _d | _t 	ddd¡| _
t 	ddd¡| _d| _d| _d | _|  tj¡ |  tjtjB tjB ¡ |  d¡ tdƒ| _tdƒ| _tdƒ| _td	ƒ| _td
ƒ| _ttdƒƒ| _d | _t ƒ | _!t"ƒ | _#t"ƒ | _$t%ƒ | _&t"ƒ | _'t"ƒ | _(| j( )| j¡ | j( *| j¡ | j' +tj,¡ | j( -d¡ | j(| j$| j'| j&| j| j| j| j| j| j| j!g| _.t/dƒ}d| d | _0| j0 1dd¡| _0|  2tj3¡ x(| j.D ]}| 2tj4¡ | 5| j0¡ q¨W t6ƒ }| 7| j&¡ | 8¡  | 7| j¡ | 9t:| j| jƒ¡ t6ƒ }	|	 7| j(¡ |	 7| j#¡ |	 9t:ddƒ¡ t6ƒ }
|
 8¡  |
 7| j¡ |
 8¡  |
 9t:| j| jƒ¡ t6ƒ }| 7| j¡ | 7| j¡ | 8¡  | 7| j'¡ | 8¡  | 7| j¡ | 7| j¡ | 9t:| j| jƒ¡ t;ƒ }| <|¡ | 8¡  | 9t:ddƒ¡ | <|	¡ | <|
¡ | 8¡  | 9t:ddƒ¡ | <|¡ | 9t:| j| jƒ¡ | =t>j?¡ |  @|¡ |  A| jBg¡ |  C| jD| jEg¡ |  F| jBg¡ |  GtjH¡ d S )Néæ   éÿ   r   i,  Fz<<ÚXz < z>>z > zRun codeTzhide.pngaS  QPushButton {
                             background-color: rgbs(200,200,200,100%);
                             color: rgbs(0,0,0,100%);
                             border-style: outset;
                             border-width: 1px;
                             border-radius: 3px;
                             border-color: rgbs(100,100,100,100%);
                             padding: 2px;
                             }

                             QPushButton:hover {
                             background-color: rgbs(150, 150, 150, 100%);
                             }

                             QPushButton:disabled {
                             background-color: rgbs(230,230,230,100%);
                             color: rgbs(200,200,200,100%);
                             border-color: rgbs(200,200,200,100%);
                             }

                             QComboBox {
                             padding-left: 5px;
                             background-color: rgbs(230,230,230,100%);
                             border-width: 0px;
                             border-radius: 0px;
                             min-height:20px;
                             max-height:20px;
                             }

                             QComboBox::drop-down  {
                             subcontrol-origin: padding;
                             subcontrol-position: top left;
                             border-width: 0px;
                             }
                             
                             QComboBox::down-arrow {
                             image: url(z]);
                             }
                             
                             ú\ú/é   é   )IrJ   r¹   rK   rV   ZholderrL   rD   Úframesr
   ZfromRgbÚ	color_topÚ
color_backÚoffset_shadowZfixed_widthr®   r‘   r   r’   rŽ   r   r   ÚWindowStaysOnTopHintr\   r   Úbutton_homeÚbutton_closeÚbutton_previousÚ
button_endÚbutton_nextr    Ú
button_runÚbutton_disabler   Úbutton_currentr   Úlabel_imageÚlabel_titler   Úcombo_titleÚlabel_currentÚlabel_contentZsetMinimumWidthZsetMaximumWidthZsetAlignmentZAlignCenterZsetWordWrapr>   r!   Z
stylesheetÚreplacer”   ZStrongFocusr•   ZsetStyleSheetr   Ú	addWidgetÚ
addStretchZaddSpacerItemr   r   Z	addLayoutZsetSizeConstraintr   ZSetFixedSizeÚ	setLayoutrz   Ú_disable_widgetsr{   Ú_enable_widgetsZsetFocusr|   ZsetContextMenuPolicyZCustomContextMenu)r]   rL   r^   r_   r`   rD   Zarrowr£   Z
layout_topZlayout_contentZ
layout_runZlayout_navigationÚlayout)ra   r4   r5   rK     s°    






&












zFadingTipBox.__init__c             C   s   x| j D ]}| d¡ qW dS )rb   TN)r>   ÚsetDisabled)r]   r£   r4   r4   r5   r×   «  s    zFadingTipBox._disable_widgetsc             C   s|   |   tjtjB tjB ¡ x| jD ]}| d¡ q W | jdkrV| j d¡ | j	 d¡ n"| jdkrx| j
 d¡ | j d¡ dS )rb   FÚpreviousTÚnextN)rŽ   r   r   r   rÅ   r>   rÚ   rÌ   rÈ   rÆ   rÊ   rÉ   )r]   r£   r4   r4   r5   rØ   °  s    


zFadingTipBox._enable_widgetsc       	      C   sö   | j  |¡ | j ¡  | j |¡ | j |¡ | j |¡ | j |¡ | j |¡ || _	|dkrz| j
 d¡ | j
 d¡ n>| d¡d }tt|ƒ|ƒ| _	| j
 | j	¡ | j
 | j	 ¡ ¡ |dkrÎ| j d¡ n| j d¡ | j d¡ |  ¡  ¡  dS )rb   Nr™   Ú.rE   FT)rÏ   ZsetTextrÐ   ÚclearZaddItemsZsetCurrentIndexrÑ   rÍ   rÒ   r;   rÎ   ZsetFixedHeightZsetFixedWidthÚsplitr   r!   Z	setPixmapÚsetFixedSizerš   rË   Z
setVisiblerÚ   rÙ   Zactivate)	r]   r9   r:   Úcurrentr;   rB   rÁ   ÚstepÚ	extensionr4   r4   r5   Úset_data¾  s(    
zFadingTipBox.set_datac             C   s    || _ || _|  t||ƒ¡ dS )rb   N)rž   rŸ   Úmover   )r]   rž   rŸ   r4   r4   r5   Úset_posà  s    zFadingTipBox.set_posc             C   sÂ  |   ¡ }d}| j}| ¡ | ¡  }}| ¡ | | ¡ |  }}d\}}	|| }
}tƒ | _| j |
|	| ¡ | j 	|
| |	||dd¡ | j 
|| |	¡ | j 	||	||dd¡ | j 
||| ¡ | j 	||| ||dd¡ | j 
|
| |¡ | j 	|
| || ||dd¡ | j ¡  d}d}|| }}	|| }
tƒ | _| j 
|
|	| ¡ | j |
|	| ¡ | j 	|
| |	||dd¡ | j 
|| |	¡ | j 	||	||dd¡ | j 
||	| ¡ | j 
|
|	| ¡ d	S )
rb   é   )r   r   g        g     €V@g     €f@g     àp@é$   r   N)ÚgeometryrÄ   rž   rŸ   r›   rœ   r   Úround_rect_pathZmoveToZarcToZlineToZcloseSubpathÚtop_rect_path)r]   r¤   ZradiusZshadowZx0Zy0r›   rœ   ÚleftÚtopÚrightZbottomÚheaderÚoffsetr4   r4   r5   Úbuild_pathsæ  s@    


zFadingTipBox.build_pathsc             C   sV   |   ¡  t| ƒ}| tj¡ | | j| j¡ | | j| j¡ | 	| jt
tjdƒ¡ dS )rb   r™   N)rñ   r   r¦   r§   r¨   rê   rÃ   rë   rÂ   r©   r   r   Zgray)r]   rª   r«   r4   r4   r5   r¬     s    zFadingTipBox.paintEventc          
   C   sX   |  ¡ }|| _tjtjtjtjtjtjtj	tj
tjtjg
}||krT|  ¡ sT| j ¡  dS )rb   N)r°   r®   r   Ú	Key_RightÚKey_LeftÚKey_DownÚKey_Upr­   Ú
Key_PageUpÚKey_PageDownÚKey_HomeÚKey_EndÚKey_Menury   r~   r¯   )r]   rª   r°   Úkeysr4   r4   r5   ÚkeyReleaseEvent  s    zFadingTipBox.keyReleaseEventc             C   s$   | j  ¡  |  ¡  | ¡ tjkr dS )zoverride Qt methodN)rL   rn   rA   r   ZRightButton)r]   rª   r4   r4   r5   r²   '  s    
zFadingTipBox.mousePressEventc             C   s   | j  ¡  dS )zOverride Qt method.N)rD   r·   )r]   rª   r4   r4   r5   r¸   3  s    zFadingTipBox.focusOutEventc             C   sd   t | ¡ | ¡ ƒ}t| ƒ}g }t| tdƒtƒ d}| d¡ | |¡ t	||ƒ | 
|  |¡¡ dS )rb   zGo to step: )ZiconTN)r   rž   rŸ   r   r$   r    r   rÚ   Úappendr#   ZpopupÚmapToGlobal)r]   rª   ÚposZmenuZactionsZaction_titler4   r4   r5   Úcontext_menu_requested8  s    


z#FadingTipBox.context_menu_requestedc             C   s"   |   ¡ stj}|| _| j ¡  dS )z$Qt method to handle escape key eventN)ry   r   r­   r®   r~   r¯   )r]   r°   r4   r4   r5   r±   G  s    zFadingTipBox.reject)N)NN)r*   r+   r,   r-   rK   r×   rØ   rä   ræ   rñ   r¬   rü   r²   r¸   r   r±   r   r4   r4   )ra   r5   r¹     s     
!'r¹   c               @   sê   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd9d-d.„Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd,S ):ÚAnimatedTourrb   c                s¸  t  ˆ |¡ |ˆ _ddgˆ _ddgˆ _ddgˆ _ddgˆ _tjˆ _	t
jgˆ _dˆ _dˆ _dˆ _d ˆ _d ˆ _d ˆ _d ˆ _d ˆ _d ˆ _d ˆ _d ˆ _dˆ _dˆ _tˆ jˆ jˆ jˆ jˆ j	ˆ dˆ _tˆ jˆ jˆ jˆ jˆ dˆ _ˆ  tj¡ ˆ jjj  ˆ j!¡ ˆ jj"j  ˆ j#¡ ˆ jj$j  ˆ j%¡ ˆ jj&j  ˆ j'¡ ˆ jj(j  ˆ j)¡ ˆ jj*j  ˆ j+¡ ˆ jj&j  ‡ fd	d
„¡ ˆ jj,j-  ˆ j.¡ ˆ jj/  ˆ j0¡ ˆ jj1  ˆ j2¡ ˆ jj3  ˆ j4¡ dˆ _5dˆ _6d S )Niš  iM  g        gffffffæ?g      ð?r   F)rD   c                  s   ˆ j j d¡S )NT)ÚtipsrË   rÚ   r4   )r]   r4   r5   rƒ   ƒ  s    z'AnimatedTour.__init__.<locals>.<lambda>)7r   rK   rL   Zduration_canvasZduration_tipsZopacity_canvasZopacity_tipsr   Zblackr…   r   ZLinearr`   Zcurrent_stepr¶   ÚstepsÚcanvasr  rÁ   Ú
spy_windowr>   Údockwidgetsr?   rB   Úis_tour_setÚ
is_runningr€   r¹   r‘   r“   rÊ   Úclickedrt   Ú	next_steprÈ   Úprevious_steprÇ   Ú
close_tourrË   Úrun_coderÆ   Ú
first_steprÉ   Ú	last_steprÐ   ZcurrentIndexChangedÚ
go_to_stepÚsig_resizedÚ_resizedÚ	sig_movedÚ_movedr~   Ú_key_pressedÚsetting_dataÚhidden)r]   rL   r4   )r]   r5   rK   R  sT    








zAnimatedTour.__init__c             C   s6   | j r2| ¡ }| j |¡ | j ¡  | jr2|  ¡  dS )rb   N)r  rš   r  rà   r–   r  Ú	_set_data)r]   rª   rš   r4   r4   r5   r  ‘  s    
zAnimatedTour._resizedc             C   s:   | j r6| ¡ }| j t| ¡ | ¡ ƒ¡ | jr6|  ¡  dS )rb   N)	r  rÿ   r  rå   r   rž   rŸ   r  r  )r]   rª   rÿ   r4   r4   r5   r  ›  s
    zAnimatedTour._movedc             C   s   | j  ¡  | j | jj¡ dS )rb   N)r  Úhider  rx   )r]   r4   r4   r5   Ú_close_canvas¤  s    
zAnimatedTour._close_canvasc             C   s&   | j  d¡ | j  d¡ | j  ¡  dS )rb   N)r  r‚   r„   r–   )r]   r4   r4   r5   Ú_clear_canvas©  s    zAnimatedTour._clear_canvasc             C   s\   |   ¡  | j}|dk	r6|d }|dk	r6| ¡  | ¡  |  ¡  | j | jj¡ | j ¡  dS )rb   Nr   )	r  r  rm   rn   Ú_locate_tip_boxr  rw   r  r–   )r]   r>   r£   r4   r4   r5   Ú
_move_step±  s    zAnimatedTour._move_stepc             C   sT   t j ¡ }d|krn<d|krFx2|D ]}| |¡ | ¡  | ¡  q"W n
d|krPn dS )rb   ZlinuxÚwinÚdarwinN)ÚsysÚplatformÚlowerr\   r  rm   )r]   r—   r>   r!  r£   r4   r4   r5   Ú
_set_modalÃ  s    


zAnimatedTour._set_modalc             C   sz   g }g }xh|D ]`}|  d¡d }t||ƒ}d|krN| ¡ }t||  d¡d ƒ}| |¡ t|d|ƒ}| |¡ qW ||fS )rb   rÝ   r   zget_current_editor()rE   Z
dockwidget)rß   ÚgetattrZget_current_editorrý   )r]   Únamesr  r>   r  rC   ÚbaseZtempr4   r4   r5   Ú_process_widgetsÓ  s    


zAnimatedTour._process_widgetsc          	   C   s°  d| _ | j| j| j  }}}d |d |¡}|| }dd„ t|ƒD ƒ}d\}}}	d\}
}}d}d	|krn|d	 }d
|kr~|d
 }d|kr¤|| d }|  || j¡\}
}|
| _|| _	d|krÜ|| d }|  || j¡\}}|| _
d|krð|| d }	d|kr8| j |d ¡ |d r&|  d| jg¡ n|  d| jg¡ n| j d¡ |  d| jg¡ d|krl|d }|| _| jj||||	|||d |  ¡  | j |¡ | j |¡ d| _ dS )z4Set data that is displayed in each step of the tour.Tz{0}/{1}r™   c             S   s$   g | ]\}}d   |d |d ¡‘qS )z{0}. {1}r™   r9   )rF   )Ú.0ÚiÚfr4   r4   r5   ú
<listcomp>ñ  s   z*AnimatedTour._set_data.<locals>.<listcomp>)r)   r)   N)NNNNr9   r:   r>   r?   r;   r@   FrB   )rÁ   râ   )r  r¶   r  rÁ   rF   Ú	enumerater'  r  r>   r  r?   r  r˜   r#  r  rB   rä   Ú_check_buttonsr‚   r„   )r]   râ   r  rÁ   rá   ÚframeZcombobox_framesr9   r:   r;   r>   r  r?   rB   Zwidget_namesZdecor4   r4   r5   r  ê  sT    





zAnimatedTour._set_datac             C   sð  | j }| j ¡ }| ¡ | ¡ | ¡ | ¡ f\}}}}|| _|| _|| _	|| _
d}|dk	r¢|d dk	rÞ|d  ¡ }| ¡ | ¡ | ¡ | ¡ f\}}}}|d  tddƒ¡}| ¡ | ¡  }	}
|| j d }|dkr<|| j ¡ k r|	| | }|
|d  | j ¡ d  }n,|	| j ¡  | }|
|d  | j ¡ d  }nd|| j ¡ k rt|	|d  | j ¡ d  }|
| | }n,|	|d  | j ¡ d  }|
| | j ¡  }n<| j	| jd  | j ¡ d  }| j
| jd  | j ¡ d  }| j ||¡ dS )rb   é   Nr   éd   é<   r   )r  rL   r   rž   rŸ   r›   rœ   Z
width_mainZheight_mainZx_mainZy_mainré   rþ   r   r  ræ   )r]   r  r¤   rž   rŸ   r›   rœ   Zdeltar¥   Zx_globZy_globZy_facr4   r4   r5   r  (  s:    
$
$
zAnimatedTour._locate_tip_boxc             C   s>   | j | j }}d| j_|dkr&d| j_||d kr:d| j_dS )rb   Nr   rÛ   r™   rÜ   )r¶   r  r  rÌ   )r]   râ   r  r4   r4   r5   r-  X  s    zAnimatedTour._check_buttonsc             C   sî   | j j}|tjks&|tjks&|tjkr@| j| jd kr@|  ¡  nª|tj	ks^|tj
ks^|tjkrr| jdkrr|  ¡  nx|tjkr†|  ¡  nd|tjkr¤| jdkr¤|  ¡  nF|tjkrÈ| j| jd krÈ|  ¡  n"|tjkrê| j j ¡ }| j  |¡ dS )rb   r™   r   N)r  r®   r   rò   rô   r÷   r¶   r  r
  ró   rõ   rö   r  r­   r  rø   r  rù   r  rú   rÑ   rÿ   r   )r]   r°   rÿ   r4   r4   r5   r  c  s     






zAnimatedTour._key_pressedc             C   s   d| _ | j ¡  d S )NT)r  r  r  )r]   r4   r4   r5   Ú_hidingw  s    zAnimatedTour._hidingc             C   s,   | j }| jd }x|D ]}| |¡ qW dS )rb   r   N)rB   r>   Zexecute_code)r]   Z	codelinesZconsoleZcodeliner4   r4   r5   r  |  s    

zAnimatedTour.run_codec             C   s6   || _ || _|d | _|d | _t| jƒ| _d| _dS )rb   ÚlastrD   TN)r  Úactive_tour_indexÚlast_frame_activerÁ   Úlenr  r  )r]   r7   rÁ   r  r4   r4   r5   Úset_tourƒ  s    

zAnimatedTour.set_tourc             C   sv   | j  ¡ }| ¡ | ¡ | ¡ | ¡ f\}}}}| j| _| j 	||¡ | j 
t||ƒ¡ | j | j¡ |  ¡  d| _dS )rb   TN)rL   ré   rž   rŸ   r›   rœ   r5  r¶   r  rà   rå   r   rw   r  r  r  )r]   r¤   rž   rŸ   r›   rœ   r4   r4   r5   Ú
start_tour  s    
$zAnimatedTour.start_tourc             C   sd   | j  | j¡ | j d¡ |  d| j g¡ | j ¡  y| j| jj	| j
 d< W n   Y nX d| _dS )rb   FTr3  N)r  rx   r  r  r˜   r#  r  r¶   rL   Ztours_availabler4  r  )r]   r4   r4   r5   r  ¢  s    
zAnimatedTour.close_tourc             C   s   |   ¡  | j | j¡ dS )z2Hide tips dialog when the main window loses focus.N)r  r  rx   r2  )r]   r4   r4   r5   Ú	hide_tips³  s    zAnimatedTour.hide_tipsc             C   s   |   ¡  |  ¡  d| _dS )z4Unhide tips dialog when the main window loses focus.FN)r  r  r  )r]   r4   r4   r5   Úunhide_tips¸  s    zAnimatedTour.unhide_tipsc             C   s(   |   ¡  |  jd7  _| j | j¡ dS )rb   r™   N)r  r¶   r  rx   r  )r]   r4   r4   r5   r
  ¾  s    zAnimatedTour.next_stepc             C   s(   |   ¡  |  jd8  _| j | j¡ dS )rb   r™   N)r  r¶   r  rx   r  )r]   r4   r4   r5   r  Ä  s    zAnimatedTour.previous_stepNc             C   s    |   ¡  || _| j | j¡ dS )rb   N)r  r¶   r  rx   r  )r]   ZnumberZid_r4   r4   r5   r  Ê  s    zAnimatedTour.go_to_stepc             C   s   |   | jd ¡ dS )rb   r™   N)r  r  )r]   r4   r4   r5   r  Ð  s    zAnimatedTour.last_stepc             C   s   |   d¡ dS )rb   r   N)r  )r]   r4   r4   r5   r  Ô  s    zAnimatedTour.first_stepc             C   s&   | j r"|  ¡ s"| js"| js"|  ¡  dS )z3Confirm if the tour loses focus and hides the tips.N)r  Úany_has_focusr  r  r9  )r]   r4   r4   r5   r·   Ø  s    zAnimatedTour.lost_focusc             C   s&   | j r"|  ¡ r"| js"| jr"|  ¡  dS )z7Confirm if the tour regains focus and unhides the tips.N)r  r;  r  r  r:  )r]   r4   r4   r5   r´   Þ  s    zAnimatedTour.gain_focusc             C   s*   |   ¡ p$| j  ¡ p$| j  ¡ p$| j  ¡ }|S )z3Returns if tour or any of its components has focus.)r³   rL   r  r  )r]   r*  r4   r4   r5   r;  ä  s    zAnimatedTour.any_has_focus)N)r*   r+   r,   r-   rK   r  r  r  r  r  r#  r'  r  r  r-  r  r2  r  r7  r8  r  r9  r:  r
  r  r  r  r  r·   r´   r;  r4   r4   r4   r5   r  O  s8   ?
	>0

r  c                   sP   e Zd ZdZedƒZedƒZ‡ fdd„Zdd„ Zdd	„ Z	d
d„ Z
dd„ Z‡  ZS )ÚTourTestWindowrb   ZQResizeEventZ
QMoveEventc                sP  t t| ƒ ¡  |  dddd¡ |  d¡ td| ƒ| _| j d¡ |  ¡ }| 	d¡}| 
| j¡ |  ¡  t| ƒ| _td	ƒ| _td
ƒ| _tdƒ| _t| jƒ}| j |¡ t|tdƒƒ| _| j d¡ | j d¡ | j d¡ tƒ }| | j¡ | ¡  | | j¡ | | j¡ | j |¡ |  | j¡ | jj  | j!¡ | jj  | j"¡ t#| ƒ| _$d S )Ni,  r0  i  iX  zExploring QMainWindowZExitzExit programz&FilerH   Ú1Ú2r^   g{®Gáz„?g      ð?iô  )%rJ   r<  rK   ZsetGeometryZsetWindowTitler   ÚexitZsetStatusTipZmenuBarZaddMenuZ	addActionZ	statusBarr   r£   r   rA   r<   r=   r   rk   r   r"   rV   rp   rq   rr   r   rÔ   rÕ   rÖ   ZsetCentralWidgetr	  rt   Úaction1Úaction2r  rD   )r]   ZmenubarZfile_rU   Zlay)ra   r4   r5   rK   ó  s:    






zTourTestWindow.__init__c             C   s4   t dƒ}d}d|dœ}| j ||| ¡ | j ¡  dS )rb   rH   r   )r3  rD   N)r6   rD   r7  r8  )r]   rÁ   r7   Zdicr4   r4   r5   r@    s
    
zTourTestWindow.action1c             C   s   | j  ¡  dS )rb   N)rV   ru   )r]   r4   r4   r5   rA  '  s    zTourTestWindow.action2c             C   s   t  | |¡ | j |¡ dS )zReimplement Qt methodN)r   ÚresizeEventr  r¯   )r]   rª   r4   r4   r5   rB  +  s    zTourTestWindow.resizeEventc             C   s   t  | |¡ | j |¡ dS )zReimplement Qt methodN)r   Ú	moveEventr  r¯   )r]   rª   r4   r4   r5   rC  0  s    zTourTestWindow.moveEvent)r*   r+   r,   r-   r   r  r  rK   r@  rA  rB  rC  r   r4   r4   )ra   r5   r<  î  s   ,r<  c              C   s"   t g ƒ} tƒ }| ¡  |  ¡  dS )rb   N)r   r<  rm   Zexec_)Zappr  r4   r4   r5   rH   6  s    rH   Ú__main__)N)7r-   Z
__future__r   r   Zqtpy.QtCorer   r   r   r   r   r   Z
qtpy.QtGuir	   r
   r   r   r   r   r   r   Zqtpy.QtWidgetsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Zspyder.config.baser    r!   Zspyder.py3compatr"   Zspyder.utils.qthelpersr#   r$   Úobjectr%   r8   r6   rI   r€   r¹   r  r<  rH   r*   r4   r4   r4   r5   Ú<module>   s4    (D
 Gk   B   "H
