Mercurial > cpython-lru_cache-weakref
annotate Lib/idlelib/SearchDialogBase.py @ 80661:94de77bd0b4b 2.7
Issue #16194: document imp.load_dynamic problems
when read several extension modules from the same binary object file.
| author | Andrew Svetlov <andrew.svetlov@gmail.com> |
|---|---|
| date | Thu, 29 Nov 2012 19:51:28 +0200 |
| parents | b53604fad54b |
| children | 0d2b87ec9f2b |
| rev | line source |
|---|---|
|
47183
b53604fad54b
Tkinter rename reversal: remove tkinter package, adapt imports and docs.
Georg Brandl <georg@python.org>
parents:
47130
diff
changeset
|
1 from Tkinter import * |
| 13975 | 2 |
| 3 class SearchDialogBase: | |
| 4 | |
| 5 title = "Search Dialog" | |
| 6 icon = "Search" | |
| 7 needwrapbutton = 1 | |
| 8 | |
| 9 def __init__(self, root, engine): | |
| 10 self.root = root | |
| 11 self.engine = engine | |
| 12 self.top = None | |
| 13 | |
|
26068
868ff0dfabd2
By default when getting the search menu, the currently highligted
Chui Tey <chui.tey@advdata.com.au>
parents:
26026
diff
changeset
|
14 def open(self, text, searchphrase=None): |
| 13975 | 15 self.text = text |
| 16 if not self.top: | |
| 17 self.create_widgets() | |
| 18 else: | |
| 19 self.top.deiconify() | |
| 20 self.top.tkraise() | |
|
26068
868ff0dfabd2
By default when getting the search menu, the currently highligted
Chui Tey <chui.tey@advdata.com.au>
parents:
26026
diff
changeset
|
21 if searchphrase: |
|
868ff0dfabd2
By default when getting the search menu, the currently highligted
Chui Tey <chui.tey@advdata.com.au>
parents:
26026
diff
changeset
|
22 self.ent.delete(0,"end") |
|
868ff0dfabd2
By default when getting the search menu, the currently highligted
Chui Tey <chui.tey@advdata.com.au>
parents:
26026
diff
changeset
|
23 self.ent.insert("end",searchphrase) |
| 13975 | 24 self.ent.focus_set() |
| 25 self.ent.selection_range(0, "end") | |
| 26 self.ent.icursor(0) | |
| 27 self.top.grab_set() | |
| 28 | |
| 29 def close(self, event=None): | |
| 30 if self.top: | |
| 31 self.top.grab_release() | |
| 32 self.top.withdraw() | |
| 33 | |
| 34 def create_widgets(self): | |
| 35 top = Toplevel(self.root) | |
| 36 top.bind("<Return>", self.default_command) | |
| 37 top.bind("<Escape>", self.close) | |
| 38 top.protocol("WM_DELETE_WINDOW", self.close) | |
| 39 top.wm_title(self.title) | |
| 40 top.wm_iconname(self.icon) | |
| 41 self.top = top | |
| 42 | |
| 43 self.row = 0 | |
|
26026
0bda20afe623
Tidied up widget placement
Chui Tey <chui.tey@advdata.com.au>
parents:
25314
diff
changeset
|
44 self.top.grid_columnconfigure(0, pad=2, weight=0) |
|
0bda20afe623
Tidied up widget placement
Chui Tey <chui.tey@advdata.com.au>
parents:
25314
diff
changeset
|
45 self.top.grid_columnconfigure(1, pad=2, minsize=100, weight=100) |
| 13975 | 46 |
| 47 self.create_entries() | |
| 48 self.create_option_buttons() | |
| 49 self.create_other_buttons() | |
| 50 return self.create_command_buttons() | |
| 51 | |
| 52 def make_entry(self, label, var): | |
| 53 l = Label(self.top, text=label) | |
|
26310
baa47d7e84e2
Apply Nicolas Riley's Patch.
Kurt B. Kaiser <kbk@shore.net>
parents:
26068
diff
changeset
|
54 l.grid(row=self.row, column=0, sticky="nw") |
| 13975 | 55 e = Entry(self.top, textvariable=var, exportselection=0) |
|
26310
baa47d7e84e2
Apply Nicolas Riley's Patch.
Kurt B. Kaiser <kbk@shore.net>
parents:
26068
diff
changeset
|
56 e.grid(row=self.row, column=1, sticky="nwe") |
| 13975 | 57 self.row = self.row + 1 |
| 58 return e | |
| 59 | |
|
26026
0bda20afe623
Tidied up widget placement
Chui Tey <chui.tey@advdata.com.au>
parents:
25314
diff
changeset
|
60 def make_frame(self,labeltext=None): |
|
0bda20afe623
Tidied up widget placement
Chui Tey <chui.tey@advdata.com.au>
parents:
25314
diff
changeset
|
61 if labeltext: |
|
0bda20afe623
Tidied up widget placement
Chui Tey <chui.tey@advdata.com.au>
parents:
25314
diff
changeset
|
62 l = Label(self.top, text=labeltext) |
|
26310
baa47d7e84e2
Apply Nicolas Riley's Patch.
Kurt B. Kaiser <kbk@shore.net>
parents:
26068
diff
changeset
|
63 l.grid(row=self.row, column=0, sticky="nw") |
| 13975 | 64 f = Frame(self.top) |
|
26310
baa47d7e84e2
Apply Nicolas Riley's Patch.
Kurt B. Kaiser <kbk@shore.net>
parents:
26068
diff
changeset
|
65 f.grid(row=self.row, column=1, columnspan=1, sticky="nwe") |
| 13975 | 66 self.row = self.row + 1 |
| 67 return f | |
| 68 | |
|
26026
0bda20afe623
Tidied up widget placement
Chui Tey <chui.tey@advdata.com.au>
parents:
25314
diff
changeset
|
69 def make_button(self, label, command, isdef=0): |
| 13975 | 70 b = Button(self.buttonframe, |
| 71 text=label, command=command, | |
| 72 default=isdef and "active" or "normal") | |
|
26026
0bda20afe623
Tidied up widget placement
Chui Tey <chui.tey@advdata.com.au>
parents:
25314
diff
changeset
|
73 cols,rows=self.buttonframe.grid_size() |
|
0bda20afe623
Tidied up widget placement
Chui Tey <chui.tey@advdata.com.au>
parents:
25314
diff
changeset
|
74 b.grid(pady=1,row=rows,column=0,sticky="ew") |
|
0bda20afe623
Tidied up widget placement
Chui Tey <chui.tey@advdata.com.au>
parents:
25314
diff
changeset
|
75 self.buttonframe.grid(rowspan=rows+1) |
| 13975 | 76 return b |
| 77 | |
| 78 def create_entries(self): | |
| 79 self.ent = self.make_entry("Find:", self.engine.patvar) | |
| 80 | |
| 81 def create_option_buttons(self): | |
|
26026
0bda20afe623
Tidied up widget placement
Chui Tey <chui.tey@advdata.com.au>
parents:
25314
diff
changeset
|
82 f = self.make_frame("Options") |
| 13975 | 83 |
| 84 btn = Checkbutton(f, anchor="w", | |
| 85 variable=self.engine.revar, | |
| 86 text="Regular expression") | |
| 87 btn.pack(side="left", fill="both") | |
| 88 if self.engine.isre(): | |
| 89 btn.select() | |
| 90 | |
| 91 btn = Checkbutton(f, anchor="w", | |
| 92 variable=self.engine.casevar, | |
| 93 text="Match case") | |
| 94 btn.pack(side="left", fill="both") | |
| 95 if self.engine.iscase(): | |
| 96 btn.select() | |
| 97 | |
| 98 btn = Checkbutton(f, anchor="w", | |
| 99 variable=self.engine.wordvar, | |
| 100 text="Whole word") | |
| 101 btn.pack(side="left", fill="both") | |
| 102 if self.engine.isword(): | |
| 103 btn.select() | |
| 104 | |
| 105 if self.needwrapbutton: | |
| 106 btn = Checkbutton(f, anchor="w", | |
| 107 variable=self.engine.wrapvar, | |
| 108 text="Wrap around") | |
| 109 btn.pack(side="left", fill="both") | |
| 110 if self.engine.iswrap(): | |
| 111 btn.select() | |
| 112 | |
| 113 def create_other_buttons(self): | |
|
26026
0bda20afe623
Tidied up widget placement
Chui Tey <chui.tey@advdata.com.au>
parents:
25314
diff
changeset
|
114 f = self.make_frame("Direction") |
| 13975 | 115 |
|
26026
0bda20afe623
Tidied up widget placement
Chui Tey <chui.tey@advdata.com.au>
parents:
25314
diff
changeset
|
116 #lbl = Label(f, text="Direction: ") |
|
0bda20afe623
Tidied up widget placement
Chui Tey <chui.tey@advdata.com.au>
parents:
25314
diff
changeset
|
117 #lbl.pack(side="left") |
| 13975 | 118 |
| 119 btn = Radiobutton(f, anchor="w", | |
| 120 variable=self.engine.backvar, value=1, | |
| 121 text="Up") | |
| 122 btn.pack(side="left", fill="both") | |
| 123 if self.engine.isback(): | |
| 124 btn.select() | |
| 125 | |
| 126 btn = Radiobutton(f, anchor="w", | |
| 127 variable=self.engine.backvar, value=0, | |
| 128 text="Down") | |
| 129 btn.pack(side="left", fill="both") | |
| 130 if not self.engine.isback(): | |
| 131 btn.select() | |
| 132 | |
| 133 def create_command_buttons(self): | |
|
26026
0bda20afe623
Tidied up widget placement
Chui Tey <chui.tey@advdata.com.au>
parents:
25314
diff
changeset
|
134 # |
|
0bda20afe623
Tidied up widget placement
Chui Tey <chui.tey@advdata.com.au>
parents:
25314
diff
changeset
|
135 # place button frame on the right |
|
0bda20afe623
Tidied up widget placement
Chui Tey <chui.tey@advdata.com.au>
parents:
25314
diff
changeset
|
136 f = self.buttonframe = Frame(self.top) |
|
26310
baa47d7e84e2
Apply Nicolas Riley's Patch.
Kurt B. Kaiser <kbk@shore.net>
parents:
26068
diff
changeset
|
137 f.grid(row=0,column=2,padx=2,pady=2,ipadx=2,ipady=2) |
|
26026
0bda20afe623
Tidied up widget placement
Chui Tey <chui.tey@advdata.com.au>
parents:
25314
diff
changeset
|
138 |
|
0bda20afe623
Tidied up widget placement
Chui Tey <chui.tey@advdata.com.au>
parents:
25314
diff
changeset
|
139 b = self.make_button("close", self.close) |
| 13975 | 140 b.lower() |
