Toast

Screenshot

Toast - Reference - Enaml-native - CodeLV

Example

from enamlnative.widgets.api import *

enamldef ContentView(Flexbox):
    flex_direction = "column"
    Button:
        text = "Show toast"
        clicked ::
            toast.show = True
    TextView:
        text << "Toast: {}".format("active" if toast.show else "hidden")
    Button:
        text = "Show custom toast"
        clicked ::
            toast2.show = True

    Toast: toast:
        text = "Cheers!"

    Toast: toast2:
        #: Time in ms to flash
        duration = 5000
        #: Custom component
        CardView: card:
            background_color = "#555"
            radius = 10
            Flexbox:
                align_items = "center"
                padding = (20, 10, 20, 10)
                Icon:
                    text_color = "#fff"
                    text = "{md-check}"
                TextView:
                    padding = (10, 10, 10, 10)
                    text = "PAGE ADDED"
                    text_color = "#fff"

Declaration

class enamlnative.widgets.toast.Toast(parent=None, **kwargs)[source]

Bases: enaml.widgets.toolkit_object.ToolkitObject

A toast is a view containing a quick little message for the user.

text

Text to display if this node has a child view this is ignored

duration

Duration to display in ms

x

x position

y

y position

gravity

Position

show

Show the notification for the given duration

proxy

A reference to the proxy object.

Android Implementation

class enamlnative.android.android_toast.AndroidToast[source]

Bases: enamlnative.android.android_toolkit_object.AndroidToolkitObject, enamlnative.widgets.toast.ProxyToast

An Android implementation of an Enaml ProxyToast.

toast

A reference to the widget created by the proxy.

made_toast

Made toast Android doesn’t let us simply update the text of an existing toast unless it was created with “makeToast”

create_widget()[source]

Create the underlying widget.

A toast is not a subclass of view, hence we don’t set name as widget or children will try to use it as their parent (which crashes).

init_widget()[source]

Our widget may not exist yet so we have to diverge from the normal way of doing initialization. See update_widget

init_layout()[source]

If a view is given show it

child_added(child)[source]

Overwrite the view

on_make_toast(f: _asyncio.Future)[source]

Using Toast.makeToast returns async so we have to initialize it later.

set_duration(duration: int)[source]

Android for whatever stupid reason doesn’t let you set the time it only allows 1-long or 0-short. So we have to repeatedly call show until the duration expires, hence this method does nothing see set_show.

No iOS implementation found.