ff7e45bf3dfbde3aa871f9853bee90698242dc99
[hooke.git] / hooke / ui / gui / dialog / text.py
1 # Copyright (C) 2010-2012 W. Trevor King <wking@drexel.edu>
2 #
3 # This file is part of Hooke.
4 #
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
8 # later version.
9 #
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
13 # details.
14 #
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/>.
17
18 import wx
19
20
21 class MemoDialog(wx.Dialog):
22     """\
23     Dialog for multi-line text editing.
24     """
25     def __init__(self, parent=None, title='', text='', pos=None, size=(500,500)):
26         wx.Dialog.__init__(self, parent, -1, title, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
27
28         sizer = wx.BoxSizer(wx.VERTICAL)
29
30         tc = wx.TextCtrl(self, 11, text, style=wx.TE_MULTILINE)
31         self.tc = tc
32         topsizer.Add(tc,1,wx.EXPAND|wx.ALL,8)
33
34         rowsizer = wx.BoxSizer( wx.HORIZONTAL )
35         rowsizer.Add(wx.Button(self,wx.ID_OK,'Ok'),0,wx.ALIGN_RIGHT|wx.ALIGN_CENTRE_VERTICAL,8)
36         rowsizer.Add((0,0),1,wx.ALIGN_RIGHT|wx.ALIGN_CENTRE_VERTICAL,8)
37         rowsizer.Add(wx.Button(self,wx.ID_CANCEL,'Cancel'),0,wx.ALIGN_RIGHT|wx.ALIGN_CENTRE_VERTICAL,8)
38         topsizer.Add(rowsizer,0,wx.EXPAND|wx.ALL,8)
39
40         self.SetSizer( topsizer )
41         topsizer.Layout()
42
43         self.SetSize( size )
44         if not pos:
45             self.CenterOnScreen()
46         else:
47             self.Move(pos)