3
8ßL]òF  ã               @   st   d Z ddlmZ ddlZddlmZ ddlmZmZ ej	e
ƒZdZdadd„ Zdd
d„Zdd„ ZG dd„ deƒZdS )a  
Defines the stub functions used for creating concrete implementations of
the standard EditorFactory subclasses supplied with the Traits package.

Most of the logic for determining which backend toolkit to use can now be
found in :py:mod:`pyface.base_toolkit`.
é    )Úabsolute_importN)Ú	ETSConfig)ÚToolkitÚfind_toolkitz/the '{}' toolkit does not implement this methodc             C   s*   t jr&t j| kr&td| d t jf ƒ‚dS )z_ Raise an error if a toolkit with the given name should not be allowed
    to be imported.
    z5Importing from %s backend after selecting %s backend!r   N)r   ÚtoolkitÚRuntimeError)Únames© r	   ú6/tmp/pip-install-5sebvq2j/traitsui/traitsui/toolkit.pyÚassert_toolkit_import&   s    r   Fc             C   s>   t dkrtƒ  t | ƒ}|r:|jdkr:tdjt| ƒt jƒƒ‚|S )aK   Return the toolkit specific object with the given name.

    Parameters
    ----------
    name : str
        The relative module path and the object name separated by a colon.
    raise_exceptions : bool
        Whether or not to raise an exception if the name cannot be imported.

    Raises
    ------
    TraitError
        If no working toolkit is found.
    RuntimeError
        If no ETSConfig.toolkit is set but the toolkit cannot be loaded for
        some reason.  This is also raised if raise_exceptions is True the
        backend does not implement the desired object.
    NZUnimplementedzCan't import {} for backend {})Ú_toolkitr   Ú__name__r   ÚformatÚrepr)ÚnameZraise_exceptionsÚobjr	   r	   r
   Útoolkit_object/   s    r   c              G   s,   t dkr(t| ƒdkr td| ƒa ntdƒa t S )at   Selects and returns a low-level GUI toolkit.

    Use this function to get a reference to the current toolkit.

    Parameters
    ----------
    *toolkits : strings
        Toolkit names to try if toolkit not already selected.  If not supplied,
        will try all ``traitsui.toolkits`` entry points until a match is found.

    Returns
    -------
    toolkit
        Appropriate concrete Toolkit subclass for selected toolkit.

    Raises
    ------
    TraitError
        If no working toolkit is found.
    RuntimeError
        If no ETSConfig.toolkit is set but the toolkit cannot be loaded for
        some reason.
    Nr   ztraitsui.toolkits)r   Úlenr   )Ztoolkitsr	   r	   r
   r   O   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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(d)„Zd*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ Zd6d7„ Zd8d9„ Zd:d;„ Zd<d=„ Z d>d?„ Z!d@dA„ Z"dBdC„ Z#dDdE„ Z$dFdG„ Z%dHdI„ Z&dJdK„ Z'dLdM„ Z(dNdO„ Z)dPdQ„ Z*dRdS„ Z+dTdU„ Z,dVdW„ Z-dXdY„ Z.dZd[„ Z/d\d]„ Z0d^d_„ Z1d`da„ Z2dbdc„ Z3ddde„ Z4dfdg„ Z5dhdi„ Z6djdk„ Z7dldm„ Z8dndo„ Z9dpdq„ Z:drds„ Z;dtdu„ Z<dvdw„ Z=dxdy„ Z>dzd{„ Z?d|d}„ Z@d~d„ ZAd€d�„ ZBd‚dƒ„ ZCd„d…„ ZDd†d‡„ ZEdˆd‰„ ZFdS )Œr   z+ Abstract base class for GUI toolkits.
    c             C   s   t tjtjƒƒ‚dS )z Creates a GUI-toolkit-specific panel-based user interface using
            information from the specified UI object.
        N)ÚNotImplementedErrorÚnot_implemented_messager   r   r   )ÚselfÚuiÚparentr	   r	   r
   Úui_panelz   s    zToolkit.ui_panelc             C   s   t tjtjƒƒ‚dS )z‚ Creates a GUI-toolkit-specific subpanel-based user interface using
            information from the specified UI object.
        N)r   r   r   r   r   )r   r   r   r	   r	   r
   Úui_subpanel�   s    zToolkit.ui_subpanelc             C   s   t tjtjƒƒ‚dS )zŽ Creates a GUI-toolkit-specific modal "live update" dialog user
            interface using information from the specified UI object.
        N)r   r   r   r   r   )r   r   r   r	   r	   r
   Úui_livemodalˆ   s    zToolkit.ui_livemodalc             C   s   t tjtjƒƒ‚dS )z’ Creates a GUI-toolkit-specific non-modal "live update" window user
            interface using information from the specified UI object.
        N)r   r   r   r   r   )r   r   r   r	   r	   r
   Úui_live�   s    zToolkit.ui_livec             C   s   t tjtjƒƒ‚dS )z€ Creates a GUI-toolkit-specific modal dialog user interface using
            information from the specified UI object.
        N)r   r   r   r   r   )r   r   r   r	   r	   r
   Úui_modal–   s    zToolkit.ui_modalc             C   s   t tjtjƒƒ‚dS )z„ Creates a GUI-toolkit-specific non-modal dialog user interface using
            information from the specified UI object.
        N)r   r   r   r   r   )r   r   r   r	   r	   r
   Úui_nonmodal�   s    zToolkit.ui_nonmodalc             C   s   t tjtjƒƒ‚dS )z˜ Creates a GUI-toolkit-specific temporary "live update" popup dialog
            user interface using information from the specified UI object.
        N)r   r   r   r   r   )r   r   r   r	   r	   r
   Úui_popup¤   s    zToolkit.ui_popupc             C   s   t tjtjƒƒ‚dS )z˜ Creates a GUI-toolkit-specific temporary "live update" popup dialog
            user interface using information from the specified UI object.
        N)r   r   r   r   r   )r   r   r   r	   r	   r
   Ú
ui_popover«   s    zToolkit.ui_popoverc             C   s   t tjtjƒƒ‚dS )z˜ Creates a GUI-toolkit-specific temporary "live update" popup dialog
            user interface using information from the specified UI object.
        N)r   r   r   r   r   )r   r   r   r	   r	   r
   Úui_info²   s    zToolkit.ui_infoc             C   s   t tjtjƒƒ‚dS )z� Creates a GUI-toolkit-specific wizard dialog user interface using
            information from the specified UI object.
        N)r   r   r   r   r   )r   r   r   r	   r	   r
   Ú	ui_wizard¹   s    zToolkit.ui_wizardNÚ c             C   s   t tjtjƒƒ‚dS )a¹   Creates a GUI-toolkit-specific modal dialog user interface that
            runs as a complete application using information from the
            specified View object.

        Parameters
        ----------
        context : object or dictionary
            A single object or a dictionary of string/object pairs, whose trait
            attributes are to be edited. If not specified, the current object is
            used.
        view : view or string
            A View object that defines a user interface for editing trait
            attribute values.
        kind : string
            The type of user interface window to create. See the
            **traitsui.view.kind_trait** trait for values and
            their meanings. If *kind* is unspecified or None, the **kind**
            attribute of the View object is used.
        handler : Handler object
            A handler object used for event handling in the dialog box. If
            None, the default handler for Traits UI is used.
        id : string
            A unique ID for persisting preferences about this user interface,
            such as size and position. If not specified, no user preferences
            are saved.
        scrollable : Boolean
            Indicates whether the dialog box should be scrollable. When set to
            True, scroll bars appear on the dialog box if it is not large enough
            to display all of the items in the view at one time.

        N)r   r   r   r   r   )r   ÚcontextÚviewÚkindÚhandlerÚidZ
scrollableÚargsr	   r	   r
   Úview_applicationÀ   s    !zToolkit.view_applicationc             C   s   t tjtjƒƒ‚dS )z@ Positions the associated dialog window on the display.
        N)r   r   r   r   r   )r   r   r	   r	   r
   Úpositionä   s    zToolkit.positionc             C   s   t tjtjƒƒ‚dS )z= Shows a Help window for a specified UI and control.
        N)r   r   r   r   r   )r   r   Úcontrolr	   r	   r
   Ú	show_helpê   s    zToolkit.show_helpc             C   s   t tjtjƒƒ‚dS )z+ Sets the title for the UI window.
        N)r   r   r   r   r   )r   r   r	   r	   r
   Ú	set_titleð   s    zToolkit.set_titlec             C   s   t tjtjƒƒ‚dS )z* Sets the icon for the UI window.
        N)r   r   r   r   r   )r   r   r	   r	   r
   Úset_iconö   s    zToolkit.set_iconc             C   s   t tjtjƒƒ‚dS )zH Saves user preference information associated with a UI window.
        N)r   r   r   r   r   )r   r   r	   r	   r
   Úsave_windowü   s    zToolkit.save_windowc             C   s   t tjtjƒƒ‚dS )z@ Rebuilds a UI after a change to the content of the UI.
        N)r   r   r   r   r   )r   r   r	   r	   r
   Ú
rebuild_ui  s    zToolkit.rebuild_uic             C   s   t tjtjƒƒ‚dS )zC Converts a keystroke event into a corresponding key name.
        N)r   r   r   r   r   )r   Úeventr	   r	   r
   Úkey_event_to_name  s    zToolkit.key_event_to_namec             C   s   t tjtjƒƒ‚dS )z‚ Hooks all specified events for all controls in a UI so that they
            can be routed to the correct event handler.
        N)r   r   r   r   r   )r   r   r,   Úeventsr'   r	   r	   r
   Úhook_events  s    zToolkit.hook_eventsc             C   s   t tjtjƒƒ‚dS )z@ Routes a "hooked" event to the corrent handler method.
        N)r   r   r   r   r   )r   r   r2   r	   r	   r
   Úroute_event  s    zToolkit.route_eventc             C   s   t tjtjƒƒ‚dS )z] Indicates that an event should continue to be processed by the
            toolkit.
        N)r   r   r   r   r   )r   r2   r	   r	   r
   Ú
skip_event  s    zToolkit.skip_eventc             C   s   t tjtjƒƒ‚dS )z3 Destroys a specified GUI toolkit control.
        N)r   r   r   r   r   )r   r,   r	   r	   r
   Údestroy_control"  s    zToolkit.destroy_controlc             C   s   t tjtjƒƒ‚dS )z\ Destroys all of the child controls of a specified GUI toolkit
            control.
        N)r   r   r   r   r   )r   r,   r	   r	   r
   Údestroy_children(  s    zToolkit.destroy_childrenc             C   s   t tjtjƒƒ‚dS )zi Returns a ( width, height ) tuple containing the size of a
            specified toolkit image.
        N)r   r   r   r   r   )r   Úimager	   r	   r
   Ú
image_size/  s    zToolkit.image_sizec             C   s   t tjtjƒƒ‚dS )zû Returns a dictionary of useful constants.

            Currently, the dictionary should have the following key/value pairs:

            - WindowColor': the standard window background color in the toolkit
              specific color format.
        N)r   r   r   r   r   )r   r	   r	   r
   Ú	constants6  s    zToolkit.constantsc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   Útraitsr	   r	   r
   Úcolor_traitE  s    zToolkit.color_traitc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úrgb_color_traitI  s    zToolkit.rgb_color_traitc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úrgba_color_traitM  s    zToolkit.rgba_color_traitc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Ú
font_traitQ  s    zToolkit.font_traitc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úkiva_font_traitU  s    zToolkit.kiva_font_traitc             C   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r	   r	   r
   Ú	ui_editor]  s    zToolkit.ui_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úarray_editore  s    zToolkit.array_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úboolean_editori  s    zToolkit.boolean_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úbutton_editorm  s    zToolkit.button_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úcheck_list_editorq  s    zToolkit.check_list_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úcode_editoru  s    zToolkit.code_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úcolor_editory  s    zToolkit.color_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úcompound_editor}  s    zToolkit.compound_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úcustom_editor�  s    zToolkit.custom_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Údirectory_editor…  s    zToolkit.directory_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Údrop_editor‰  s    zToolkit.drop_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Ú
dnd_editor�  s    zToolkit.dnd_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úenum_editor‘  s    zToolkit.enum_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úfile_editor•  s    zToolkit.file_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úfont_editor™  s    zToolkit.font_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úkey_binding_editor�  s    zToolkit.key_binding_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úhistory_editor¡  s    zToolkit.history_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úhtml_editor¥  s    zToolkit.html_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úimage_editor©  s    zToolkit.image_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úimage_enum_editor­  s    zToolkit.image_enum_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úinstance_editor±  s    zToolkit.instance_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úlist_editorµ  s    zToolkit.list_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úlist_str_editor¹  s    zToolkit.list_str_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Únull_editor½  s    zToolkit.null_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úordered_set_editorÁ  s    zToolkit.ordered_set_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úplot_editorÅ  s    zToolkit.plot_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úrange_editorÉ  s    zToolkit.range_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úrgb_color_editorÍ  s    zToolkit.rgb_color_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úrgba_color_editorÑ  s    zToolkit.rgba_color_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úshell_editorÕ  s    zToolkit.shell_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Útable_editorÙ  s    zToolkit.table_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Útabular_editorÝ  s    zToolkit.tabular_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Útext_editorá  s    zToolkit.text_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Útitle_editorå  s    zToolkit.title_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Útree_editoré  s    zToolkit.tree_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Útuple_editorí  s    zToolkit.tuple_editorc             O   s   t tjtjƒƒ‚d S )N)r   r   r   r   r   )r   r)   r=   r	   r	   r
   Úvalue_editorñ  s    zToolkit.value_editor)NNr#   NN)NN)Gr   Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r    r!   r"   r*   r+   r-   r.   r/   r0   r1   r3   r5   r6   r7   r8   r9   r;   r<   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   r	   r	   r	   r
   r   q   sŠ    
#
r   )F)rj   Ú
__future__r   ÚloggingZtraits.trait_baser   Zpyface.base_toolkitr   r   Ú	getLoggerr   Úloggerr   r   r   r   r   r	   r	   r	   r
   Ú<module>   s   
	
 "