Eagle is an abstraction layer atop Graphical Toolkits to make GUI programming as easy as possible. Eagle reaches this by narrowing what's possible to do and providing high level components with easy to use API.
Eagle isn't meant to design every kind of GUI, it's focused to
provide resources to create windows with 5 areas (left,
right, top, bottom and center), each one provides automatic
scrollbars and lay out components in a sensible way: left,
right and center provides vertical scrollbars and vertical
layout, while top and bottom uses horizontal. Each area can be
hidden and extended with more complex layout internally by means
of Group widget. Eagle calls each
window an application (App), but you
can provide multiple in your application.
Each App provides a preferences
window, a window that is modal to the application window and
will save and restore its components values automatically
together with other App persistent
components.
Every component have an identification name (id) and can be
reach by this, so you can avoid global variables to access
components. Each id have the scope of the application it's
inside and thus one component can be in just one App. You may access components instances
with , get_widget_by_id(
id, )app_idapp_id may be omitted, the first declared
application will be used, this is useful when you have just
one, since you can save some typing. Some components may not
receive an id (App, customized
buttons like CloseButton) since you
usually will not use their id directly (probably they already
do everything, like QuitButton that
quits program), these will be named sequentially. Every widget
can be accessed using Python's dict syntax, id being the key.
Every input component can be persisted, that is, its contents
will be saved to a file after they changed and will be loaded
from this file automatically when the application
starts. Components that are in App
preferences will be marked persistent automatically, other
components should be marked with the parameter .
persistent=True
Every input or output component have a common API to set/get
value, you may use the or set_value( new_value ) methods if you
like Object Oriented Programming or you may use functions
get_value() or set_value( component_id, new_value ), app_id if you don't. Eagle
has special support for input and output components if using the
dict-like syntax: it already does get_value( component_id, )app_idset_value or get_value as appropriated:
# It's easier to write
value = my_app[
"my_widget" ]
my_app[ "my_widget" ] = value
# instead of
my_widget = get_widget_by_id( my_app, "my_widget"
)
value = my_widget.get_value()
my_widget.set_value( value )
Example of dict-like access.
Input and Buttons components provide a callback to notify some
action. Input calls back the provided function with app_id, component_id and value as parameters when
they contents changed, while buttons calls back when with
app_id and component_id when clicked. Eagle, different
from toolkits like GTK, Qt, Tk and others doesn't provide
various callbacks for the same component, like double-clicked
or mouse-over, just the callback that makes more sense. This
makes programming much easier and GUI more consistent
usability-wise. There are, however, some exceptions: App, it provides 2 callbacks: one to
notify that data changed (if you use the same callback to
handle every input component, you may use this and avoid some
typing!) and other that is called before the App closes, Canvas
for resize in addition to mouse event callback, Table for selection changed in addition to
data changed callback.
Eagle show room.
Eagle show room annotated.