DrawerLayout

Screenshot

Drawerlayout - Reference - Enaml-native - CodeLV

Example

from enamlnative.core.api import *
from enamlnative.widgets.api import *

enamldef Drawer(ScrollView): view:
    #: Must have gravity AND width
    width = 200
    attr side = 'left'
    gravity << side # Use an attr since this gets converted to an int
    background_color = "#fff"
    Flexbox:
        flex_direction = "column"
        Looper:
            iterable = range(20)
            Button:
                flat = True
                text = "{} {}".format(view.side, loop_index)

enamldef ContentView(DrawerLayout): drawer:
    background_color = "#eee"
    Flexbox:
        flex_direction = "column"
        Toolbar:
            title = "Drawers"
            subtitle = "Swipe to open drawers"
            background_color = "#abc"
        Button:
            text = "Open left"
            #: Set the `opened` attribute to the list of drawers
            clicked :: drawer.opened = [left_drawer]
        Button:
            text = "Open right"
            clicked :: drawer.opened = [right_drawer]
        Button:
            text = "Close all"
            #: Set the `opened` attribute to an empty list to close all
            clicked :: drawer.opened = []

    Drawer: left_drawer:
        side = "left"
    Drawer: right_drawer:
        side = "right"

Declaration

class enamlnative.widgets.drawer_layout.DrawerLayout(parent=None, **kwargs)[source]

Bases: enamlnative.widgets.view_group.ViewGroup

A simple control for displaying a drawer

opened

List of opened drawers

drawer_width

Drawer width

title

Title of drawer

title_gravity

Gravity of title

drawer_elevation

Elevation

lock_mode

Set lock mode

scrim_color

Set a color to use for the scrim that obscures primary content while a drawer is open.

status_bar_background_color

Statusbar background color

proxy

A reference to the ProxyLabel object.

Android Implementation

class enamlnative.android.android_drawer_layout.AndroidDrawerLayout[source]

Bases: enamlnative.android.android_view_group.AndroidViewGroup, enamlnative.widgets.drawer_layout.ProxyDrawerLayout

An Android implementation of an Enaml ProxyDrawerLayout.

widget

A reference to the widget created by the proxy.

drawer_state

Drawer state

layout_param_type

Children use DrawerLayoutParams

create_widget()[source]

Create the underlying widget.

init_widget()[source]

Initialize the underlying widget.

init_layout()[source]

Add all child widgets to the view

set_opened(opened)[source]

Opened is a tuple of the drawer sides that are open

create_layout_params(child, layout)[source]

Create the LayoutParams for a child with it’s requested layout parameters. Subclasses should override this as needed to handle layout specific needs.

Parameters
  • child (AndroidView) – A view to create layout params for.

  • layout (Dict) – A dict of layout parameters to use to create the layout.

Returns

layout_params – A LayoutParams bridge object with the requested layout options.

Return type

LayoutParams

No iOS implementation found.