]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxTextCtrl.py
added wxWindows shared library to link of OpenGL wxWindows shared library
[wxWidgets.git] / wxPython / demo / wxTextCtrl.py
CommitLineData
d56cebe7 1import sys
cf694132
RD
2from wxPython.wx import *
3
4#---------------------------------------------------------------------------
5
6class TestPanel(wxPanel):
7 def __init__(self, parent, log):
8 wxPanel.__init__(self, parent, -1)
9 self.log = log
10
d56cebe7
RD
11 l1 = wxStaticText(self, -1, "wxTextCtrl")
12 t1 = wxTextCtrl(self, 10, "Test it out and see", size=(125, -1))
13 t1.SetInsertionPoint(0)
cf694132 14 EVT_TEXT(self, 10, self.EvtText)
d56cebe7 15 EVT_CHAR(t1, self.EvtChar)
c368d904 16
cf694132 17
d56cebe7
RD
18 l2 = wxStaticText(self, -1, "Passsword")
19 t2 = wxTextCtrl(self, 20, "", size=(125, -1), style=wxTE_PASSWORD)
cf694132
RD
20 EVT_TEXT(self, 20, self.EvtText)
21
d56cebe7
RD
22 l3 = wxStaticText(self, -1, "Multi-line")
23 t3 = wxTextCtrl(self, 30, "How does it work with a long line of text set in the control",
24 size=(200, 100), style=wxTE_MULTILINE)
25 t3.SetInsertionPoint(0)
cf694132
RD
26 EVT_TEXT(self, 30, self.EvtText)
27
d56cebe7
RD
28 l4 = wxStaticText(self, -1, "Rich Text")
29 t4 = wxTextCtrl(self, 40, "If supported by the native control, this is red, and this is a different font.",
30 size=(200, 100), style=wxTE_MULTILINE|wxTE_RICH)
31 t4.SetInsertionPoint(0)
32 t4.SetStyle(44, 47, wxTextAttr("RED", "YELLOW"))
33
34 points = t4.GetFont().GetPointSize() # get the current size
35 f = wxFont(points+2, wxROMAN, wxITALIC, wxBOLD, true)
36## print 'a1', sys.getrefcount(f)
37## t4.SetStyle(63, 77, wxTextAttr("BLUE", font=f))
38 t4.SetStyle(63, 77, wxTextAttr("BLUE", wxNullColour, f))
39## print 'a2', sys.getrefcount(f)
40
41 sizer = wxFlexGridSizer(cols=2, hgap=6, vgap=6)
42 sizer.AddMany([ l1, t1,
43 l2, t2,
44 l3, t3,
45 l4, t4,
46 ])
47 border = wxBoxSizer(wxVERTICAL)
48 border.Add(sizer, 0, wxALL, 25)
49 self.SetSizer(border)
50 self.SetAutoLayout(true)
51
52
cf694132
RD
53 def EvtText(self, event):
54 self.log.WriteText('EvtText: %s\n' % event.GetString())
55
56
c368d904
RD
57 def EvtChar(self, event):
58 self.log.WriteText('EvtChar: %d\n' % event.GetKeyCode())
59 event.Skip()
60
cf694132
RD
61
62#---------------------------------------------------------------------------
63
64def runTest(frame, nb, log):
65 win = TestPanel(nb, log)
66 return win
67
68#---------------------------------------------------------------------------
69
70
71
72
73overview = """\
74"""