]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/tests/fs_test.py
Always send an erase event to satisfy some users...
[wxWidgets.git] / wxPython / tests / fs_test.py
... / ...
CommitLineData
1
2
3from wxPython.wx import *
4import glob
5
6class File2(wxFileSystemHandler):
7
8 def CanOpen(self,location):
9 return self.GetProtocol(location) == "file2"
10
11 def OpenFile(self,fs,location):
12 return wxFSFile(wxInputStream(open(self.GetRightLocation(location),"rb")),
13 location,"text/plain","",wxDateTime())
14
15 def FindFirst(self,location,flags):
16 # the flags are ignored
17 self.files = glob.glob(self.GetRightLocation(location))
18 if len(self.files) == 0:
19 return ""
20 else:
21 return self.files[0]
22
23 def FindNext(self):
24 self.files = self.files[1:]
25 if len(self.files) == 0:
26 return ""
27 else:
28 return self.files[0]
29
30# register new handler
31wxFileSystem_AddHandler(File2())
32fs = wxFileSystem()
33
34# cat /etc/passwd
35print fs.OpenFile("file2:/projects/files.lst").GetStream().read()
36
37# ls /etc/*
38fn = fs.FindFirst("file2:/projects/*")
39while fn:
40 print fn
41 fn = fs.FindNext()