• Home
  • Cart
MenuClose Menu
  • Home
  • Projects
  • Blog
  • Contact
  • About
  • Store
  1. Projects
  2. Enaml native
  3. Docs
  4. 5.0.0
  5. Widgets
  6. Popupwindow

enaml-native

Navigation

  • App
  • Widgets
    • Activity
    • ActivityIndicator
    • AppBarLayout
    • AutoCompleteTextView
    • BottomSheetDialog
    • Button
    • CalendarView
    • CameraView
    • CardView
    • CheckBox
    • Chronometer
    • CompoundButton
    • CoordinatorLayout
    • DatePicker
    • Dialog
    • DrawerLayout
    • EditText
    • Flexbox
    • FloatingActionButton
    • Fragment
    • FrameLayout
    • GridLayout
    • Icon
    • IconButton
    • IconToggleButton
    • ImageButton
    • ImageView
    • LinearLayout
    • ListItem
    • ListView
    • Notification
    • PagerFragment
    • PagerTabStrip
    • PagerTitleStrip
    • Picker
    • PopupWindow
    • ProgressBar
    • RadioButton
    • RadioGroup
    • RatingBar
    • RelativeLayout
    • ScrollView
    • SeekBar
    • Snackbar
    • Spinner
    • SurfaceView
    • SwipeRefreshLayout
    • Switch
    • TabFragment
    • TabLayout
    • TextClock
    • TextView
    • TextureView
    • TimePicker
    • Toast
    • ToggleButton
    • Toolbar
    • VideoView
    • View
    • ViewGroup
    • ViewPager
    • WebView
    • Window
  • Native APIs
  • Bridge

Related Topics

  • Documentation overview
    • Widgets
      • Previous: Picker
      • Next: ProgressBar

Quick search

PopupWindow¶

Screenshot¶

Popupwindow - Reference - Enaml-native - CodeLV

Example¶

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

enamldef ContextMenu(PopupWindow): popup:
    attr items = []
    attr result = lambda r:r
    ScrollView:
        LinearLayout:
            orientation = 'vertical'
            background_color = "#FFF"
            Looper:
                iterable << popup.items
                Button:
                    flat = True
                    text = loop_item
                    clicked ::
                        popup.result(self.text)
                        popup.show = False


enamldef ContentView(LinearLayout): drawer:
    orientation = 'vertical'
    AppBarLayout: app_bar:
        height = "wrap_content"
        Toolbar:
            height = "wrap_content"
            content_padding = (0,0,0,0)
            Flexbox:
                justify_content = "space_between"
                Button:
                    flat = True
                    text = "Menu"
                    clicked :: self.children[0].show = True
                    ContextMenu:
                        gravity="bottom|right"
                        x=-20
                        items = ["One", "Two", "Three"]
                Button:
                    flat = True
                    text = "Settings"
                    clicked :: ContextMenu(
                                    parent=self,
                                    x=-20,
                                    items=["A", "B"]).popup()
    Button:
        text = "Popup in center"
        clicked ::  self.children[0].show = True
        PopupWindow:
            gravity = "center_horizontal|center_vertical"
            position = 'absolute'
            LinearLayout:
                padding = (20, 20, 20, 20)
                TextView:
                    text = "Volume"
                SeekBar:
                    width = 200

Declaration¶

class enamlnative.widgets.popup_window.PopupWindow(parent=None, **kwargs)[source]¶

Bases: enaml.widgets.toolkit_object.ToolkitObject

A popup window that may contain a view.

width¶

Width and height or a string “match_parent” or “fill_parent”

gravity¶

Layout gravity

x¶

Position

focusable¶

Set whether the popup window can be focused

touchable¶

Set whether the popup is touchable

outside_touchable¶

Controls whether the pop-up will be informed of touch events outside of its window.

show¶

Start the popup and display it on screen (or hide if False)

background_color¶

Background color of the window (white by default)

position¶

If relative, show as a dropdown on the parent view, otherwise show at the position given by x and y.

animation¶

Animation style for the PopupWindow using the @style format (ex. @style/MyAnimation

style¶

PopupWindow style using the @style format (ex. @style/Theme_Light_NoTitleBar_Fullscreen

proxy¶

A reference to the proxy object.

popup()[source]¶

Show the window from code. This will initialize and activate if needed.

Examples

>>> enamldef ContextMenu(PopupWindow): popup:
      attr result: lambda text: None
      Button:
        text = "One"
        clicked ::
          dialog.show = False
          dialog.result(self.text)
      Button:
        text = "Two"
        clicked ::
          dialog.show = False
          dialog.result(self.text)
    def on_result(value):
      print("User clicked: {}".format(value))
    ContextMenu(result=on_result).popup()

Notes

This does NOT block. Callbacks should be used to handle click events or the show state should be observed to know when it is closed.

Android Implementation¶

class enamlnative.android.android_popup_window.AndroidPopupWindow[source]¶

Bases: enamlnative.android.android_toolkit_object.AndroidToolkitObject, enamlnative.widgets.popup_window.ProxyPopupWindow

An Android implementation of an Enaml ProxyPopupWindow.

window¶

A reference to the widget created by the proxy.

showing¶

Whether the popup has been shown

create_widget()[source]¶

Create the underlying widget.

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

init_widget()[source]¶

Set the listeners

init_layout()[source]¶

If a view is given show it

child_added(child)[source]¶

Overwrite the content view

destroy()[source]¶

A reimplemented destructor that cancels the dialog before destroying.

update()[source]¶

Update the PopupWindow if it is currently showing. This avoids calling update during initialization.

No iOS implementation found.

Pages
  • Home
  • Projects
  • Blog
  • Contact
  • About
  • Store
Projects
  • Inkcut
  • DeclaraCAD
  • Inventory
  • Zerobooks
Connect
  • Github
  • Stack Overflow
Resources
  • Dev music
  • Live debt free
  • For the commute
  • For the kids

© 2017-2025 CodeLV All rights reserved.

Built with enaml-web