enaml.widgets.widget
Classes
The base class of visible widgets in Enaml. |
- class enaml.widgets.widget.Widget(parent=None, **kwargs)[source]
Bases:
ToolkitObject
,Stylable
The base class of visible widgets in Enaml.
- enabled
Whether or not the widget is enabled.
- visible
Whether or not the widget is visible.
- background
The background color of the widget.
- foreground
The foreground color of the widget.
- font
The font used for the widget.
- minimum_size
The minimum size for the widget. The default means that the client should determine an intelligent minimum size.
- maximum_size
The maximum size for the widget. The default means that the client should determine an intelligent maximum size.
- tool_tip
The tool tip to show when the user hovers over the widget.
- status_tip
The status tip to show when the user hovers over the widget.
- features
Set the extra features to enable for this widget. This value must be provided when the widget is instantiated. Runtime changes to this value are ignored.
- proxy
A reference to the ProxyWidget object.
- restyle()[source]
Restyle the toolkit widget.
This method is invoked by the Stylable class when the style dependencies have changed for the widget. This will trigger a proxy restyle if necessary. This method should not typically be called directly by user code.
- show()[source]
Ensure the widget is shown.
Calling this method will also set the widget visibility to True.
- hide()[source]
Ensure the widget is hidden.
Calling this method will also set the widget visibility to False.
- set_focus()[source]
Set the keyboard input focus to this widget.
FOR ADVANCED USE CASES ONLY: DO NOT ABUSE THIS!
- clear_focus()[source]
Clear the keyboard input focus from this widget.
FOR ADVANCED USE CASES ONLY: DO NOT ABUSE THIS!
- has_focus()[source]
Test whether this widget has input focus.
FOR ADVANCED USE CASES ONLY: DO NOT ABUSE THIS!
- Returns:
result – True if this widget has input focus, False otherwise.
- Return type:
- focus_next_child()[source]
Give focus to the next widget in the focus chain.
FOR ADVANCED USE CASES ONLY: DO NOT ABUSE THIS!
- focus_previous_child()[source]
Give focus to the previous widget in the focus chain.
FOR ADVANCED USE CASES ONLY: DO NOT ABUSE THIS!
- next_focus_child(current)[source]
Compute the next widget which should gain focus.
When the FocusTraversal feature of the widget is enabled, this method will be invoked as a result of a Tab key press or from a call to the ‘focus_next_child’ method on a decendant of the owner widget. It should be reimplemented in order to provide custom logic for computing the next focus widget.
** The FocusTraversal feature must be enabled for the widget in order for this method to be called. **
- Parameters:
current (Widget or None) – The current widget with input focus, or None if no widget has focus or if the toolkit widget with focus does not correspond to an Enaml widget.
- Returns:
result – The next widget which should gain focus, or None to follow the default toolkit behavior.
- Return type:
Widget or None
- previous_focus_child(current)[source]
Compute the previous widget which should gain focus.
When the FocusTraversal feature of the widget is enabled, this method will be invoked as a result of a Shift+Tab key press or from a call to the ‘focus_prev_child’ method on a decendant of the owner widget. It should be reimplemented in order to provide custom logic for computing the previous focus widget.
** The FocusTraversal feature must be enabled for the widget in order for this method to be called. **
- Parameters:
current (Widget or None) – The current widget with input focus, or None if no widget has focus or if the toolkit widget with focus does not correspond to an Enaml widget.
- Returns:
result – The previous widget which should gain focus, or None to follow the default toolkit behavior.
- Return type:
Widget or None
- focus_gained()[source]
A method invoked when the widget gains input focus.
** The FocusEvents feature must be enabled for the widget in order for this method to be called. **
- focus_lost()[source]
A method invoked when the widget loses input focus.
** The FocusEvents feature must be enabled for the widget in order for this method to be called. **
- drag_start()[source]
A method called at the start of a drag-drop operation.
This method is called when the user starts a drag operation by dragging the widget with the left mouse button. It returns the drag data for the drag operation.
** The DragEnabled feature must be enabled for the widget in order for this method to be called. **
- Returns:
result – An Enaml DragData object which holds the drag data. If this is not provided, no drag operation will occur.
- Return type:
DragData
- drag_end(drag_data, result)[source]
A method called at the end of a drag-drop operation.
This method is called after the user has completed the drop operation by releasing the left mouse button. It is passed the original drag data object along with the resulting drop action of the operation.
** The DragEnabled feature must be enabled for the widget in order for this method to be called. **
- Parameters:
data (DragData) – The drag data created by the drag_start method.
result (DropAction) – The requested drop action when the drop completed.
- drag_enter(event)[source]
A method invoked when a drag operation enters the widget.
The widget should inspect the mime data of the event and accept the event if it can handle the drop action. The event must be accepted in order to receive further drag-drop events.
** The DropEnabled feature must be enabled for the widget in order for this method to be called. **
- Parameters:
event (DropEvent) – The event representing the drag-drop operation.
- drag_move(event)[source]
A method invoked when a drag operation moves in the widget.
This method will not normally be implemented, but it can be useful for supporting advanced drag-drop interactions.
** The DropEnabled feature must be enabled for the widget in order for this method to be called. **
- Parameters:
event (DropEvent) – The event representing the drag-drop operation.
- drag_leave()[source]
A method invoked when a drag operation leaves the widget.
** The DropEnabled feature must be enabled for the widget in order for this method to be called. **
- drop(event)[source]
A method invoked when the user drops the data on the widget.
The widget should either accept the proposed action, or set the drop action to an appropriate action before accepting the event, or set the drop action to DropAction.Ignore and then ignore the event.
** The DropEnabled feature must be enabled for the widget in order for this method to be called. **
- Parameters:
event (DropEvent) – The event representing the drag-drop operation.
- 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.