How to use the enaml.core.declarative.d_ function in enaml

To help you get started, we’ve selected a few enaml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nucleic / enaml / enaml / widgets / page.py View on Github external
A Page is a widget which can be used as a child of a Notebook
    control. It can have at most a single child widget which is an
    instance of Container.

    """
    #: The title to use for the page in the notebook.
    title = d_(Str())

    #: The icon to use for the page tab.
    icon = d_(Typed(Icon))

    #: Whether or not this individual page is closable. Note that the
    #: 'tabs_closable' flag on the parent Notebook must be set to True
    #: for this to have any effect.
    closable = d_(Bool(True))

    #: An event fired when the user closes the page by clicking on
    #: the tab's close button.
    closed = d_(Event(), writable=False)

    #: A reference to the ProxyPage object.
    proxy = Typed(ProxyPage)

    def page_widget(self):
        """ Get the page widget defined for the page.

        The last child Container is the page widget.

        """

        for child in reversed(self.children):
github nucleic / enaml / enaml / widgets / status_bar.py View on Github external
def show_message(self, message, timeout=0):
        raise NotImplementedError

    def clear_message(self):
        raise NotImplementedError


class StatusBar(Widget):
    """ A widget used as a status bar in a MainWindow.

    A status bar can be used to display temporary messages or display
    persistent widgets by declaring StatusItem children.

    """
    #: Whether or not the size grip in the right corner is enabled.
    size_grip_enabled = d_(Bool(True))

    #: A reference to the ProxyStatusBar object.
    proxy = Typed(ProxyStatusBar)

    def status_items(self):
        """ Get the list of status items defined on the status bar.

        """
        return [c for c in self.children if isinstance(c, StatusItem)]

    #--------------------------------------------------------------------------
    # Observers
    #--------------------------------------------------------------------------
    @observe('size_grip_enabled')
    def _update_proxy(self, change):
        """ Update the proxy when the status bar data changes.
github ContinuumIO / ashiba / enaml / core / include.py View on Github external
from .object import Object


class Include(Declarative):
    """ An object which dynamically inserts children into its parent.

    The 'Include' object is used to cleanly and easily insert objects
    into the children of its parent. 'Object' instances assigned to the
    'objects' list of the 'Include' will be parented with the parent of
    the 'Include'. Creating an 'Include' with no parent is a programming
    error.

    """
    #: The list of objects belonging to this Include. Objects in this
    #: list will be automatically parented with the Include's parent.
    objects = d_(ContainerList(Object))

    #: A boolean flag indicating whether to destroy the old objects that
    #: are removed from the parent. The default is True.
    destroy_old = d_(Bool(True))

    def initialize(self):
        """ A reimplemented initializer.

        This method will add the include objects to the parent of the
        include and ensure that they are initialized.

        """
        super(Include, self).initialize()
        self.parent.insert_children(self, self.objects)
        for obj in self.objects:
            obj.initialize()
github codelv / enaml-native / src / enamlnative / widgets / map_view.py View on Github external
color = d_(Unicode())

    #: Sets the cap at the end vertex of the polyline
    end_cap = d_(Enum('butt', 'round', 'square'))

    #: Specifies whether to draw each segment of this polyline as a geodesic
    geodesic = d_(Bool())

    #: Sets the joint type for all vertices of the polyline except the start and end vertices.
    joint_type = d_(Enum('', 'bevel', 'round'))

    #: Sets the cap at the start vertex of the polyline
    start_cap = d_(Enum('butt', 'round', 'square'))

    #: Sets the visibility for the marker.
    visible = d_(Bool(True))

    #: Sets the width of the polyline in screen pixels.
    width = d_(Float(10, strict=False))

    #: Sets the zIndex for the marker.
    zindex = d_(Float(strict=False))

    #: Line clicked
    #: event value will have a 'result' that can be set to True
    #: to indicate the event was handled
    clicked = d_(Event(dict), writable=False)

    #: A reference to the proxy object.
    proxy = Typed(ProxyMapPolyline)

    @observe('points', 'clickable', 'color', 'end_cap', 'geodesic',
github nucleic / enaml / enaml / widgets / styling.py View on Github external
"""
    #: The type name of the element which will match the rule set. A
    #: comma separated string can be used to match more than one
    #: element. An empty string will match all elements.
    element_name = d_(Unicode())

    #: The name of the widget style class which will match the rule set.
    #: A comma separated string can be used to match more than one style
    #: class. An empty string will match all style classes.
    style_class = d_(Unicode())

    #: The object name of the widget which will match the rule set. A
    #: comma separated string can be used to match more than one object
    #: name. An empty string will match all object names.
    object_name = d_(Unicode())

    #: The pseudostate to which the style applies. A comma separated
    #: string can be used to match more than one pseudostate. An empty
    #: string will match all pseudostates. The pseudostates supported
    #: by a widget are toolkit dependent.
    pseudostate = d_(Unicode())

    #: The subcontrol to which the style applies. A comma separated
    #: string can be used to match more than one subcontrol. An empty
    #: string indicates no subcontrol. The subcontrols supported by a
    #: widget are toolkit dependent.
    subcontrol = d_(Unicode())

    #: The private cached tuple of element names.
    _elements = Typed(tuple)
github codelv / enaml-native / src / enamlnative / widgets / progress_bar.py View on Github external
class ProgressBar(View):
    """ A simple control for displaying a ProgressBar.

    """
    #: Sets the current progress to the specified value.
    progress = d_(Int())

    #: Sets the current progress to the specified value.
    secondary_progress = d_(Int())

    #: Change the indeterminate mode for this progress bar.
    #: In indeterminate mode, the progress is ignored and the progress
    #: bar shows an infinite animation instead.

    #: Set the upper range of the progress bar max.
    max = d_(Int())

    #: Set the lower range of the progress bar
    min = d_(Int())

    #: A reference to the ProxyProgressBar object.
    proxy = Typed(ProxyProgressBar)

    # -------------------------------------------------------------------------
    # Observers
    # -------------------------------------------------------------------------
    @observe('progress', 'secondary_progress', 'max', 'min')
    def _update_proxy(self, change):
        """ An observer which sends the state change to the proxy.

        """
        # The superclass implementation is sufficient.
github codelv / enaml-native / android / app / src / main / assets / python / enamlnative / widgets / view.py View on Github external
pivot_x = d_(Float())

    pivot_y = d_(Float())

    pressed = d_(Bool())

    right = d_(Int())

    rotation = d_(Float())

    rotation_x = d_(Float())

    rotation_y = d_(Float())

    save_enabled = d_(Bool())

    save_from_parent_enabled = d_(Bool())

    scale_x = d_(Float())

    scale_y = d_(Float())

    scroll_bar_default_delay_before_fade = d_(Int())

    scroll_bar_fade_duration = d_(Int())

    scroll_bar_size = d_(Int())

    scroll_bar_style = d_(Int())

    scroll_container = d_(Bool())
github codelv / enaml-native / src / enamlnative / widgets / map_view.py View on Github external
"""
        if change['type'] == 'container':
            #: Only update what's needed
            self.proxy.update_points(change)
        else:
            super(MapPolyline, self)._update_proxy(change)


class MapPolygon(ToolkitObject):
    """ A polygon on the map. """

    #: Sets the alpha (opacity) of the marker.
    points = d_(ContainerList(tuple))

    #: Specifies whether this polygon is clickable.
    clickable = d_(Bool())

    #: Adds a holes to the polygon being built.
    #: May be a list of coordinates or multiple coordinate lists
    holes = d_(ContainerList(tuple))

    #: Sets the fill color of the polygon
    fill_color = d_(Unicode())

    #: Specifies whether to draw each segment of this polyline as a geodesic
    geodesic = d_(Bool())

    #: Sets the color of the polygon
    stroke_color = d_(Unicode())

    #: Sets the joint type for all vertices of the polyline except the start and end vertices.
    stroke_joint_type = d_(Enum('', 'bevel', 'round'))
github nucleic / enaml / enaml / widgets / item.py View on Github external
The self reference to allow method chaining.

        """
        self.text_alignment = TextAlignment.Center
        return self


class Item(Declarative):
    """ An object representing an item in an item model.

    An Item encapsulates a data value and the styling information for
    rendering that value to the screen.

    """
    #: The data value for the item. The default value is None.
    data = d_(Value())

    #: The check state for the item. The default value is None.
    check_state = d_(Enum(None, CheckState.Unchecked, CheckState.Checked))

    #: The flags for the item. The default is selectable and enabled.
    item_flags = d_(Int(ItemFlag.Selectable | ItemFlag.Enabled))

    #: The style to use for the item. The default value is None.
    style = d_(Typed(Style))

    #: The unicode tool tip for the item.
    tool_tip = d_(Unicode())

    #: The unicode status tip for the item.
    status_tip = d_(Unicode())
github inkcut / inkcut / src / inkcut / workbench / ui / widgets / table_view.py View on Github external
class ProxyTableView(ProxyControl):
    declaration = ForwardTyped(lambda: TableView)
    
    def set_model(self, model):
        raise NotImplementedError

class TableView(Control):
    hug_width = set_default('ignore')
    hug_height = set_default('ignore')
    proxy = Typed(ProxyTableView)
    model = d_(Typed(QAbstractTableModel))
    auto_scroll = d_(Bool(True))
    stretch_last_section = d_(Bool(False))
    selected = d_(Callable(lambda selected,deselected:None))
    selection_mode = d_(Enum(QtGui.QAbstractItemView.SingleSelection,
                             QtGui.QAbstractItemView.MultiSelection,
                             QtGui.QAbstractItemView.NoSelection))
    
    setup = d_(Callable(lambda table_view:None))
    
    @observe('model')
    def _update_proxy(self, change):
        """ An observer which sends state change to the proxy.
        """
        # The superclass handler implementation is sufficient.
        super(TableView, self)._update_proxy(change)
        
    @observe('stretch_last_section')            
    def _update_resize(self,change):
        self.proxy.widget.horizontalHeader().setStretchLastSection(self.stretch_last_section)