1Preferences in Envisage
2=======================
3
4This section discusses how an Envisage application uses the preferences
5mechanism. Envisage tries not to dictate too much, and so this describes the
6default behaviour, but you are free to override it as desired.
7
8Envisage uses the default implementation of the ScopedPreferences_ class which
9is made available via the application's 'preferences' trait::
10
11  >>> application = Application(id='myapplication')
12  >>> application.preferences.set('acme.ui.bgcolor', 'yellow')
13  >>> application.preferences.get('acme.ui.bgcolor')
14  'yellow'
15
16Hence, you use the Envisage preferences just like you would any other scoped
17preferences.
18
19It also registers itself as the default preferences node used by the
20PreferencesHelper_ class. Hence you don't need to provide a preferences node
21explicitly to your helper::
22
23  >>> helper = SplashScreenPreferences()
24  >>> helper.bgcolor
25  'blue'
26  >>> helper.width
27  100
28  >>> helper.ratio
29  1.0
30  >>> helper.visible
31  True
32
33The only extra thing that Envisage does for you is to provide an extension
34point that allows you to contribute any number of '.ini' files that are
35loaded into the default scope when the application is started.
36
37e.g. To contribute a preference file for my plugin I might use::
38
39  class MyPlugin(Plugin):
40      ...
41
42      @contributes_to('envisage.preferences')
43      def get_preferences(self, application):
44          return ['pkgfile://mypackage:preferences.ini']
45
46.. _PreferencesHelper: ../../enthought/preferences/preferences_helper.py
47.. _ScopedPreferences: ../../enthought/preferences/scoped_preferences.py
48