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 under the
6 # terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your option) any
10 # Hooke is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with Hooke. If not, see <http://www.gnu.org/licenses/>.
18 """Defines :class:`GUI` providing a wxWidgets interface to Hooke.
20 We only define the :class:`UserInterface` here, to minimize required
21 dependencies for users who may not wish to use this interface. The
22 bulk of the interface is defined in :mod:`interface`.
25 import os.path as _os_path
27 from ...ui import UserInterface as _UserInterface
28 from ...config import Setting as _Setting
30 import wxversion as _wxversion
31 except ImportError, e:
36 _wxversion.select(WX_GOOD)
38 from .interface import HookeApp as _HookeApp
39 except _wxversion.VersionError, e:
43 class GUI (_UserInterface):
44 """wxWindows graphical user interface.
47 super(GUI, self).__init__(name='gui')
49 def default_settings(self):
50 """Return a list of :class:`hooke.config.Setting`\s for any
51 configurable UI settings.
53 The suggested section setting is::
55 Setting(section=self.setting_section, help=self.__doc__)
58 _Setting(section=self.setting_section, help=self.__doc__),
59 _Setting(section=self.setting_section, option='icon image',
60 value=_os_path.join('doc', 'img', 'microscope.ico'),
62 help='Path to the hooke icon image.'),
63 _Setting(section=self.setting_section, option='show splash screen',
64 value=True, type='bool',
65 help='Enable/disable the splash screen'),
66 _Setting(section=self.setting_section, option='splash screen image',
67 value=_os_path.join('doc', 'img', 'hooke.jpg'),
69 help='Path to the Hooke splash screen image.'),
70 _Setting(section=self.setting_section,
71 option='splash screen duration',
72 value=1000, type='int',
73 help='Duration of the splash screen in milliseconds.'),
74 _Setting(section=self.setting_section, option='perspective path',
75 value=_os_path.join('resources', 'gui', 'perspective'),
76 help='Directory containing perspective files.'), # TODO: allow colon separated list, like $PATH.
77 _Setting(section=self.setting_section, option='perspective extension',
79 help='Extension for perspective files.'),
80 _Setting(section=self.setting_section, option='hide extensions',
81 value=False, type='bool',
82 help='Hide file extensions when displaying names.'),
83 _Setting(section=self.setting_section, option='plot legend',
84 value=True, type='bool',
85 help='Enable/disable the plot legend.'),
86 _Setting(section=self.setting_section, option='plot SI format',
87 value='True', type='bool',
88 help='Enable/disable SI plot axes numbering.'),
89 _Setting(section=self.setting_section, option='plot decimals',
91 help=('Number of decimal places to show if "plot SI '
92 'format" is enabled.')),
93 _Setting(section=self.setting_section, option='folders-workdir',
94 value='.', type='path',
95 help='This should probably go...'),
96 _Setting(section=self.setting_section, option='folders-filters',
97 value='.', type='path',
98 help='This should probably go...'),
99 _Setting(section=self.setting_section, option='active perspective',
101 help='Name of active perspective file (or "Default").'),
102 _Setting(section=self.setting_section,
103 option='folders-filter-index',
105 help='This should probably go...'),
106 _Setting(section=self.setting_section, option='main height',
107 value=450, type='int',
108 help='Height of main window in pixels.'),
109 _Setting(section=self.setting_section, option='main width',
110 value=800, type='int',
111 help='Width of main window in pixels.'),
112 _Setting(section=self.setting_section, option='main top',
114 help='Pixels from screen top to top of main window.'),
115 _Setting(section=self.setting_section, option='main left',
117 help='Pixels from screen left to left of main window.'),
118 _Setting(section=self.setting_section, option='selected command',
119 value='load playlist',
120 help='Name of the initially selected command.'),
123 def _app(self, commands, ui_to_command_queue, command_to_ui_queue):
124 if _wxversion is None:
125 raise _wxversion_error
129 app = _HookeApp(gui=self,
131 inqueue=ui_to_command_queue,
132 outqueue=command_to_ui_queue,
136 def run(self, commands, ui_to_command_queue, command_to_ui_queue):
137 app = self._app(commands, ui_to_command_queue, command_to_ui_queue)