Package Gnumed :: Package timelinelib :: Package wxgui :: Package components :: Package propertyeditors :: Module descriptioneditor
[frames] | no frames]

Source Code for Module Gnumed.timelinelib.wxgui.components.propertyeditors.descriptioneditor

 1  # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018  Rickard Lindberg, Roger Lindberg 
 2  # 
 3  # This file is part of Timeline. 
 4  # 
 5  # Timeline is free software: you can redistribute it and/or modify 
 6  # it under the terms of the GNU General Public License as published by 
 7  # the Free Software Foundation, either version 3 of the License, or 
 8  # (at your option) any later version. 
 9  # 
10  # Timeline is distributed in the hope that it will be useful, 
11  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
13  # GNU General Public License for more details. 
14  # 
15  # You should have received a copy of the GNU General Public License 
16  # along with Timeline.  If not, see <http://www.gnu.org/licenses/>. 
17   
18   
19  import wx 
20   
21  from timelinelib.wxgui.components.propertyeditors.baseeditor import BaseEditor 
22   
23   
24 -class DescriptionEditorGuiCreator(wx.Panel):
25
26 - def __init__(self, parent):
27 wx.Panel.__init__(self, parent)
28
29 - def create_sizer(self):
30 return wx.BoxSizer()
31
32 - def create_controls(self):
33 text = self._create_text_control() 34 return (text,)
35
36 - def put_controls_in_sizer(self, sizer, controls):
37 text, = controls 38 sizer.Add(text, 1, wx.ALL | wx.EXPAND, 0)
39
40 - def _create_text_control(self):
41 self.data = wx.TextCtrl(self, style=wx.TE_MULTILINE) 42 self.data.Bind(wx.EVT_CHAR, self._on_char) 43 return self.data
44
45 - def _on_char(self, evt):
46 if self._ctrl_a(evt): 47 self.data.SetSelection(-1, -1) 48 else: 49 evt.Skip()
50
51 - def _ctrl_a(self, evt):
52 KEY_CODE_A = 1 53 return evt.ControlDown() and evt.KeyCode == KEY_CODE_A
54 55
56 -class DescriptionEditor(BaseEditor, DescriptionEditorGuiCreator):
57
58 - def __init__(self, parent, editor, name=""):
62
63 - def get_data(self):
64 description = self.data.GetValue().strip() 65 if description != "": 66 return description 67 return None
68
69 - def clear_data(self):
70 self.data.SetValue("")
71