golden hour
/opt/alt/python37/lib64/python3.7/idlelib
⬆️ Go Up
Upload
File/Folder
Size
Actions
CREDITS.txt
1.82 KB
Del
OK
ChangeLog
55.04 KB
Del
OK
HISTORY.txt
10.07 KB
Del
OK
Icons
-
Del
OK
NEWS.txt
47.65 KB
Del
OK
NEWS2x.txt
26.54 KB
Del
OK
README.txt
9.37 KB
Del
OK
TODO.txt
8.28 KB
Del
OK
__init__.py
396 B
Del
OK
__main__.py
159 B
Del
OK
__pycache__
-
Del
OK
autocomplete.py
8.74 KB
Del
OK
autocomplete_w.py
19.64 KB
Del
OK
autoexpand.py
3.14 KB
Del
OK
browser.py
8.12 KB
Del
OK
calltip.py
6.17 KB
Del
OK
calltip_w.py
6.99 KB
Del
OK
codecontext.py
11.06 KB
Del
OK
colorizer.py
12.69 KB
Del
OK
config-extensions.def
2.21 KB
Del
OK
config-highlight.def
2.8 KB
Del
OK
config-keys.def
10.65 KB
Del
OK
config-main.def
3.09 KB
Del
OK
config.py
37.28 KB
Del
OK
config_key.py
14.13 KB
Del
OK
configdialog.py
102.07 KB
Del
OK
debugger.py
18.66 KB
Del
OK
debugger_r.py
11.86 KB
Del
OK
debugobj.py
3.96 KB
Del
OK
debugobj_r.py
1.06 KB
Del
OK
delegator.py
1.02 KB
Del
OK
dynoption.py
1.97 KB
Del
OK
editor.py
64.08 KB
Del
OK
extend.txt
3.56 KB
Del
OK
filelist.py
3.8 KB
Del
OK
format.py
15.41 KB
Del
OK
grep.py
7.3 KB
Del
OK
help.html
60.76 KB
Del
OK
help.py
11.46 KB
Del
OK
help_about.py
8.77 KB
Del
OK
history.py
3.95 KB
Del
OK
hyperparser.py
12.58 KB
Del
OK
idle.py
454 B
Del
OK
idle.pyw
570 B
Del
OK
idle_test
-
Del
OK
iomenu.py
20.15 KB
Del
OK
macosx.py
9.44 KB
Del
OK
mainmenu.py
3.83 KB
Del
OK
multicall.py
18.21 KB
Del
OK
outwin.py
5.65 KB
Del
OK
parenmatch.py
7.04 KB
Del
OK
pathbrowser.py
3.12 KB
Del
OK
percolator.py
3.06 KB
Del
OK
pyparse.py
19.48 KB
Del
OK
pyshell.py
55.91 KB
Del
OK
query.py
14.55 KB
Del
OK
redirector.py
6.71 KB
Del
OK
replace.py
9.66 KB
Del
OK
rpc.py
20.64 KB
Del
OK
run.py
19.82 KB
Del
OK
runscript.py
8.58 KB
Del
OK
scrolledlist.py
4.36 KB
Del
OK
search.py
5.44 KB
Del
OK
searchbase.py
7.36 KB
Del
OK
searchengine.py
7.3 KB
Del
OK
sidebar.py
13.27 KB
Del
OK
squeezer.py
12.54 KB
Del
OK
stackviewer.py
4.35 KB
Del
OK
statusbar.py
1.41 KB
Del
OK
textview.py
6.65 KB
Del
OK
tooltip.py
6.41 KB
Del
OK
tree.py
15.97 KB
Del
OK
undo.py
10.79 KB
Del
OK
window.py
2.55 KB
Del
OK
zoomheight.py
4.1 KB
Del
OK
zzdummy.py
961 B
Del
OK
Edit: searchbase.py
'''Define SearchDialogBase used by Search, Replace, and Grep dialogs.''' from tkinter import Toplevel from tkinter.ttk import Frame, Entry, Label, Button, Checkbutton, Radiobutton class SearchDialogBase: '''Create most of a 3 or 4 row, 3 column search dialog. The left and wide middle column contain: 1 or 2 labeled text entry lines (make_entry, create_entries); a row of standard Checkbuttons (make_frame, create_option_buttons), each of which corresponds to a search engine Variable; a row of dialog-specific Check/Radiobuttons (create_other_buttons). The narrow right column contains command buttons (make_button, create_command_buttons). These are bound to functions that execute the command. Except for command buttons, this base class is not limited to items common to all three subclasses. Rather, it is the Find dialog minus the "Find Next" command, its execution function, and the default_command attribute needed in create_widgets. The other dialogs override attributes and methods, the latter to replace and add widgets. ''' title = "Search Dialog" # replace in subclasses icon = "Search" needwrapbutton = 1 # not in Find in Files def __init__(self, root, engine): '''Initialize root, engine, and top attributes. top (level widget): set in create_widgets() called from open(). text (Text searched): set in open(), only used in subclasses(). ent (ry): created in make_entry() called from create_entry(). row (of grid): 0 in create_widgets(), +1 in make_entry/frame(). default_command: set in subclasses, used in create_widgets(). title (of dialog): class attribute, override in subclasses. icon (of dialog): ditto, use unclear if cannot minimize dialog. ''' self.root = root self.bell = root.bell self.engine = engine self.top = None def open(self, text, searchphrase=None): "Make dialog visible on top of others and ready to use." self.text = text if not self.top: self.create_widgets() else: self.top.deiconify() self.top.tkraise() self.top.transient(text.winfo_toplevel()) if searchphrase: self.ent.delete(0,"end") self.ent.insert("end",searchphrase) self.ent.focus_set() self.ent.selection_range(0, "end") self.ent.icursor(0) self.top.grab_set() def close(self, event=None): "Put dialog away for later use." if self.top: self.top.grab_release() self.top.transient('') self.top.withdraw() def create_widgets(self): '''Create basic 3 row x 3 col search (find) dialog. Other dialogs override subsidiary create_x methods as needed. Replace and Find-in-Files add another entry row. ''' top = Toplevel(self.root) top.bind("<Return>", self.default_command) top.bind("<Escape>", self.close) top.protocol("WM_DELETE_WINDOW", self.close) top.wm_title(self.title) top.wm_iconname(self.icon) self.top = top self.row = 0 self.top.grid_columnconfigure(0, pad=2, weight=0) self.top.grid_columnconfigure(1, pad=2, minsize=100, weight=100) self.create_entries() # row 0 (and maybe 1), cols 0, 1 self.create_option_buttons() # next row, cols 0, 1 self.create_other_buttons() # next row, cols 0, 1 self.create_command_buttons() # col 2, all rows def make_entry(self, label_text, var): '''Return (entry, label), . entry - gridded labeled Entry for text entry. label - Label widget, returned for testing. ''' label = Label(self.top, text=label_text) label.grid(row=self.row, column=0, sticky="nw") entry = Entry(self.top, textvariable=var, exportselection=0) entry.grid(row=self.row, column=1, sticky="nwe") self.row = self.row + 1 return entry, label def create_entries(self): "Create one or more entry lines with make_entry." self.ent = self.make_entry("Find:", self.engine.patvar)[0] def make_frame(self,labeltext=None): '''Return (frame, label). frame - gridded labeled Frame for option or other buttons. label - Label widget, returned for testing. ''' if labeltext: label = Label(self.top, text=labeltext) label.grid(row=self.row, column=0, sticky="nw") else: label = '' frame = Frame(self.top) frame.grid(row=self.row, column=1, columnspan=1, sticky="nwe") self.row = self.row + 1 return frame, label def create_option_buttons(self): '''Return (filled frame, options) for testing. Options is a list of searchengine booleanvar, label pairs. A gridded frame from make_frame is filled with a Checkbutton for each pair, bound to the var, with the corresponding label. ''' frame = self.make_frame("Options")[0] engine = self.engine options = [(engine.revar, "Regular expression"), (engine.casevar, "Match case"), (engine.wordvar, "Whole word")] if self.needwrapbutton: options.append((engine.wrapvar, "Wrap around")) for var, label in options: btn = Checkbutton(frame, variable=var, text=label) btn.pack(side="left", fill="both") return frame, options def create_other_buttons(self): '''Return (frame, others) for testing. Others is a list of value, label pairs. A gridded frame from make_frame is filled with radio buttons. ''' frame = self.make_frame("Direction")[0] var = self.engine.backvar others = [(1, 'Up'), (0, 'Down')] for val, label in others: btn = Radiobutton(frame, variable=var, value=val, text=label) btn.pack(side="left", fill="both") return frame, others def make_button(self, label, command, isdef=0): "Return command button gridded in command frame." b = Button(self.buttonframe, text=label, command=command, default=isdef and "active" or "normal") cols,rows=self.buttonframe.grid_size() b.grid(pady=1,row=rows,column=0,sticky="ew") self.buttonframe.grid(rowspan=rows+1) return b def create_command_buttons(self): "Place buttons in vertical command frame gridded on right." f = self.buttonframe = Frame(self.top) f.grid(row=0,column=2,padx=2,pady=2,ipadx=2,ipady=2) b = self.make_button("Close", self.close) b.lower() class _searchbase(SearchDialogBase): # htest # "Create auto-opening dialog with no text connection." def __init__(self, parent): import re from idlelib import searchengine self.root = parent self.engine = searchengine.get(parent) self.create_widgets() print(parent.geometry()) width,height, x,y = list(map(int, re.split('[x+]', parent.geometry()))) self.top.geometry("+%d+%d" % (x + 40, y + 175)) def default_command(self, dummy): pass if __name__ == '__main__': from unittest import main main('idlelib.idle_test.test_searchbase', verbosity=2, exit=False) from idlelib.idle_test.htest import run run(_searchbase)
Save