1 # Copyright (C) 2010-2012 W. Trevor King <wking@drexel.edu>
3 # This file is part of Hooke.
5 # Hooke is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as
7 # published by the Free Software Foundation, either version 3 of the
8 # License, or (at your option) any later version.
10 # Hooke is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 # Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with Hooke. If not, see
17 # <http://www.gnu.org/licenses/>.
19 """Defines :class:`GUI` providing a wxWidgets interface to Hooke.
21 We only define the :class:`UserInterface` here, to minimize required
22 dependencies for users who may not wish to use this interface. The
23 bulk of the interface is defined in :mod:`interface`.
26 import os.path as _os_path
28 from ...ui import UserInterface as _UserInterface
29 from ...config import Setting as _Setting
31 import wxversion as _wxversion
32 except ImportError, e:
37 from .interface import HookeApp as _HookeApp
38 except _wxversion.VersionError, e:
42 class GUI (_UserInterface):
43 """wxWindows graphical user interface.
46 super(GUI, self).__init__(name='gui')
48 def default_settings(self):
49 """Return a list of :class:`hooke.config.Setting`\s for any
50 configurable UI settings.
52 The suggested section setting is::
54 Setting(section=self.setting_section, help=self.__doc__)
57 _Setting(section=self.setting_section, help=self.__doc__),
58 _Setting(section=self.setting_section, option='icon image',
59 value=_os_path.join('doc', 'img', 'microscope.ico'),
61 help='Path to the hooke icon image.'),
62 _Setting(section=self.setting_section, option='show splash screen',
63 value=True, type='bool',
64 help='Enable/disable the splash screen'),
65 _Setting(section=self.setting_section, option='splash screen image',
66 value=_os_path.join('doc', 'img', 'hooke.jpg'),
68 help='Path to the Hooke splash screen image.'),
69 _Setting(section=self.setting_section,
70 option='splash screen duration',
71 value=1000, type='int',
72 help='Duration of the splash screen in milliseconds.'),
73 _Setting(section=self.setting_section, option='perspective path',
74 value=_os_path.join('resources', 'gui', 'perspective'),
75 help='Directory containing perspective files.'), # TODO: allow colon separated list, like $PATH.
76 _Setting(section=self.setting_section, option='perspective extension',
78 help='Extension for perspective files.'),
79 _Setting(section=self.setting_section, option='hide extensions',
80 value=False, type='bool',
81 help='Hide file extensions when displaying names.'),
82 _Setting(section=self.setting_section, option='plot legend',
83 value=True, type='bool',
84 help='Enable/disable the plot legend.'),
85 _Setting(section=self.setting_section, option='plot SI format',
86 value='True', type='bool',
87 help='Enable/disable SI plot axes numbering.'),
88 _Setting(section=self.setting_section, option='plot decimals',
90 help=('Number of decimal places to show if "plot SI '
91 'format" is enabled.')),
92 _Setting(section=self.setting_section, option='folders-workdir',
93 value='.', type='path',
94 help='This should probably go...'),
95 _Setting(section=self.setting_section, option='folders-filters',
96 value='.', type='path',
97 help='This should probably go...'),
98 _Setting(section=self.setting_section, option='active perspective',
100 help='Name of active perspective file (or "Default").'),
101 _Setting(section=self.setting_section,
102 option='folders-filter-index',
104 help='This should probably go...'),
105 _Setting(section=self.setting_section, option='main height',
106 value=450, type='int',
107 help='Height of main window in pixels.'),
108 _Setting(section=self.setting_section, option='main width',
109 value=800, type='int',
110 help='Width of main window in pixels.'),
111 _Setting(section=self.setting_section, option='main top',
113 help='Pixels from screen top to top of main window.'),
114 _Setting(section=self.setting_section, option='main left',
116 help='Pixels from screen left to left of main window.'),
117 _Setting(section=self.setting_section, option='selected command',
118 value='load playlist',
119 help='Name of the initially selected command.'),
122 def _app(self, commands, ui_to_command_queue, command_to_ui_queue):
123 if _wxversion is None:
124 raise _wxversion_error
128 app = _HookeApp(gui=self,
130 inqueue=ui_to_command_queue,
131 outqueue=command_to_ui_queue,
135 def run(self, commands, ui_to_command_queue, command_to_ui_queue):
136 app = self._app(commands, ui_to_command_queue, command_to_ui_queue)