Ran update_copyright.py.
[hooke.git] / hooke / ui / gui / panel / note.py
1 # Copyright (C) 2010-2011 Rolf Schmidt <rschmidt@alcor.concordia.ca>
2 #                         W. Trevor King <wking@drexel.edu>
3 #
4 # This file is part of Hooke.
5 #
6 # Hooke is free software: you can redistribute it and/or modify it
7 # under the terms of the GNU Lesser General Public License as
8 # published by the Free Software Foundation, either version 3 of the
9 # License, or (at your option) any later version.
10 #
11 # Hooke is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
14 # Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with Hooke.  If not, see
18 # <http://www.gnu.org/licenses/>.
19
20 """Note panel for Hooke.
21 """
22
23 import wx
24
25 from ....util.callback import callback, in_callback
26 from . import Panel
27
28
29 class NotePanel (Panel, wx.Panel):
30     def __init__(self, callbacks=None, **kwargs):
31         super(NotePanel, self).__init__(
32             name='note', callbacks=callbacks, **kwargs)
33
34         self._c = {
35             'editor': wx.TextCtrl(
36                 parent=self,
37                 style=wx.TE_MULTILINE),
38             'update': wx.Button(
39                 parent=self,
40                 label='Update note'),
41             }
42         sizer = wx.BoxSizer(wx.VERTICAL)
43         sizer.Add(self._c['editor'], 1, wx.EXPAND)
44         sizer.Add(self._c['update'], 0, wx.EXPAND)
45         self.SetSizer(sizer)
46         self.SetAutoLayout(True)
47
48         self.Bind(wx.EVT_BUTTON, self._on_update)
49
50     def set_text(self, text):
51         self._c['editor'].SetValue(text)
52
53     def _on_update(self, event):
54         text = self._c['editor'].GetValue()
55         in_callback(self, text)