a
    ¨ˆc  ã                   @   sP   d Z ddlmZ ddlmZmZmZmZ ddlm	Z	 ee	ƒG dd„ deƒƒZ
dS )	ú! A page in a preferences dialog. é    )ÚPreferencesHelper)ÚAnyÚDictÚStrÚprovidesé   )ÚIPreferencesPagec                   @   s<   e Zd ZdZeZeZeZeZ	e
Zdd„ Zdd„ Zdd„ ZdS )	ÚPreferencesPager   c                 C   sJ   |   ¡ }| j ¡ D ](\}}|  |¡r| j d||f |¡ q| j ¡  dS )z Apply the page's preferences. z%s.%sN)Ú	_get_pathÚ_changedÚitemsÚ_is_preference_traitZpreferencesÚsetÚclear)ÚselfÚpathÚ
trait_nameÚvalue© r   úk/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/apptools/preferences/ui/preferences_page.pyÚapply8   s
    
zPreferencesPage.applyc                 C   sJ   |   |¡r|| j|< n0| d¡rF|dd… }|   |¡rFt| |ƒ| j|< dS )aQ  Static trait change handler.

        This is an important override! In the base-class when a trait is
        changed the preferences node is updated too. Here, we stop that from
        happening and just make a note of what changes have been made. The
        preferences node gets updated when the 'apply' method is called.

        Z_itemsNiúÿÿÿ)r   r   ÚendswithÚgetattr)r   r   ÚoldÚnewr   r   r   Ú_anytrait_changedI   s    



z!PreferencesPage._anytrait_changedc                 C   s0   |  d¡s | d¡s |t ¡ v r$dS ||  ¡ v S )z7 Return True if a trait represents a preference value. Ú_F)Ú
startswithr   r
   Zclass_traitsZeditable_traits)r   r   r   r   r   r   ^   s    ÿþ
ýz$PreferencesPage._is_preference_traitN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚcategoryZhelp_idÚnamer   Z_uir   r   r   r   r   r   r   r   r   r
      s   	r
   N)r"   Zapptools.preferences.apir   Z
traits.apir   r   r   r   Zi_preferences_pager	   r
   r   r   r   r   Ú<module>
   s
   