Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
idlelib.ReplaceDialog.ReplaceDialog Class Reference
Inheritance diagram for idlelib.ReplaceDialog.ReplaceDialog:
Inheritance graph
[legend]
Collaboration diagram for idlelib.ReplaceDialog.ReplaceDialog:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def open
def create_entries
def create_command_buttons
def find_it
def replace_it
def default_command
def replace_all
def do_find
def do_replace
def show_hit
def close
def open
def create_widgets
def make_entry
def make_frame
def make_button
def create_option_buttons
def create_other_buttons

Public Attributes

 replvar
 ok
 replent
 root
 engine
 top
 text
 row
 ent
 buttonframe

Static Public Attributes

string title = "Replace Dialog"
string icon = "Replace"
int needwrapbutton = 1

Detailed Description

Definition at line 14 of file ReplaceDialog.py.


Constructor & Destructor Documentation

def idlelib.ReplaceDialog.ReplaceDialog.__init__ (   self,
  root,
  engine 
)

Reimplemented from idlelib.SearchDialogBase.SearchDialogBase.

Definition at line 19 of file ReplaceDialog.py.

00019 
00020     def __init__(self, root, engine):
00021         SearchDialogBase.__init__(self, root, engine)
00022         self.replvar = StringVar(root)

Here is the caller graph for this function:


Member Function Documentation

def idlelib.ReplaceDialog.ReplaceDialog.close (   self,
  event = None 
)

Reimplemented from idlelib.SearchDialogBase.SearchDialogBase.

Definition at line 166 of file ReplaceDialog.py.

00166 
00167     def close(self, event=None):
00168         SearchDialogBase.close(self, event)
00169         self.text.tag_remove("hit", "1.0", "end")

Here is the caller graph for this function:

Reimplemented from idlelib.SearchDialogBase.SearchDialogBase.

Definition at line 42 of file ReplaceDialog.py.

00042 
00043     def create_command_buttons(self):
00044         SearchDialogBase.create_command_buttons(self)
00045         self.make_button("Find", self.find_it)
00046         self.make_button("Replace", self.replace_it)
00047         self.make_button("Replace+Find", self.default_command, 1)
00048         self.make_button("Replace All", self.replace_all)

Here is the call graph for this function:

Reimplemented from idlelib.SearchDialogBase.SearchDialogBase.

Definition at line 38 of file ReplaceDialog.py.

00038 
00039     def create_entries(self):
00040         SearchDialogBase.create_entries(self)
00041         self.replent = self.make_entry("Replace with:", self.replvar)

Definition at line 81 of file SearchDialogBase.py.

00081 
00082     def create_option_buttons(self):
00083         f = self.make_frame("Options")
00084 
00085         btn = Checkbutton(f, anchor="w",
00086                 variable=self.engine.revar,
00087                 text="Regular expression")
00088         btn.pack(side="left", fill="both")
00089         if self.engine.isre():
00090             btn.select()
00091 
00092         btn = Checkbutton(f, anchor="w",
00093                 variable=self.engine.casevar,
00094                 text="Match case")
00095         btn.pack(side="left", fill="both")
00096         if self.engine.iscase():
00097             btn.select()
00098 
00099         btn = Checkbutton(f, anchor="w",
00100                 variable=self.engine.wordvar,
00101                 text="Whole word")
00102         btn.pack(side="left", fill="both")
00103         if self.engine.isword():
00104             btn.select()
00105 
00106         if self.needwrapbutton:
00107             btn = Checkbutton(f, anchor="w",
00108                     variable=self.engine.wrapvar,
00109                     text="Wrap around")
00110             btn.pack(side="left", fill="both")
00111             if self.engine.iswrap():
00112                 btn.select()

Here is the call graph for this function:

Reimplemented in idlelib.GrepDialog.GrepDialog.

Definition at line 113 of file SearchDialogBase.py.

00113 
00114     def create_other_buttons(self):
00115         f = self.make_frame("Direction")
00116 
00117         #lbl = Label(f, text="Direction: ")
00118         #lbl.pack(side="left")
00119 
00120         btn = Radiobutton(f, anchor="w",
00121                 variable=self.engine.backvar, value=1,
00122                 text="Up")
00123         btn.pack(side="left", fill="both")
00124         if self.engine.isback():
00125             btn.select()
00126 
00127         btn = Radiobutton(f, anchor="w",
00128                 variable=self.engine.backvar, value=0,
00129                 text="Down")
00130         btn.pack(side="left", fill="both")
00131         if not self.engine.isback():
00132             btn.select()

Here is the call graph for this function:

Reimplemented in idlelib.SearchDialog.SearchDialog.

Definition at line 34 of file SearchDialogBase.py.

00034 
00035     def create_widgets(self):
00036         top = Toplevel(self.root)
00037         top.bind("<Return>", self.default_command)
00038         top.bind("<Escape>", self.close)
00039         top.protocol("WM_DELETE_WINDOW", self.close)
00040         top.wm_title(self.title)
00041         top.wm_iconname(self.icon)
00042         self.top = top
00043 
00044         self.row = 0
00045         self.top.grid_columnconfigure(0, pad=2, weight=0)
00046         self.top.grid_columnconfigure(1, pad=2, minsize=100, weight=100)
00047 
00048         self.create_entries()
00049         self.create_option_buttons()
00050         self.create_other_buttons()
00051         return self.create_command_buttons()

def idlelib.ReplaceDialog.ReplaceDialog.default_command (   self,
  event = None 
)

Definition at line 56 of file ReplaceDialog.py.

00056 
00057     def default_command(self, event=None):
00058         if self.do_find(self.ok):
00059             self.do_replace()
00060             self.do_find(0)

Here is the call graph for this function:

Here is the caller graph for this function:

def idlelib.ReplaceDialog.ReplaceDialog.do_find (   self,
  ok = 0 
)

Definition at line 108 of file ReplaceDialog.py.

00108 
00109     def do_find(self, ok=0):
00110         if not self.engine.getprog():
00111             return False
00112         text = self.text
00113         res = self.engine.search_text(text, None, ok)
00114         if not res:
00115             text.bell()
00116             return False
00117         line, m = res
00118         i, j = m.span()
00119         first = "%d.%d" % (line, i)
00120         last = "%d.%d" % (line, j)
00121         self.show_hit(first, last)
00122         self.ok = 1
00123         return True

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 124 of file ReplaceDialog.py.

00124 
00125     def do_replace(self):
00126         prog = self.engine.getprog()
00127         if not prog:
00128             return False
00129         text = self.text
00130         try:
00131             first = pos = text.index("sel.first")
00132             last = text.index("sel.last")
00133         except TclError:
00134             pos = None
00135         if not pos:
00136             first = last = pos = text.index("insert")
00137         line, col = SearchEngine.get_line_col(pos)
00138         chars = text.get("%d.0" % line, "%d.0" % (line+1))
00139         m = prog.match(chars, col)
00140         if not prog:
00141             return False
00142         new = m.expand(self.replvar.get())
00143         text.mark_set("insert", first)
00144         text.undo_block_start()
00145         if m.group():
00146             text.delete(first, last)
00147         if new:
00148             text.insert(first, new)
00149         text.undo_block_stop()
00150         self.show_hit(first, text.index("insert"))
00151         self.ok = 0
00152         return True

Here is the call graph for this function:

Here is the caller graph for this function:

def idlelib.ReplaceDialog.ReplaceDialog.find_it (   self,
  event = None 
)

Definition at line 49 of file ReplaceDialog.py.

00049 
00050     def find_it(self, event=None):
00051         self.do_find(0)

Here is the call graph for this function:

Here is the caller graph for this function:

def idlelib.SearchDialogBase.SearchDialogBase.make_button (   self,
  label,
  command,
  isdef = 0 
) [inherited]

Definition at line 69 of file SearchDialogBase.py.

00069 
00070     def make_button(self, label, command, isdef=0):
00071         b = Button(self.buttonframe,
00072                    text=label, command=command,
00073                    default=isdef and "active" or "normal")
00074         cols,rows=self.buttonframe.grid_size()
00075         b.grid(pady=1,row=rows,column=0,sticky="ew")
00076         self.buttonframe.grid(rowspan=rows+1)
00077         return b

Here is the caller graph for this function:

def idlelib.SearchDialogBase.SearchDialogBase.make_entry (   self,
  label,
  var 
) [inherited]

Definition at line 52 of file SearchDialogBase.py.

00052 
00053     def make_entry(self, label, var):
00054         l = Label(self.top, text=label)
00055         l.grid(row=self.row, column=0, sticky="nw")
00056         e = Entry(self.top, textvariable=var, exportselection=0)
00057         e.grid(row=self.row, column=1, sticky="nwe")
00058         self.row = self.row + 1
00059         return e

def idlelib.SearchDialogBase.SearchDialogBase.make_frame (   self,
  labeltext = None 
) [inherited]

Definition at line 60 of file SearchDialogBase.py.

00060 
00061     def make_frame(self,labeltext=None):
00062         if labeltext:
00063             l = Label(self.top, text=labeltext)
00064             l.grid(row=self.row, column=0, sticky="nw")
00065         f = Frame(self.top)
00066         f.grid(row=self.row, column=1, columnspan=1, sticky="nwe")
00067         self.row = self.row + 1
00068         return f

Here is the caller graph for this function:

def idlelib.SearchDialogBase.SearchDialogBase.open (   self,
  text,
  searchphrase = None 
) [inherited]

Definition at line 14 of file SearchDialogBase.py.

00014 
00015     def open(self, text, searchphrase=None):
00016         self.text = text
00017         if not self.top:
00018             self.create_widgets()
00019         else:
00020             self.top.deiconify()
00021             self.top.tkraise()
00022         if searchphrase:
00023             self.ent.delete(0,"end")
00024             self.ent.insert("end",searchphrase)
00025         self.ent.focus_set()
00026         self.ent.selection_range(0, "end")
00027         self.ent.icursor(0)
00028         self.top.grab_set()

def idlelib.ReplaceDialog.ReplaceDialog.open (   self,
  text 
)

Definition at line 23 of file ReplaceDialog.py.

00023 
00024     def open(self, text):
00025         SearchDialogBase.open(self, text)
00026         try:
00027             first = text.index("sel.first")
00028         except TclError:
00029             first = None
00030         try:
00031             last = text.index("sel.last")
00032         except TclError:
00033             last = None
00034         first = first or text.index("insert")
00035         last = last or first
00036         self.show_hit(first, last)
00037         self.ok = 1

Here is the call graph for this function:

def idlelib.ReplaceDialog.ReplaceDialog.replace_all (   self,
  event = None 
)

Definition at line 61 of file ReplaceDialog.py.

00061 
00062     def replace_all(self, event=None):
00063         prog = self.engine.getprog()
00064         if not prog:
00065             return
00066         repl = self.replvar.get()
00067         text = self.text
00068         res = self.engine.search_text(text, prog)
00069         if not res:
00070             text.bell()
00071             return
00072         text.tag_remove("sel", "1.0", "end")
00073         text.tag_remove("hit", "1.0", "end")
00074         line = res[0]
00075         col = res[1].start()
00076         if self.engine.iswrap():
00077             line = 1
00078             col = 0
00079         ok = 1
00080         first = last = None
00081         # XXX ought to replace circular instead of top-to-bottom when wrapping
00082         text.undo_block_start()
00083         while 1:
00084             res = self.engine.search_forward(text, prog, line, col, 0, ok)
00085             if not res:
00086                 break
00087             line, m = res
00088             chars = text.get("%d.0" % line, "%d.0" % (line+1))
00089             orig = m.group()
00090             new = m.expand(repl)
00091             i, j = m.span()
00092             first = "%d.%d" % (line, i)
00093             last = "%d.%d" % (line, j)
00094             if new == orig:
00095                 text.mark_set("insert", last)
00096             else:
00097                 text.mark_set("insert", first)
00098                 if first != last:
00099                     text.delete(first, last)
00100                 if new:
00101                     text.insert(first, new)
00102             col = i + len(new)
00103             ok = 0
00104         text.undo_block_stop()
00105         if first and last:
00106             self.show_hit(first, last)
00107         self.close()

Here is the call graph for this function:

Here is the caller graph for this function:

def idlelib.ReplaceDialog.ReplaceDialog.replace_it (   self,
  event = None 
)

Definition at line 52 of file ReplaceDialog.py.

00052 
00053     def replace_it(self, event=None):
00054         if self.do_find(self.ok):
00055             self.do_replace()

Here is the call graph for this function:

Here is the caller graph for this function:

def idlelib.ReplaceDialog.ReplaceDialog.show_hit (   self,
  first,
  last 
)

Definition at line 153 of file ReplaceDialog.py.

00153 
00154     def show_hit(self, first, last):
00155         text = self.text
00156         text.mark_set("insert", first)
00157         text.tag_remove("sel", "1.0", "end")
00158         text.tag_add("sel", first, last)
00159         text.tag_remove("hit", "1.0", "end")
00160         if first == last:
00161             text.tag_add("hit", first)
00162         else:
00163             text.tag_add("hit", first, last)
00164         text.see("insert")
00165         text.update_idletasks()

Here is the caller graph for this function:


Member Data Documentation

Definition at line 136 of file SearchDialogBase.py.

Definition at line 11 of file SearchDialogBase.py.

Definition at line 79 of file SearchDialogBase.py.

Reimplemented from idlelib.SearchDialogBase.SearchDialogBase.

Definition at line 17 of file ReplaceDialog.py.

Reimplemented in idlelib.GrepDialog.GrepDialog.

Definition at line 7 of file SearchDialogBase.py.

Definition at line 36 of file ReplaceDialog.py.

Definition at line 40 of file ReplaceDialog.py.

Definition at line 21 of file ReplaceDialog.py.

Definition at line 10 of file SearchDialogBase.py.

Definition at line 43 of file SearchDialogBase.py.

Definition at line 15 of file SearchDialogBase.py.

Reimplemented from idlelib.SearchDialogBase.SearchDialogBase.

Definition at line 16 of file ReplaceDialog.py.

Definition at line 12 of file SearchDialogBase.py.


The documentation for this class was generated from the following file: