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 from .interface import HookeApp as _HookeApp
37 except _wxversion.VersionError, e:
41 class GUI (_UserInterface):
42 """wxWindows graphical user interface.
45 super(GUI, self).__init__(name='gui')
47 def default_settings(self):
48 """Return a list of :class:`hooke.config.Setting`\s for any
49 configurable UI settings.
51 The suggested section setting is::
53 Setting(section=self.setting_section, help=self.__doc__)
56 _Setting(section=self.setting_section, help=self.__doc__),
57 _Setting(section=self.setting_section, option='icon image',
58 value=_os_path.join('doc', 'img', 'microscope.ico'),
60 help='Path to the hooke icon image.'),
61 _Setting(section=self.setting_section, option='show splash screen',
62 value=True, type='bool',
63 help='Enable/disable the splash screen'),
64 _Setting(section=self.setting_section, option='splash screen image',
65 value=_os_path.join('doc', 'img', 'hooke.jpg'),
67 help='Path to the Hooke splash screen image.'),
68 _Setting(section=self.setting_section,
69 option='splash screen duration',
70 value=1000, type='int',
71 help='Duration of the splash screen in milliseconds.'),
72 _Setting(section=self.setting_section, option='perspective path',
73 value=_os_path.join('resources', 'gui', 'perspective'),
74 help='Directory containing perspective files.'), # TODO: allow colon separated list, like $PATH.
75 _Setting(section=self.setting_section, option='perspective extension',
77 help='Extension for perspective files.'),
78 _Setting(section=self.setting_section, option='hide extensions',
79 value=False, type='bool',
80 help='Hide file extensions when displaying names.'),
81 _Setting(section=self.setting_section, option='plot legend',
82 value=True, type='bool',
83 help='Enable/disable the plot legend.'),
84 _Setting(section=self.setting_section, option='plot SI format',
85 value='True', type='bool',
86 help='Enable/disable SI plot axes numbering.'),
87 _Setting(section=self.setting_section, option='plot decimals',
89 help=('Number of decimal places to show if "plot SI '
90 'format" is enabled.')),
91 _Setting(section=self.setting_section, option='folders-workdir',
92 value='.', type='path',
93 help='This should probably go...'),
94 _Setting(section=self.setting_section, option='folders-filters',
95 value='.', type='path',
96 help='This should probably go...'),
97 _Setting(section=self.setting_section, option='active perspective',
99 help='Name of active perspective file (or "Default").'),
100 _Setting(section=self.setting_section,
101 option='folders-filter-index',
103 help='This should probably go...'),
104 _Setting(section=self.setting_section, option='main height',
105 value=450, type='int',
106 help='Height of main window in pixels.'),
107 _Setting(section=self.setting_section, option='main width',
108 value=800, type='int',
109 help='Width of main window in pixels.'),
110 _Setting(section=self.setting_section, option='main top',
112 help='Pixels from screen top to top of main window.'),
113 _Setting(section=self.setting_section, option='main left',
115 help='Pixels from screen left to left of main window.'),
116 _Setting(section=self.setting_section, option='selected command',
117 value='load playlist',
118 help='Name of the initially selected command.'),
121 def _app(self, commands, ui_to_command_queue, command_to_ui_queue):
122 if _wxversion is None:
123 raise _wxversion_error
127 app = _HookeApp(gui=self,
129 inqueue=ui_to_command_queue,
130 outqueue=command_to_ui_queue,
134 def run(self, commands, ui_to_command_queue, command_to_ui_queue):
135 app = self._app(commands, ui_to_command_queue, command_to_ui_queue)