enaml.widgets.popup_view
Classes
A widget which implements a nice popup view. |
- class enaml.widgets.popup_view.PopupView(parent=None, **kwargs)[source]
Bases:
Widget
A widget which implements a nice popup view.
A PopupView is a single-use transient widget that is automatically destroyed when it is closed. It is useful for showing contextual popup dialogs or notification messages.
- popup_views = []
Static class-level storage for the view instances. A view will automatically add and remove itself from this list as needed. This list prevents the need for the user to manage a strong reference to a transient popup.
- window_type
The type of the window to create. Each has different behavior. The window type cannot be changed after the widget is created.
- ‘popup’
This window will close when the user presses escape or clicks outside of the window. It will block all external interactions until it is closed.
- ‘tool_tip’
This window will close when the user clicks inside the window. It stays on top of all the other windows on the desktop. It is useful for showing mouse cursor or desktop notifications.
- ‘window’
This window will close when the user clicks inside the window. It stays on top of its parent, but not the other windows on the desktop. It is useful for notifications inside a window.
- anchor_mode
The mode to use for anchoring. The ‘parent’ mode uses a point on the parent or the desktop as the target anchor, the ‘cursor’ mode uses the current cursor position as the target anchor.
- parent_anchor
The relative position on the parent to use as the anchor. This anchor will be aligned with the view anchor to position the popup view. It is expressed as a percentage of the parent size. The default anchors will position the popup just below the center of the parent widget.
- anchor
The relative position on the view to use as the view anchor. This anchor will be aligned with the parent anchor to position the popup view. It is expressed as a percentage of the view size. The default anchors will position the popup just below the center of the parent widget.
- offset
The offset to apply between the two anchors, in pixels.
- arrow_edge
The edge of the popup view to use for rendering the arrow.
- arrow_size
The size of the arrow in pixels. If this value is > 0, the view anchor is taken to be the point of the arrow. If the arrow edge is ‘left’ or ‘right’, the anchor’s y-coordinate is used to set the arrow position, and the x-coordinate is ignored. If the arrow edge is ‘top’ or ‘bottom’, the anchor’s x-coordinate is used to set the arrow position, and the y-coordinate is ignored.
- timeout
The timeout, in seconds, before automatically closing the popup. A value less than or equal to zero means no timeout. This is typically useful when displaying non-interactive notifications.
- fade_in_duration
The duration of the fade-in, in milliseconds. A value less than or equal to zero means no fade.
- fade_out_duration
The duration of the fade-out, in milliseconds. A value less than or equal to zero means no fade.
- close_on_click
Whether or not close the popup view on a mouse click. For ‘popup’ windows, this means clicking outside of the view. For ‘tool_tip’ and ‘window’ windows, this means clicking inside of the view.
- translucent_background
Whether or not the background of the popup view is translucent. This must be True in order to use background colors with alpha and for the fade in and out animation to have effect. This value must be set before the popup view is shown. Changes to this value after the popup is shown will have no effect.
- closed
An event emitted when the view is closed. After this event is fired, the view will be destroyed and should not be used.
- visible
PopupViews are invisible by default.
- proxy
A reference to the ProxyPopupView object.
- arrow_position
This attribute is deprecated and will be removed in Enaml 1.0
- central_widget()[source]
Get the central widget defined on the PopupView.
The last Container child of the window is the central widget.
- show()[source]
Show the PopupView.
This is a reimplemented method which will intitialize the proxy tree before showing the view.
- close()[source]
Close the PopupView.
Closing the view, as opposed to hiding it or setting it’s visibility to False, will cause the ‘closed’ event to be emitted and the view to be destroyed.
- activated
An event fired when an object’s proxy is activated. It is triggered once during the object lifetime, at the end of the activate_proxy method.