(self, event=None)
| 171 | self.quit(self.get_selection()) |
| 172 | |
| 173 | def filter_command(self, event=None): |
| 174 | dir, pat = self.get_filter() |
| 175 | try: |
| 176 | names = os.listdir(dir) |
| 177 | except OSError: |
| 178 | self.master.bell() |
| 179 | return |
| 180 | self.directory = dir |
| 181 | self.set_filter(dir, pat) |
| 182 | names.sort() |
| 183 | subdirs = [os.pardir] |
| 184 | matchingfiles = [] |
| 185 | for name in names: |
| 186 | fullname = os.path.join(dir, name) |
| 187 | if os.path.isdir(fullname): |
| 188 | subdirs.append(name) |
| 189 | elif fnmatch.fnmatch(name, pat): |
| 190 | matchingfiles.append(name) |
| 191 | self.dirs.delete(0, END) |
| 192 | for name in subdirs: |
| 193 | self.dirs.insert(END, name) |
| 194 | self.files.delete(0, END) |
| 195 | for name in matchingfiles: |
| 196 | self.files.insert(END, name) |
| 197 | head, tail = os.path.split(self.get_selection()) |
| 198 | if tail == os.curdir: tail = '' |
| 199 | self.set_selection(tail) |
| 200 | |
| 201 | def get_filter(self): |
| 202 | filter = self.filter.get() |
no test coverage detected