ae.enaml_app

enaml application widgets, helper functions and classes

the enaml module widgets is providing widgets to write themed applications which can switch their font colors and backgrounds at run-time between dark and light.

another set of widgets provided by this namespace portion allows the automatic change of the application flow with only few lines of code.

to convert colors between the enaml and other formats the functions declared in the functions of this package can be used.

main application class for GUIApp-conform Enaml app

the classes FrameworkApp and EnamlMainApp of this ae portion are bundling and adding useful attributes and methods for your application and are extendable by creating a subclass.

the class EnamlMainApp is implementing a main app class that is reducing the amount of code needed to create a Python application based on the enaml framework.

EnamlMainApp is based on the following classes:

the main app class EnamlMainApp is also encapsulating the enaml app class for the Qt widget set (<enaml.QtApplication>) within the FrameworkApp class.

an instance of the Enaml app class can be directly accessed from the main app class instance via the framework_app attribute.

enaml application events

this portion is firing application events additional to the ones provided by MainAppBase. these framework app events get fired after on_app_run() in the following order:

  • on_app_build (fired on start of the application event loop).

  • on_app_stopped (fired after the main application window got closed)

Functions

convert_key_event_to_code(event)

converts the Qt key-press/-release event into a modifiers and key code string.

Classes

EnamlMainApp(**console_app_kwargs)

enaml application main base class

FrameworkApp(*args, **kwargs)

enaml framework application class with atom member/attribute support.

convert_key_event_to_code(event)[source]

converts the Qt key-press/-release event into a modifiers and key code string.

Return type:

Tuple[str, str]

class FrameworkApp(*args, **kwargs)[source]

Bases: QtApplication

enaml framework application class with atom member/attribute support.

app_state_flow_id

A value of type str.

By default, bytes will NOT be promoted to strings. Pass strict=False to the constructor to enable loose string checking.

app_state_flow_path

A List member which supports container notifications.

app_state_font_size

A value of type float.

By default, ints and longs will be promoted to floats. Pass strict=True to the constructor to enable strict float checking.

app_state_light_theme

A value of type bool.

app_state_sound_volume

A value of type float.

By default, ints and longs will be promoted to floats. Pass strict=True to the constructor to enable strict float checking.

app_state_win_rectangle

A member which allows tuple values.

If item validation is used, then assignment will create a copy of the original tuple before validating the items, since validation may change the item values.

app_state_flow_id_ink

A member which allows list values.

Assigning to a list creates a copy. The orginal list will remain unmodified. This is similar to the semantics of the assignment operator on the C++ STL container classes.

app_state_flow_path_ink

A member which allows list values.

Assigning to a list creates a copy. The orginal list will remain unmodified. This is similar to the semantics of the assignment operator on the C++ STL container classes.

app_state_selected_item_ink

A member which allows list values.

Assigning to a list creates a copy. The orginal list will remain unmodified. This is similar to the semantics of the assignment operator on the C++ STL container classes.

app_state_unselected_item_ink

A member which allows list values.

Assigning to a list creates a copy. The orginal list will remain unmodified. This is similar to the semantics of the assignment operator on the C++ STL container classes.

landscape

saved via win_rectangle app state

max_font_size

maximum font size in pixels bound to window size

min_font_size

minimum - “ -

mixed_back_ink

mixed color - used for user pref dropdown opening button

__atom_specific_members__ = frozenset({'app_state_flow_id', 'app_state_flow_id_ink', 'app_state_flow_path', 'app_state_flow_path_ink', 'app_state_font_size', 'app_state_light_theme', 'app_state_selected_item_ink', 'app_state_sound_volume', 'app_state_unselected_item_ink', 'app_state_win_rectangle', 'landscape', 'max_font_size', 'min_font_size', 'mixed_back_ink'})
__slotnames__ = []
class EnamlMainApp(**console_app_kwargs)[source]

Bases: MainAppBase

enaml application main base class

_original_key_press_handler: Optional[Callable] = None
_original_key_release_handler: Optional[Callable] = None
_original_win_resize_handler: Optional[Callable] = None
init_app(framework_app_class=<class 'ae.enaml_app.FrameworkApp'>)[source]

initialize framework app instance and root window/layout, return GUI event loop start/stop methods.

Return type:

Tuple[Optional[Callable], Optional[Callable]]

cached_icon(icon_name, size, light)[source]

get cached image/icon object.

Return type:

Optional[Icon]

call_method_delayed(_delay, callback, *args, **kwargs)[source]

delay not implemented - for now redirect to direct call.

Return type:

Any

focus_widget(widget)[source]

set input/keyboard focus to the passed widget.

Parameters:

widget (Widget) – widget/window that will receive the focus.

focused_widget()[source]

enaml/qt focus debug helper method determining tool tip of the current qt widget with focus

Return type:

str

Returns:

tool tip string of current focus or app window status.

key_press_from_enaml(event)[source]

convert/normalize enaml/Qt key press/down event and pass it to MainAppBase key press dispatcher.

key_release_from_enaml(event)[source]

convert/normalize enaml/Qt key release/up event and pass it to MainAppBase key release dispatcher.

load_images()[source]

overwrite un-cached image file register to use cached image files instead.

on_app_run()[source]

run/start app event handler.

on_flow_widget_focused()[source]

set focus to the widget referenced by the current flow id.

on_font_size_change(_flow_key, event_kwargs)[source]

font size app state flow change confirmation event handler.

Parameters:
  • _flow_key (str) – flow key.

  • event_kwargs (Dict[str, Any]) – event kwargs with key ‘font_size’ containing the font_size in pixels.

Return type:

bool

Returns:

True to confirm change of flow id.

open_popup(popup_class, **popup_kwargs)[source]

open Popup and set focus to the first widget.

Parameters:
  • popup_class (Type) – class of the Popup widget/window.

  • popup_kwargs – args to instantiate and show/open the popup.

Return type:

Widget

Returns:

instance of the popup widget.

play_sound(sound_name)[source]

play audio/sound file.

user_preference_color_selected(color_name, dialog)[source]

ColorDialog callback.

win_activated(main_window)[source]

main window activated event handler, called only once on app startup via widgets.enaml/ThemeMainWindow.

Parameters:

main_window (Any) –

Returns:

win_closed(changed)[source]

callback fired on close of Main window to save/restore framework_win.geometry on app exit/start.

Parameters:

changed (dict) – qt/enaml changed event dict.

Note

neither self.framework_app.stop() nor self.framework_app._ qapp.exit(exit_code) trigger window closed event.

win_resize_from_enaml(event)[source]

convert/normalize enaml/Qt key press/down event and pass it to MainAppBase key press dispatcher.