]>
Commit | Line | Data |
---|---|---|
8fa876ca RD |
1 | # |
2 | # This file is used for the wx.HtmlWindow demo. | |
3 | # | |
e166644c | 4 | |
8fa876ca | 5 | import sys |
e166644c | 6 | |
8fa876ca RD |
7 | import wx |
8 | import wx.html as html | |
e166644c RD |
9 | |
10 | #---------------------------------------------------------------------- | |
11 | ||
8fa876ca RD |
12 | class TestPanel(wx.Panel): |
13 | def __init__(self, parent, id=-1, size=wx.DefaultSize, bgcolor=None): | |
14 | wx.Panel.__init__(self, parent, id, size=size) | |
e166644c RD |
15 | |
16 | if bgcolor: | |
17 | self.SetBackgroundColour(bgcolor) | |
18 | ||
8fa876ca RD |
19 | wx.StaticText(self, -1, 'Name:', (10, 10)) |
20 | wx.StaticText(self, -1, 'Email:', (10, 40)) | |
e166644c | 21 | |
8fa876ca RD |
22 | self.name = wx.TextCtrl(self, -1, '', (50, 10), (100, -1)) |
23 | self.email = wx.TextCtrl(self, -1, '', (50, 40), (100, -1)) | |
e166644c | 24 | |
8fa876ca RD |
25 | wx.Button(self, -1, 'Okay', (50, 70)) |
26 | self.Bind(wx.EVT_BUTTON, self.OnButton) | |
e166644c RD |
27 | |
28 | ||
29 | def OnButton(self, event): | |
30 | name = self.name.GetValue() | |
31 | email = self.email.GetValue() | |
8fa876ca RD |
32 | dlg = wx.MessageDialog( |
33 | self, 'You entered:\n %s\n %s' % (name, email), | |
34 | 'Results', style = wx.OK | wx.ICON_INFORMATION | |
35 | ) | |
36 | ||
e166644c RD |
37 | dlg.ShowModal() |
38 | dlg.Destroy() | |
39 | ||
40 | ||
41 | ||
42 | #---------------------------------------------------------------------- | |
43 | ||
8fa876ca RD |
44 | class TestHtmlPanel(wx.Panel): |
45 | def __init__(self, parent, id=-1, size=wx.DefaultSize): | |
46 | ||
e166644c | 47 | import About |
8fa876ca RD |
48 | |
49 | wx.Panel.__init__(self, parent, id, size=size) | |
50 | self.html = html.HtmlWindow(self, -1, (5,5), (400, 350)) | |
1e4a197e | 51 | py_version = sys.version.split()[0] |
8fa876ca | 52 | self.html.SetPage(About.MyAboutBox.text % (wx.VERSION_STRING, py_version)) |
c368d904 RD |
53 | ir = self.html.GetInternalRepresentation() |
54 | self.html.SetSize( (ir.GetWidth()+5, ir.GetHeight()+5) ) | |
e166644c RD |
55 | self.Fit() |
56 | ||
57 | #---------------------------------------------------------------------- | |
58 | ||
8fa876ca RD |
59 | def runTest(frame, nb, log): |
60 | win = TestHtmlPanel(frame) | |
61 | return win | |
62 | ||
63 | #---------------------------------------------------------------------- | |
64 | ||
65 | if __name__ == '__main__': | |
66 | import sys,os | |
67 | import run | |
8eca4fef | 68 | run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) |
e166644c | 69 |