MCPcopy Index your code
hub / github.com/python/cpython / filter_command

Method filter_command

Lib/tkinter/filedialog.py:173–199  ·  view source on GitHub ↗
(self, event=None)

Source from the content-addressed store, hash-verified

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()

Callers 2

goMethod · 0.95
dirs_double_eventMethod · 0.95

Calls 14

get_filterMethod · 0.95
set_filterMethod · 0.95
get_selectionMethod · 0.95
set_selectionMethod · 0.95
listdirMethod · 0.80
fnmatchMethod · 0.80
bellMethod · 0.45
sortMethod · 0.45
joinMethod · 0.45
isdirMethod · 0.45
appendMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected