3
8Ad]ö  ã               @   s:  d Z ddlmZmZ ddlZddlZddlZddlmZ ddl	m
Z
 ddlmZmZmZmZmZ ddlmZ ddlmZ dd	lT dd
lmZ edƒržejdƒ‚edddd�ZG dd„ deƒZdd„ Zdd„ Zdd„ Zedd„ ƒZedd„ ƒZedd„ ƒZ ej!e" dƒe#d d!„ ƒƒZ$e#d"d#„ ƒZ%e&d$k�r6eƒ Z'e'j(ƒ  dS )%z3
Test that menu and toolbar actions are triggered.
é    )Úabsolute_importÚprint_functionN)Ú	HasTraits)ÚBool)ÚActionÚActionGroupÚMenuÚMenuBarÚToolBar)ÚItem)ÚView)Ú*)Ú_is_current_backendZnullz$Not supported using the null backendZTestÚtest_clickedzClick to test)ÚnameÚactionZtooltipc               @   sd   e Zd ZdZedƒZdd„ Zeee	e
ƒdd�ƒZee	e
ƒƒZeedd�ed	d
d�eee
dgd�ZdS )ÚDialogWithToolbarz"Test dialog with toolbar and menu.Fc             C   s   t dƒ d| _d S )Nzperform actionT)ÚprintÚaction_successful)Úself© r   úw/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/traitsui-6.1.2-py3.6.egg/traitsui/tests/test_actions.pyr   2   s    zDialogWithToolbar.test_clickedz
&Test menu)r   zfClick the button on the toolbar or the menu item.
The 'Action successful' element should turn to True.)Úlabelr   Úreadonly)ÚstyleÚOK)ÚmenubarÚtoolbarÚbuttonsN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r	   r   r   Ú
TestActionr   r
   r   r   r   Ztraits_viewr   r   r   r   r   -   s   


r   c          	   C   s:   t ƒ �* tƒ }|jƒ }| |ƒ tjj|jƒ W dQ R X dS )z:Template test for wx, qt4, menu, and toolbar testing.
    N)Zstore_exceptions_on_all_threadsr   Zedit_traitsÚnoseÚtoolsZassert_truer   )Ztrigger_action_funcZdialogÚuir   r   r   Ú_test_actionsK   s
    r'   c             C   s$   |j j| ƒ}|jƒ d }|jƒ  d S )Nr   )ÚcontrolÚ	findChildÚactionsZtrigger)Zcontainer_classr&   r   r   r   r   r   Ú_qt_trigger_action_   s    r+   c             C   s<   ddl m} | jj|ƒ}|jƒ d }t|jƒ ƒ |jƒ  d S )Nr   )ÚQDialogButtonBoxé   )Zpyface.qt.QtGuir,   r(   r)   r   r   ÚtextZclick)r&   r,   ZbboxÚbuttonr   r   r   Ú_qt_click_buttone   s
    r0   c              C   s    t ttjjjjjƒ} t| ƒ d S )N)	Úpartialr+   Úpyfacer&   Úqt4r   Ztool_bar_managerZ_ToolBarr'   )Zqt_trigger_toolbar_actionr   r   r   Útest_qt_toolbar_actionm   s    	r4   c              C   s    t ttjjjjjƒ} t| ƒ d S )N)	r1   r+   r2   r&   r3   r   Zmenu_managerZ_Menur'   )Zqt_trigger_menu_actionr   r   r   Útest_qt_menu_action|   s    	r5   c               C   s   t tƒ d S )N)r'   r0   r   r   r   r   Útest_qt_button_action‹   s    	r6   zIProblem with triggering toolbar actions on Linux and Windows. Issue #428.c                 s    dd l ‰ ‡ fdd„} t| ƒ d S )Nr   c                sL   | j jjd jd }|jd }|j}ˆ jˆ j|ƒ}| jj	dƒ}|j
|ƒ d S )Nr   r   )Úviewr   ÚgroupsÚitemsZ	_wrappersÚ
control_idÚCommandEventZwxEVT_COMMAND_TOOL_CLICKEDr(   ZFindWindowByNameÚProcessEvent)r&   Ztoolbar_itemZtoolbar_item_wrapperr:   Úclick_eventr   )Úwxr   r   Ú_wx_trigger_toolbar_action¤   s    
z:test_wx_toolbar_action.<locals>._wx_trigger_toolbar_action)r>   r'   )r?   r   )r>   r   Útest_wx_toolbar_action™   s    	r@   c                 s    dd l ‰ ‡ fdd„} t| ƒ d S )Nr   c                sL   | j jƒ jƒ d jƒ }|jƒ d jƒ }|jƒ }ˆ jˆ j|ƒ}| j j|ƒ d S )Né   r   )r(   ZGetSizerÚGetChildrenÚ	GetWindowÚGetIdr;   ZwxEVT_COMMAND_BUTTON_CLICKEDr<   )r&   Zbutton_sizerr/   r:   r=   )r>   r   r   Ú_wx_trigger_button_action»   s
    z8test_wx_button_action.<locals>._wx_trigger_button_action)r>   r'   )rE   r   )r>   r   Útest_wx_button_action´   s    rF   Ú__main__))r"   Ú
__future__r   r   r$   r2   ÚunittestZtraits.has_traitsr   Ztraits.trait_typesr   Ztraitsui.menur   r   r   r	   r
   Ztraitsui.itemr   Ztraitsui.viewr   Ztraitsui.tests._toolsr   ÚSkipTestr#   r   r'   r+   r0   Zskip_if_not_qt4r4   r5   r6   ÚskipIfZ	is_mac_osZskip_if_not_wxr@   rF   r   ZvwZconfigure_traitsr   r   r   r   Ú<module>   s@   

