-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextBox.py
More file actions
93 lines (77 loc) · 2.91 KB
/
TextBox.py
File metadata and controls
93 lines (77 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python
#-----------------------------------------------------------------------------
# Name: TextBox.py
# Purpose: This WX component is used to display standard text output
#
# Author: Michael Rydeen
#
# Created: 2015/02/25
# Copyright: (c) 2015
# Licence: Use as you wish.
#----------------------------------------------------------------------------
# History
import wx
import gettext
class TextBox(wx.Frame):
def __init__(self, *args, **kwds):
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.panel_1 = wx.Panel(self, wx.ID_ANY)
self.textBox = wx.TextCtrl(self.panel_1, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_RICH2 | wx.TE_WORDWRAP)
self.panel_2 = wx.Panel(self.panel_1, wx.ID_ANY)
self.okButton = wx.Button(self.panel_2, wx.ID_ANY, "OK")
self.sizer_3_staticbox = wx.StaticBox(self.panel_2, wx.ID_ANY, "")
self.__set_properties()
self.__do_layout()
self.Bind(wx.EVT_BUTTON, self.okButtonHandler, self.okButton)
return
def __set_properties(self):
self.SetTitle("Text Output")
self.textBox.SetFont(wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, 0, "Courier"))
return
def __do_layout(self):
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_2 = wx.BoxSizer(wx.VERTICAL)
self.sizer_3_staticbox.Lower()
sizer_3 = wx.StaticBoxSizer(self.sizer_3_staticbox, wx.HORIZONTAL)
sizer_2.Add(self.textBox, 2, wx.ALL | wx.EXPAND, 1)
sizer_3.Add((20, 20), 1, wx.EXPAND | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
sizer_3.Add(self.okButton, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
sizer_3.Add((20, 20), 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 0)
self.panel_2.SetSizer(sizer_3)
sizer_2.Add(self.panel_2, 0, wx.EXPAND, 0)
self.panel_1.SetSizer(sizer_2)
sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
self.SetSizer(sizer_1)
sizer_1.Fit(self)
self.Layout()
self.SetSize((700,600))
return
def disableOkButton(self):
self.okButton.Disable()
return
def enableOkButton(self):
self.okButton.Enable()
return
def okButtonHandler(self, event):
self.Hide()
return
def setTitle( self, title ):
self.SetTitle((title))
return
def setText(self, text):
self.textBox.AppendText( text )
return
def setTextArray( self, array ):
for s in array:
self.setText( s )
return
# end of class TextBox
if __name__ == "__main__":
gettext.install("app") # replace with the appropriate catalog name
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
TextBox = TextBox(None, wx.ID_ANY, "")
app.SetTopWindow(TextBox)
TextBox.Show()
app.MainLoop()