]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxTextCtrl.py
added wxWindows shared library to link of OpenGL wxWindows shared library
[wxWidgets.git] / wxPython / demo / wxTextCtrl.py
1 import sys
2 from wxPython.wx import *
3
4 #---------------------------------------------------------------------------
5
6 class TestPanel(wxPanel):
7 def __init__(self, parent, log):
8 wxPanel.__init__(self, parent, -1)
9 self.log = log
10
11 l1 = wxStaticText(self, -1, "wxTextCtrl")
12 t1 = wxTextCtrl(self, 10, "Test it out and see", size=(125, -1))
13 t1.SetInsertionPoint(0)
14 EVT_TEXT(self, 10, self.EvtText)
15 EVT_CHAR(t1, self.EvtChar)
16
17
18 l2 = wxStaticText(self, -1, "Passsword")
19 t2 = wxTextCtrl(self, 20, "", size=(125, -1), style=wxTE_PASSWORD)
20 EVT_TEXT(self, 20, self.EvtText)
21
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)
26 EVT_TEXT(self, 30, self.EvtText)
27
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
53 def EvtText(self, event):
54 self.log.WriteText('EvtText: %s\n' % event.GetString())
55
56
57 def EvtChar(self, event):
58 self.log.WriteText('EvtChar: %d\n' % event.GetKeyCode())
59 event.Skip()
60
61
62 #---------------------------------------------------------------------------
63
64 def runTest(frame, nb, log):
65 win = TestPanel(nb, log)
66 return win
67
68 #---------------------------------------------------------------------------
69
70
71
72
73 overview = """\
74 """