2 """ Demonstrate filebrowsebutton module of the wxPython.lib Library.
4 14.1.2001 Bernhard Reiter <bernhard@intevation.de>
5 Added demo for DirBrowseButton and improved overview text.
9 import wx
.lib
.filebrowsebutton
as filebrowse
11 #----------------------------------------------------------------------
13 class TestPanel(wx
.Panel
):
14 def __init__(self
, parent
, ID
, log
):
15 wx
.Panel
.__init
__(self
, parent
, ID
)
18 self
.fbb
= filebrowse
.FileBrowseButton(
19 self
, -1, (20, 20), (450, -1), changeCallback
= self
.fbbCallback
22 self
.fbbh
= filebrowse
.FileBrowseButtonWithHistory(
23 self
, -1, (20, 50), (450, -1), changeCallback
= self
.fbbhCallback
26 self
.dbb
= filebrowse
.DirBrowseButton(
27 self
, -1, (20, 80), (450, -1), changeCallback
= self
.dbbCallback
30 self
.fbbh
.SetHistory(['You', 'can', 'put', 'some', 'filenames', 'here'])
33 def fbbCallback(self
, evt
):
34 self
.log
.write('FileBrowseButton: %s\n' % evt
.GetString())
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()
42 if value
not in history
:
44 self
.fbbh
.SetHistory(history
)
45 self
.fbbh
.GetHistoryControl().SetStringSelection(value
)
48 def dbbCallback(self
, evt
):
49 self
.log
.write('DirBrowseButton: %s\n' % evt
.GetString())
52 #----------------------------------------------------------------------
54 def runTest(frame
, nb
, log
):
55 win
= TestPanel(nb
, -1, log
)
59 #----------------------------------------------------------------------
61 overview
= """<html><body>
62 <h2>class FileBrowseButton:</h2>
67 <h2>class FileBrowseButtonWithHistory(FileBrowseButton):</h2>
72 <h2>class DirBrowseButton(FileBrowseButton):</h2>
78 """ % ( filebrowse
.FileBrowseButton
.__doc
__,
79 filebrowse
.FileBrowseButtonWithHistory
.__doc
__ ,
80 filebrowse
.DirBrowseButton
.__doc
__
84 if __name__
== '__main__':
87 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])