2003-12-09 01:23:28 +00:00
|
|
|
|
2001-02-16 08:19:50 +00:00
|
|
|
""" Demonstrate filebrowsebutton module of the wxPython.lib Library.
|
2000-07-15 19:51:35 +00:00
|
|
|
|
2001-02-16 08:19:50 +00:00
|
|
|
14.1.2001 Bernhard Reiter <bernhard@intevation.de>
|
|
|
|
Added demo for DirBrowseButton and improved overview text.
|
|
|
|
"""
|
2000-07-15 19:51:35 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
import wx
|
|
|
|
import wx.lib.filebrowsebutton as filebrowse
|
2000-07-15 19:51:35 +00:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
class TestPanel(wx.Panel):
|
2000-07-15 19:51:35 +00:00
|
|
|
def __init__(self, parent, ID, log):
|
2003-12-09 01:23:28 +00:00
|
|
|
wx.Panel.__init__(self, parent, ID)
|
2000-07-15 19:51:35 +00:00
|
|
|
self.log = log
|
2001-02-16 08:19:50 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
self.fbb = filebrowse.FileBrowseButton(
|
2005-01-13 20:46:17 +00:00
|
|
|
self, -1, size=(450, -1), changeCallback = self.fbbCallback
|
2003-12-09 01:23:28 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
self.fbbh = filebrowse.FileBrowseButtonWithHistory(
|
2005-01-13 20:46:17 +00:00
|
|
|
self, -1, size=(450, -1), changeCallback = self.fbbhCallback
|
2003-12-09 01:23:28 +00:00
|
|
|
)
|
2004-05-02 02:41:33 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
self.dbb = filebrowse.DirBrowseButton(
|
2005-01-13 20:46:17 +00:00
|
|
|
self, -1, size=(450, -1), changeCallback = self.dbbCallback
|
2003-12-09 01:23:28 +00:00
|
|
|
)
|
2000-07-15 19:51:35 +00:00
|
|
|
|
2005-12-30 23:02:03 +00:00
|
|
|
self.fbbh.callCallback = False
|
|
|
|
self.fbbh.SetHistory(['You', 'can', 'put', 'some', 'filenames', 'here'], 4)
|
2000-07-15 19:51:35 +00:00
|
|
|
|
2005-01-13 20:46:17 +00:00
|
|
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
|
|
|
sizer.Add(self.fbb, 0, wx.ALL, 5)
|
|
|
|
sizer.Add(self.fbbh, 0, wx.ALL, 5)
|
|
|
|
sizer.Add(self.dbb, 0, wx.ALL, 5)
|
|
|
|
box = wx.BoxSizer()
|
|
|
|
box.Add(sizer, 0, wx.ALL, 20)
|
|
|
|
self.SetSizer(box)
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
|
|
|
|
def fbbCallback(self, evt):
|
|
|
|
self.log.write('FileBrowseButton: %s\n' % evt.GetString())
|
|
|
|
|
|
|
|
|
|
|
|
def fbbhCallback(self, evt):
|
|
|
|
if hasattr(self, 'fbbh'):
|
|
|
|
value = evt.GetString()
|
2005-12-30 23:02:03 +00:00
|
|
|
if not value:
|
|
|
|
return
|
2000-07-15 19:51:35 +00:00
|
|
|
self.log.write('FileBrowseButtonWithHistory: %s\n' % value)
|
|
|
|
history = self.fbbh.GetHistory()
|
2004-05-02 02:41:33 +00:00
|
|
|
if value not in history:
|
|
|
|
history.append(value)
|
|
|
|
self.fbbh.SetHistory(history)
|
|
|
|
self.fbbh.GetHistoryControl().SetStringSelection(value)
|
2000-07-15 19:51:35 +00:00
|
|
|
|
2003-12-09 01:23:28 +00:00
|
|
|
|
2001-02-16 08:19:50 +00:00
|
|
|
def dbbCallback(self, evt):
|
|
|
|
self.log.write('DirBrowseButton: %s\n' % evt.GetString())
|
|
|
|
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
|
|
|
def runTest(frame, nb, log):
|
|
|
|
win = TestPanel(nb, -1, log)
|
|
|
|
return win
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
2001-02-16 08:19:50 +00:00
|
|
|
overview = """<html><body>
|
|
|
|
<h2>class FileBrowseButton:</h2>
|
|
|
|
<small><pre>
|
|
|
|
%s
|
|
|
|
</pre></small>
|
|
|
|
|
|
|
|
<h2>class FileBrowseButtonWithHistory(FileBrowseButton):</h2>
|
|
|
|
<small><pre>
|
|
|
|
%s
|
|
|
|
</pre></small>
|
|
|
|
|
|
|
|
<h2>class DirBrowseButton(FileBrowseButton):</h2>
|
|
|
|
<small><pre>
|
|
|
|
%s
|
|
|
|
</pre></small>
|
|
|
|
|
|
|
|
</body><</html>
|
2003-12-09 01:23:28 +00:00
|
|
|
""" % ( filebrowse.FileBrowseButton.__doc__,
|
|
|
|
filebrowse.FileBrowseButtonWithHistory.__doc__ ,
|
|
|
|
filebrowse.DirBrowseButton.__doc__
|
|
|
|
)
|
2003-07-02 23:13:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import sys,os
|
|
|
|
import run
|
2004-03-05 00:06:33 +00:00
|
|
|
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
2003-07-02 23:13:10 +00:00
|
|
|
|