3
ÌœŸW+  ã               @   sŠ   d Z ddlmZ ddlZddlmZ ddlmZmZ ddl	m
Z
mZmZ ddlmZmZmZ ddlmZmZ d	ZG d
d„ deƒZeƒ ZdS )ar  A preference manager for all mayavi related preferences.

The idea behind this module is that it lets the mayavi
library/application use the same preferences by managing them no matter
if mayavi is used as an application (via envisage3) or as a library.

The preferences helpers are divided into different categories for
different kinds of preferences.  Currently the following are available.

  - root: for global mayavi preferences of the form
    'mayavi.preference'.

For more details on the general preferences support in enthought, please
read the documentation for apptools.preferences (part of the AppTools
package).

é    )ÚjoinN)Ú	ETSConfig)Ú	HasTraitsÚInstance)ÚViewÚGroupÚItem)ÚScopedPreferencesÚIPreferencesÚPreferencesHelper)ÚRootPreferencesHelperÚMlabPreferencesHelperÚ	mayavi_e3c            	       sœ   e Zd ZeeƒZeeƒZeeƒZe	e
e
eddd�dddd�e
eddd�dd	dd�ƒd
dgdd�Z‡ fdd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Z‡  ZS )ÚPreferenceManagerÚrootÚcustom)ÚnameÚstyleFÚRootT)Úshow_labelsÚlabelÚshow_borderÚmlabÚMlabÚOKÚCancel)ÚbuttonsÚ	resizablec                s&   t t| ƒjf |Ž d|kr"| jƒ  d S )NÚpreferences)Úsuperr   Ú__init__Ú_load_preferences)ÚselfÚtraits)Ú	__class__© úh/home/yuhw/wc/wire-cell-python/venv/lib/python3.6/site-packages/mayavi/preferences/preference_manager.pyr    M   s    zPreferenceManager.__init__c             C   s   t ƒ S )zTrait initializer.)r	   )r"   r%   r%   r&   Ú_preferences_defaultS   s    z&PreferenceManager._preferences_defaultc             C   s   t | jd�S )zTrait initializer.)r   )r   r   )r"   r%   r%   r&   Ú_root_defaultW   s    zPreferenceManager._root_defaultc             C   s   t | jd�S )zTrait initializer.)r   )r   r   )r"   r%   r%   r&   Ú_mlab_default[   s    zPreferenceManager._mlab_defaultc             C   sn   t jƒ }tt jƒ tƒ}|t _zDx>dD ]6}d}tj||ƒ}| j}|j	dƒ}|j
|ƒ |jƒ  q$W W d|t _X dS )zLoad the default preferences.úmayavi.preferencesútvtk.plugins.scenezpreferences.inizdefault/N)r*   r+   )r   Úget_application_homer   Úget_application_dataÚIDÚapplication_homeÚpkg_resourcesÚresource_streamr   ÚnodeÚloadÚclose)r"   Úapp_homeÚpathÚpkgÚprefÚ	pref_filer   Údefaultr%   r%   r&   r!   b   s    

z#PreferenceManager._load_preferencesc             C   s   x| j fD ]
}||_q
W dS )z3Setup the helpers if the preferences trait changes.N)r   r   )r"   r   Úhelperr%   r%   r&   Ú_preferences_changedw   s    z&PreferenceManager._preferences_changed)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r
   r   r   r   r   Útraits_viewr    r'   r(   r)   r!   r<   Ú__classcell__r%   r%   )r$   r&   r   ,   s$   r   )Ú__doc__Úos.pathr   r0   Útraits.etsconfig.apir   Ú
traits.apir   r   Útraitsui.apir   r   r   Úapptools.preferences.apir	   r
   r   Ú&mayavi.preferences.preferences_helpersr   r   r.   r   Úpreference_managerr%   r%   r%   r&   Ú<module>   s   T