a
    «ˆc+  ã                   @   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ÚMlabPreferencesHelperZ	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ÚrootZcustom)ÚnameÚstyleFZRootT)Zshow_labelsÚlabelZshow_borderÚmlabZMlabÚOKZCancel)ZbuttonsZ	resizablec                    s*   t t| ƒjf i |¤Ž d|vr&|  ¡  d S )NÚpreferences)Úsuperr   Ú__init__Ú_load_preferences)ÚselfZtraits©Ú	__class__© úh/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/mayavi/preferences/preference_manager.pyr   M   s    zPreferenceManager.__init__c                 C   s   t ƒ S )úTrait initializer.)r	   ©r   r   r   r   Ú_preferences_defaultS   s    z&PreferenceManager._preferences_defaultc                 C   s   t | jd�S ©r   )r   )r   r   r   r   r   r   Ú_root_defaultW   s    zPreferenceManager._root_defaultc                 C   s   t | jd�S r!   )r   r   r   r   r   r   Ú_mlab_default[   s    zPreferenceManager._mlab_defaultc                 C   sp   t  ¡ }tt  ¡ tƒ}|t _zFdD ]6}d}t ||¡}| j}| 	d¡}| 
|¡ | ¡  q"W |t _n|t _0 dS )zLoad the default preferences.)zmayavi.preferencesztvtk.plugins.scenezpreferences.inizdefault/N)r   Zget_application_homer   Zget_application_dataÚIDZapplication_homeÚpkg_resourcesÚresource_streamr   ÚnodeÚloadÚclose)r   Zapp_homeÚpathÚpkgZprefZ	pref_filer   Údefaultr   r   r   r   b   s    

z#PreferenceManager._load_preferencesc                 C   s   | j fD ]
}||_q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   Ztraits_viewr   r    r"   r#   r   r.   Ú__classcell__r   r   r   r   r   ,   s,   þþû
õr   )Ú__doc__Úos.pathr   r%   Ztraits.etsconfig.apir   Z
traits.apir   r   Ztraitsui.apir   r   r   Zapptools.preferences.apir	   r
   r   Z&mayavi.preferences.preferences_helpersr   r   r$   r   Zpreference_managerr   r   r   r   Ú<module>   s   T