]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/FileBrowseButton.py
Fix compile error when building for Python 2.2
[wxWidgets.git] / wxPython / demo / FileBrowseButton.py
1 # 11/7/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2 #
3 # o Updated for wx namespace
4 # o Uncommented fbbhCallback in TestPanel.fbbh init. Appears to work fine.
5 # Wonder why it was commented.
6 # o Unrelated: TestPanel.dbb appears to cause a program error in the demo. If
7 # it is commented out, everything works fine. Investigating.
8 # o Bernhard has responded to query, does not plan on updating demo.
9 #
10 # 11/25/2003 - Jeff Grimmett (grimmtooth@softhome.net)
11 #
12 # o All issues, including the program error, have gone away in V2.5.
13 #
14
15 """ Demonstrate filebrowsebutton module of the wxPython.lib Library.
16
17 14.1.2001 Bernhard Reiter <bernhard@intevation.de>
18 Added demo for DirBrowseButton and improved overview text.
19 """
20
21 import wx
22 import wx.lib.filebrowsebutton as filebrowse
23
24 #----------------------------------------------------------------------
25
26 class TestPanel(wx.Panel):
27 def __init__(self, parent, ID, log):
28 wx.Panel.__init__(self, parent, ID)
29 self.log = log
30
31 self.fbb = filebrowse.FileBrowseButton(
32 self, -1, (20, 20), (450, -1), changeCallback = self.fbbCallback
33 )
34
35 self.fbbh = filebrowse.FileBrowseButtonWithHistory(
36 self, -1, (20, 50), (450, -1), changeCallback = self.fbbhCallback
37 )
38
39 self.dbb = filebrowse.DirBrowseButton(
40 self, -1, (20, 80), (450, -1), changeCallback = self.dbbCallback
41 )
42
43 self.fbbh.SetHistory(['You', 'can', 'put', 'some', 'file', 'names', 'here'])
44
45
46 def fbbCallback(self, evt):
47 self.log.write('FileBrowseButton: %s\n' % evt.GetString())
48
49
50 def fbbhCallback(self, evt):
51 if hasattr(self, 'fbbh'):
52 value = evt.GetString()
53 self.log.write('FileBrowseButtonWithHistory: %s\n' % value)
54 history = self.fbbh.GetHistory()
55 history.append(value)
56 self.fbbh.SetHistory(history)
57
58
59 def dbbCallback(self, evt):
60 self.log.write('DirBrowseButton: %s\n' % evt.GetString())
61
62
63 #----------------------------------------------------------------------
64
65 def runTest(frame, nb, log):
66 win = TestPanel(nb, -1, log)
67 return win
68
69
70 #----------------------------------------------------------------------
71
72 overview = """<html><body>
73 <h2>class FileBrowseButton:</h2>
74 <small><pre>
75 %s
76 </pre></small>
77
78 <h2>class FileBrowseButtonWithHistory(FileBrowseButton):</h2>
79 <small><pre>
80 %s
81 </pre></small>
82
83 <h2>class DirBrowseButton(FileBrowseButton):</h2>
84 <small><pre>
85 %s
86 </pre></small>
87
88 </body><</html>
89 """ % ( filebrowse.FileBrowseButton.__doc__,
90 filebrowse.FileBrowseButtonWithHistory.__doc__ ,
91 filebrowse.DirBrowseButton.__doc__
92 )
93
94
95 if __name__ == '__main__':
96 import sys,os
97 import run
98 run.main(['', os.path.basename(sys.argv[0])])
99