Robot Framework Integrated Development Environment (RIDE)
saving.py
Go to the documentation of this file.
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.
15 
16 import wx
17 
18 from ..context import IS_WINDOWS
19 from ..ui.preferences_dialogs import PreferencesPanel, IntegerChoiceEditor, StringChoiceEditor, boolean_editor
20 from wx import Colour
21 
22 
24  location = ('Saving',)
25  title = 'Saving Preferences'
26 
27  def __init__(self, settings, *args, **kwargs):
28  super(SavingPreferences, self).__init__(*args, **kwargs)
29  self._settings_settings = settings
30  self.SetSizer(wx.FlexGridSizer(cols=2))
31  self.background_colorbackground_color = Colour("light gray")
32  self.foreground_colorforeground_color = Colour("black")
33  for editor in self._create_editors_create_editors(settings):
34  self._add_editor_add_editor(editor)
35  l_reformat, editor = boolean_editor(self, settings, 'reformat', 'Reformat?',
36  'Should it recalculate identation on Save?')
37  if IS_WINDOWS:
38  l_reformat.SetForegroundColour(self.foreground_colorforeground_color)
39  l_reformat.SetBackgroundColour(self.background_colorbackground_color)
40  l_reformat.SetOwnBackgroundColour(self.background_colorbackground_color)
41  l_reformat.SetOwnForegroundColour(self.foreground_colorforeground_color)
42  self.Sizer.AddMany([l_reformat, editor])
43  self.Sizer.Layout()
44  self.Update()
45 
46  def _create_editors(self, settings):
47  return [
48  StringChoiceEditor(settings, 'default file format', 'Default file format:',
49  ('txt', 'tsv', 'html', 'robot', 'resource')
50  ),
51  StringChoiceEditor(settings, 'txt format separator', 'TXT format separator:', ('pipe', 'space')
52  ),
53  StringChoiceEditor(settings, 'line separator', 'Line separator:',
54  ('native', 'CRLF', 'LF'),
55  'Possible values are native (of current OS) CRLF (Windows) and LF (Unixy)'
56  ),
57  IntegerChoiceEditor(settings, 'txt number of spaces', 'Separating spaces',
58  [str(i) for i in range(2, 11)],
59  'Number of spaces between cells when saving in txt format'
60  )
61  ]
62 
63  def _add_editor(self, editor):
64  l_editor = editor.label(self)
65  if IS_WINDOWS:
66  l_editor.SetForegroundColour(self.foreground_colorforeground_color)
67  l_editor.SetBackgroundColour(self.background_colorbackground_color)
68  l_editor.SetOwnBackgroundColour(self.background_colorbackground_color)
69  l_editor.SetOwnForegroundColour(self.foreground_colorforeground_color)
70  self.Sizer.AddMany([l_editor, (editor.chooser(self),)])
71  self.Sizer.AddMany([(editor.help(self), 0, wx.BOTTOM, 10), wx.Window(self)])
def __init__(self, settings, *args, **kwargs)
Definition: saving.py:27
Base class for all preference panels used by PreferencesDialog.
def boolean_editor(parent, settings, name, label, help='')