]>
Commit | Line | Data |
---|---|---|
f6bcfd97 | 1 | |
8fa876ca | 2 | import wx |
f6bcfd97 BP |
3 | |
4 | #--------------------------------------------------------------------------- | |
5 | ||
6 | buttonDefs = { | |
95bfd958 RD |
7 | 814 : ('GridSimple', ' Simple wx.Grid, catching all events '), |
8 | 815 : ('GridStdEdRend', ' wx.Grid showing Editors and Renderers '), | |
9 | 818 : ('GridHugeTable', ' A wx.Grid with a HUGE table (100 MILLION cells!) '), | |
10 | 817 : ('GridCustTable', ' wx.Grid using a custom Table, with non-string data '), | |
1e4a197e RD |
11 | 819 : ('GridEnterHandler',' Remapping keys to behave differently '), |
12 | 820 : ('GridCustEditor', ' Shows how to create a custom Cell Editor '), | |
95bfd958 | 13 | 821 : ('GridDragable', ' A wx.Grid with dragable rows and columns '), |
8fa876ca | 14 | 822 : ('GridDragAndDrop', ' Shows how to make a grid a drop target for files'), |
f6bcfd97 BP |
15 | } |
16 | ||
17 | ||
8fa876ca | 18 | class ButtonPanel(wx.Panel): |
f6bcfd97 | 19 | def __init__(self, parent, log): |
8fa876ca | 20 | wx.Panel.__init__(self, parent, -1) |
f6bcfd97 BP |
21 | self.log = log |
22 | ||
372bde9b | 23 | box = wx.BoxSizer(wx.VERTICAL) |
fbd5dd1d | 24 | box.Add((20, 20)) |
f6bcfd97 BP |
25 | keys = buttonDefs.keys() |
26 | keys.sort() | |
8fa876ca | 27 | |
f6bcfd97 BP |
28 | for k in keys: |
29 | text = buttonDefs[k][1] | |
8fa876ca RD |
30 | btn = wx.Button(self, k, text) |
31 | box.Add(btn, 0, wx.ALIGN_CENTER|wx.ALL, 10) | |
32 | self.Bind(wx.EVT_BUTTON, self.OnButton, btn) | |
f6bcfd97 | 33 | |
1e4a197e | 34 | self.SetAutoLayout(True) |
f6bcfd97 BP |
35 | self.SetSizer(box) |
36 | ||
37 | ||
38 | def OnButton(self, evt): | |
39 | modName = buttonDefs[evt.GetId()][0] | |
40 | module = __import__(modName) | |
83625579 | 41 | frame = module.TestFrame(None, self.log) |
1e4a197e | 42 | frame.Show(True) |
f6bcfd97 BP |
43 | |
44 | ||
45 | #--------------------------------------------------------------------------- | |
46 | ||
47 | def runTest(frame, nb, log): | |
48 | win = ButtonPanel(nb, log) | |
49 | return win | |
50 | ||
51 | #--------------------------------------------------------------------------- | |
52 | ||
53 | ||
54 | ||
f6bcfd97 BP |
55 | overview = """\ |
56 | <html><body> | |
95bfd958 | 57 | <h2>wx.Grid</h2> |
f6bcfd97 BP |
58 | |
59 | This demo shows various ways of using the <b><i>new and | |
95bfd958 | 60 | improved</i></b> wx.Grid class. Unfortunatly it has not been |
f6bcfd97 | 61 | documented yet, and while it is somewhat backwards compatible, if you |
95bfd958 | 62 | try to go by the current wx.Grid documentation you will probably just |
f6bcfd97 BP |
63 | confuse yourself. |
64 | <p> | |
65 | You can look at the sources for these samples to learn a lot about how | |
66 | the new classes work. | |
67 | <p><ol> | |
68 | <li><a href="GridSimple.py">GridSimple.py</a> A simple grid that shows | |
69 | how to catch all the various events. | |
70 | ||
71 | <p> | |
72 | <li><a href="GridStdEdRend.py">GridStdEdRend.py</a> A grid that | |
73 | uses non-default Cell Editors and Cell Renderers. | |
74 | ||
75 | <p> | |
76 | <li><a href="GridHugeTable.py">GridHugeTable.py</a> A grid that | |
77 | uses a non-default Grid Table. This table is read-only and simply | |
78 | generates on the fly a unique string for each cell. | |
79 | ||
80 | <p> | |
81 | <li><a href="GridCustTable.py">GridCustTable.py</a> This grid | |
82 | shows how to deal with tables that have non-string data, and how Cell | |
83 | Editors and Cell Renderers are automatically chosen based on the data | |
84 | type. | |
85 | ||
86 | <p> | |
87 | <li><a href="GridEnterHandler.py">GridEnterHandler.py</a>This one | |
88 | changes how the ENTER key works, moving the current cell left to right | |
89 | and wrapping around to the next row when needed. | |
90 | </ol> | |
91 | <p> | |
f6bcfd97 BP |
92 | |
93 | """ | |
94 | ||
f19533bf | 95 | |
f19533bf RD |
96 | if __name__ == '__main__': |
97 | import sys,os | |
98 | import run | |
8eca4fef | 99 | run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) |
f19533bf | 100 |