]>
Commit | Line | Data |
---|---|---|
8fa876ca | 1 | |
1b62f00d | 2 | """ Demonstrate filebrowsebutton module of the wxPython.lib Library. |
f6bcfd97 | 3 | |
1b62f00d RD |
4 | 14.1.2001 Bernhard Reiter <bernhard@intevation.de> |
5 | Added demo for DirBrowseButton and improved overview text. | |
6 | """ | |
f6bcfd97 | 7 | |
8fa876ca RD |
8 | import wx |
9 | import wx.lib.filebrowsebutton as filebrowse | |
f6bcfd97 BP |
10 | |
11 | #---------------------------------------------------------------------- | |
12 | ||
8fa876ca | 13 | class TestPanel(wx.Panel): |
f6bcfd97 | 14 | def __init__(self, parent, ID, log): |
8fa876ca | 15 | wx.Panel.__init__(self, parent, ID) |
f6bcfd97 | 16 | self.log = log |
1b62f00d | 17 | |
8fa876ca RD |
18 | self.fbb = filebrowse.FileBrowseButton( |
19 | self, -1, (20, 20), (450, -1), changeCallback = self.fbbCallback | |
20 | ) | |
21 | ||
22 | self.fbbh = filebrowse.FileBrowseButtonWithHistory( | |
23 | self, -1, (20, 50), (450, -1), changeCallback = self.fbbhCallback | |
24 | ) | |
d7403ad2 | 25 | |
8fa876ca RD |
26 | self.dbb = filebrowse.DirBrowseButton( |
27 | self, -1, (20, 80), (450, -1), changeCallback = self.dbbCallback | |
28 | ) | |
f6bcfd97 | 29 | |
d7403ad2 | 30 | self.fbbh.SetHistory(['You', 'can', 'put', 'some', 'filenames', 'here']) |
f6bcfd97 BP |
31 | |
32 | ||
33 | def fbbCallback(self, evt): | |
34 | self.log.write('FileBrowseButton: %s\n' % evt.GetString()) | |
35 | ||
36 | ||
37 | def fbbhCallback(self, evt): | |
38 | if hasattr(self, 'fbbh'): | |
39 | value = evt.GetString() | |
40 | self.log.write('FileBrowseButtonWithHistory: %s\n' % value) | |
41 | history = self.fbbh.GetHistory() | |
d7403ad2 RD |
42 | if value not in history: |
43 | history.append(value) | |
44 | self.fbbh.SetHistory(history) | |
45 | self.fbbh.GetHistoryControl().SetStringSelection(value) | |
f6bcfd97 | 46 | |
8fa876ca | 47 | |
1b62f00d RD |
48 | def dbbCallback(self, evt): |
49 | self.log.write('DirBrowseButton: %s\n' % evt.GetString()) | |
50 | ||
51 | ||
f6bcfd97 BP |
52 | #---------------------------------------------------------------------- |
53 | ||
54 | def runTest(frame, nb, log): | |
55 | win = TestPanel(nb, -1, log) | |
56 | return win | |
57 | ||
58 | ||
f6bcfd97 BP |
59 | #---------------------------------------------------------------------- |
60 | ||
1b62f00d RD |
61 | overview = """<html><body> |
62 | <h2>class FileBrowseButton:</h2> | |
63 | <small><pre> | |
64 | %s | |
65 | </pre></small> | |
66 | ||
67 | <h2>class FileBrowseButtonWithHistory(FileBrowseButton):</h2> | |
68 | <small><pre> | |
69 | %s | |
70 | </pre></small> | |
71 | ||
72 | <h2>class DirBrowseButton(FileBrowseButton):</h2> | |
73 | <small><pre> | |
74 | %s | |
75 | </pre></small> | |
76 | ||
77 | </body><</html> | |
8fa876ca RD |
78 | """ % ( filebrowse.FileBrowseButton.__doc__, |
79 | filebrowse.FileBrowseButtonWithHistory.__doc__ , | |
80 | filebrowse.DirBrowseButton.__doc__ | |
81 | ) | |
1fded56b RD |
82 | |
83 | ||
84 | if __name__ == '__main__': | |
85 | import sys,os | |
86 | import run | |
8eca4fef | 87 | run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) |
1fded56b | 88 |