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

Class GrepDialog

Lib/idlelib/grep.py:64–189  ·  view source on GitHub ↗

Dialog for searching multiple files.

Source from the content-addressed store, hash-verified

62
63
64class GrepDialog(SearchDialogBase):
65 "Dialog for searching multiple files."
66
67 title = "Find in Files Dialog"
68 icon = "Grep"
69 needwrapbutton = 0
70
71 def __init__(self, root, engine, flist):
72 """Create search dialog for searching for a phrase in the file system.
73
74 Uses SearchDialogBase as the basis for the GUI and a
75 searchengine instance to prepare the search.
76
77 Attributes:
78 flist: filelist.Filelist instance for OutputWindow parent.
79 globvar: String value of Entry widget for path to search.
80 globent: Entry widget for globvar. Created in
81 create_entries().
82 recvar: Boolean value of Checkbutton widget for
83 traversing through subdirectories.
84 """
85 super().__init__(root, engine)
86 self.flist = flist
87 self.globvar = StringVar(root)
88 self.recvar = BooleanVar(root)
89
90 def open(self, text, searchphrase, io=None):
91 """Make dialog visible on top of others and ready to use.
92
93 Extend the SearchDialogBase open() to set the initial value
94 for globvar.
95
96 Args:
97 text: Multicall object containing the text information.
98 searchphrase: String phrase to search.
99 io: iomenu.IOBinding instance containing file path.
100 """
101 SearchDialogBase.open(self, text, searchphrase)
102 if io:
103 path = io.filename or ""
104 else:
105 path = ""
106 dir, base = os.path.split(path)
107 head, tail = os.path.splitext(base)
108 if not tail:
109 tail = ".py"
110 self.globvar.set(os.path.join(dir, "*" + tail))
111
112 def create_entries(self):
113 "Create base entry widgets and add widget for search path."
114 SearchDialogBase.create_entries(self)
115 self.globent = self.make_entry("In files:", self.globvar)[0]
116
117 def create_other_buttons(self):
118 "Add check button to recurse down subdirectories."
119 btn = Checkbutton(
120 self.make_frame()[0], variable=self.recvar,
121 text="Recurse down subdirectories")

Callers 1

grepFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…