本文整理汇总了Python中ScrolledText.tag_remove方法的典型用法代码示例。如果您正苦于以下问题:Python ScrolledText.tag_remove方法的具体用法?Python ScrolledText.tag_remove怎么用?Python ScrolledText.tag_remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScrolledText
的用法示例。
在下文中一共展示了ScrolledText.tag_remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import tag_remove [as 别名]
#.........这里部分代码省略.........
self.editor.tag_add(SEL, start_pos, end_pos)
self.editor.mark_set(INSERT, end_pos) # mark the cursor to end of find text to start editing
self.editor.see(INSERT) # bing the cursor position in the viewport incase of long text causinng scrollbar
self.editor.focus_set() # strangely tkinter doesnt return focus after prompt
else:
tkMessageBox.showinfo("Textee", "No morw matches found")
else:
self.editor.focus_set() # strangely tkinter doesnt return focus after prompt
def find_and_replace(self):
#show the custom dialog
self.find_and_replace_dialog = TexteeFindAndReplaceDialog(self.master)
if self.find_and_replace_dialog.find_text:
start_pos = self.editor.search(self.find_and_replace_dialog.find_text, '1.0', stopindex=END, nocase=True)
# lazy recursive replace for all the matched elements, no need to parse whole dataset again and again
while start_pos:
self.editor.delete(start_pos, '%s+%sc' % (start_pos, len(self.find_and_replace_dialog.find_text)))
self.editor.insert(start_pos, self.find_and_replace_dialog.replace_with)
# break after first replace if replace all flag is off
if not self.find_and_replace_dialog.replace_all:
break
start_pos = self.editor.search(self.find_and_replace_dialog.find_text, '%s+%sc' % (start_pos, len(self.find_and_replace_dialog.replace_with)), stopindex=END, nocase=True)
def select_font(self):
self.font_dialog = TexteeFontDialog(self.master)
fs = 12 # default size for any font selected
if self.font_dialog.selected_font_family:
ff = self.font_dialog.selected_font_family
if self.font_dialog.selected_font_size:
fs = self.font_dialog.selected_font_size
print ff, fs, " - font properties"
if ff and fs > 0:
self.default_font = tkFont.Font(self.master, family=ff, size=fs)
self.editor.config(font=self.default_font)
def show_right_click_menu(self, event):
print 'going to display popmenu at', event.x_root, event.y_root
try:
self.editor.popmenu.tk_popup(event.x_root, event.y_root, 0)
finally:
# TODO: not sure why we need this, pasting it from the documentation. Later check to remove it
self.editor.popmenu.grab_release()
def spell_check(self):
# check if the dictonary exists in the system (only mac and linux have it at this location)
# TODO: to check on windows how to do?
print "inside the spell check"
if not os.path.exists('/usr/share/dict/words'):
return
with open('/usr/share/dict/words', 'r') as words_file:
system_words = words_file.read().split('\n')
current_file_lines = self.editor.get('1.0', END+'-1c').split('\n')
for lineno, current_line in enumerate(current_file_lines):
current_line_words = re.split('\W', current_line)
columnposition = 0 # this is to ignore the white space with which we split above, the marking of the invalid word should be be without the space
for word in current_line_words:
start_index = '%s.%s' % (lineno+1, columnposition)
end_index = '%s+%dc' % (start_index, len(word))
if word in system_words:
self.editor.tag_remove('misspelled', start_index, end_index)
else:
self.editor.tag_add('misspelled', start_index, end_index)
columnposition += len(word)+1 # take into account the space
def display_current_position(self):
cursor_position = self.editor.index("insert").replace('.', ',')
self.status_bar.update_status(cursor_position)
self.master.after(self.status_bar.update_interval, self.display_current_position)
def printer(self):
if not os.path.exists('/usr/bin/lpr'):
tkMessageBox.showerror('Printing is not supported with your operating system')
return
lpr = subprocess.Popen('/usr/bin/lpr', stdin=subprocess.PIPE)
text = self.editor.get('1.0', END+'-1c')
lpr.stdin.write(text)
lpr.stdin.close()
def new_window(self):
#allow multiple windows to be opened
root = Tkinter.Tk(className=" Textee")
root.title("Textee - A Stupid Text Editor")
app = Textee(root)
self.windows.append(app)
root.mainloop()
def about(self):
tkMessageBox.showinfo("About", "Textee - A stupid text editor")
def exit(self, master):
if tkMessageBox.askokcancel("Quit", "Are you sure?"):
master.destroy()