-
Notifications
You must be signed in to change notification settings - Fork 26
/
attractors_preferences.py
68 lines (52 loc) · 2.25 KB
/
attractors_preferences.py
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Enthought library imports.
from envisage.ui.tasks.api import PreferencesPane, TaskFactory
from apptools.preferences.api import PreferencesHelper
from traits.api import Bool, Dict, Enum, List, Str
from traitsui.api import EnumEditor, HGroup, VGroup, Item, Label, View
class AttractorsPreferences(PreferencesHelper):
""" The preferences helper for the Attractors application.
"""
#### 'PreferencesHelper' interface ########################################
# The path to the preference node that contains the preferences.
preferences_path = "example.attractors"
#### Preferences ##########################################################
# The task to activate on app startup if not restoring an old layout.
default_task = Str
# Whether to always apply the default application-level layout.
# See TasksApplication for more information.
always_use_default_layout = Bool
class AttractorsPreferencesPane(PreferencesPane):
""" The preferences pane for the Attractors application.
"""
#### 'PreferencesPane' interface ##########################################
# The factory to use for creating the preferences model object.
model_factory = AttractorsPreferences
#### 'AttractorsPreferencesPane' interface ################################
task_map = Dict(Str, Str)
view = View(
VGroup(
HGroup(
Item("always_use_default_layout"),
Label("Always use the default active task on startup"),
show_labels=False,
),
HGroup(
Label("Default active task:"),
Item(
"default_task", editor=EnumEditor(name="handler.task_map")
),
enabled_when="always_use_default_layout",
show_labels=False,
),
label="Application startup",
),
resizable=True,
)
###########################################################################
# Private interface.
###########################################################################
def _task_map_default(self):
return dict(
(factory.id, factory.name)
for factory in self.dialog.application.task_factories
)