]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/FileBrowseButton.py
Undid last commit and restored bool argument to wxFrame::DoGiveHelp() as
[wxWidgets.git] / wxPython / demo / FileBrowseButton.py
CommitLineData
8fa876ca 1
1b62f00d 2""" Demonstrate filebrowsebutton module of the wxPython.lib Library.
f6bcfd97 3
1b62f00d
RD
414.1.2001 Bernhard Reiter <bernhard@intevation.de>
5 Added demo for DirBrowseButton and improved overview text.
6"""
f6bcfd97 7
8fa876ca
RD
8import wx
9import wx.lib.filebrowsebutton as filebrowse
f6bcfd97
BP
10
11#----------------------------------------------------------------------
12
8fa876ca 13class 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 18 self.fbb = filebrowse.FileBrowseButton(
a91fbc8e 19 self, -1, size=(450, -1), changeCallback = self.fbbCallback
8fa876ca
RD
20 )
21
22 self.fbbh = filebrowse.FileBrowseButtonWithHistory(
a91fbc8e 23 self, -1, size=(450, -1), changeCallback = self.fbbhCallback
8fa876ca 24 )
d7403ad2 25
8fa876ca 26 self.dbb = filebrowse.DirBrowseButton(
a91fbc8e 27 self, -1, size=(450, -1), changeCallback = self.dbbCallback
8fa876ca 28 )
f6bcfd97 29
02b800ce
RD
30 self.fbbh.callCallback = False
31 self.fbbh.SetHistory(['You', 'can', 'put', 'some', 'filenames', 'here'], 4)
f6bcfd97 32
a91fbc8e
RD
33 sizer = wx.BoxSizer(wx.VERTICAL)
34 sizer.Add(self.fbb, 0, wx.ALL, 5)
35 sizer.Add(self.fbbh, 0, wx.ALL, 5)
36 sizer.Add(self.dbb, 0, wx.ALL, 5)
37 box = wx.BoxSizer()
38 box.Add(sizer, 0, wx.ALL, 20)
39 self.SetSizer(box)
40
f6bcfd97
BP
41
42 def fbbCallback(self, evt):
43 self.log.write('FileBrowseButton: %s\n' % evt.GetString())
44
45
46 def fbbhCallback(self, evt):
47 if hasattr(self, 'fbbh'):
48 value = evt.GetString()
02b800ce
RD
49 if not value:
50 return
f6bcfd97
BP
51 self.log.write('FileBrowseButtonWithHistory: %s\n' % value)
52 history = self.fbbh.GetHistory()
d7403ad2
RD
53 if value not in history:
54 history.append(value)
55 self.fbbh.SetHistory(history)
56 self.fbbh.GetHistoryControl().SetStringSelection(value)
f6bcfd97 57
8fa876ca 58
1b62f00d
RD
59 def dbbCallback(self, evt):
60 self.log.write('DirBrowseButton: %s\n' % evt.GetString())
61
62
f6bcfd97
BP
63#----------------------------------------------------------------------
64
65def runTest(frame, nb, log):
66 win = TestPanel(nb, -1, log)
67 return win
68
69
f6bcfd97
BP
70#----------------------------------------------------------------------
71
1b62f00d
RD
72overview = """<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>
8fa876ca
RD
89""" % ( filebrowse.FileBrowseButton.__doc__,
90 filebrowse.FileBrowseButtonWithHistory.__doc__ ,
91 filebrowse.DirBrowseButton.__doc__
92 )
1fded56b
RD
93
94
95if __name__ == '__main__':
96 import sys,os
97 import run
8eca4fef 98 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
1fded56b 99