Coverage for src/robotide/preferences/imports.py: 35%
29 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-06 10:40 +0100
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-06 10:40 +0100
1# Copyright 2008-2015 Nokia Networks
2# Copyright 2016- Robot Framework Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
16import builtins 1ab
17import wx 1ab
19from .settings import RideSettings 1ab
20from ..ui.preferences_dialogs import PreferencesPanel, comma_separated_value_editor 1ab
22_ = wx.GetTranslation # To keep linter/code analyser happy 1ab
23builtins.__dict__['_'] = wx.GetTranslation 1ab
26class ImportPreferences(PreferencesPanel): 1ab
27 location = _('Importing') 1ab
29 def __init__(self, parent, settings): 1ab
30 self.title = _('Library imports and PYTHONPATH')
31 self.location = _('Importing')
32 super(PreferencesPanel, self).__init__(parent)
33 self.SetSizer(wx.FlexGridSizer(rows=4, cols=2, vgap=10, hgap=5))
34 self.Sizer.AddGrowableCol(1, proportion=1)
35 self._gsettings = RideSettings()
36 self.csettings = self._gsettings['General']
37 self.background_color = self.csettings['background']
38 self.foreground_color = self.csettings['foreground']
39 self._add_settings(settings)
41 def _add_settings(self, settings): 1ab
42 list_settings = [
43 ('auto imports', _('Comma separated list of libraries to be '
44 'automatically imported.')),
45 ('pythonpath', _('Comma separated list of directories to be added '
46 'to PYTHONPATH when libraries are searched.')),
47 ('library xml directories', _('Comma separated list of directories '
48 'containing library spec files.'))
49 ]
50 for (name, _help) in list_settings:
51 self._create_list_setting_editor(settings, name, _help)
53 def _create_list_setting_editor(self, settings, name, _help): 1ab
54 label, editor = comma_separated_value_editor(self, settings, name, name.capitalize(), _help)
55 label.SetForegroundColour(self.foreground_color)
56 label.SetBackgroundColour(self.background_color)
57 self.Sizer.Add(label)
58 self.Sizer.Add(editor) #, flag=wx.EXPAND)