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