File: gui_application.rst

package info (click to toggle)
python-envisage 7.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,880 kB
  • sloc: python: 8,696; makefile: 76; sh: 5
file content (45 lines) | stat: -rw-r--r-- 1,750 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
GUIApplication
==============

The :py:class:`GUIApplication` subclass of the standard Envisage
:py:class:`Application` class uses Pyface's cross-platform GUI tools to ensure
that an appropriate back-end application object is instantiated before plugins
run their :py:meth:`start` methods, and then ensures that the GUI mainloop is
started after the :py:meth:`start` methods have successfully completed.

This allows developers to have a single place to start the application, but have
plugins to listen for the :py:attr:`application_initialized` event to create UI
components.  In particular, Traits UIs can be created in an event listener
method by calling :py:meth:`edit_traits`, something like this::

    class MyViewPlugin(Plugin):

        model = Instance

        ui = Instance('traitsui.ui.UI')

        @on_trait_change('application:application_initialized')
        def create_ui(self):
            # we need to keep a reference to the ui object
            self.ui = self.model.edit_traits()

This is intended to be a cheap and simple way to take an existing application
and start "lifting" it to Envisage, without having to use a more heavyweight
UI framework such as Tasks immediately.  Developers can work on adding
extensibility to the application's model without having to at the same time
add extensibility to their UI.

The :py:class:`GUIApplication` exposes the following public API:

.. py:attribute:: gui

    The Pyface :py:class:`GUI` instance the :py:class:`GUIApplication` creates.

.. py:attribute:: splash_screen

    An optional Pyface :py:class:`ISplashScreen` that gets shown while
    the plugins are started.

.. py:attribute:: application_initialized

    An event which is fired after the UI mainloop has started.