本文整理汇总了Python中tkinter.SEL属性的典型用法代码示例。如果您正苦于以下问题:Python tkinter.SEL属性的具体用法?Python tkinter.SEL怎么用?Python tkinter.SEL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类tkinter
的用法示例。
在下文中一共展示了tkinter.SEL属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: select_all
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import SEL [as 别名]
def select_all(self, event):
event.widget.tag_add(tk.SEL, "1.0", tk.END)
event.widget.mark_set(tk.INSERT, "1.0")
event.widget.see(tk.INSERT)
return "break"
示例2: on_selection
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import SEL [as 别名]
def on_selection(self, event=None):
state = (tk.NORMAL if self.editor.text.tag_ranges(tk.SEL)
else tk.DISABLED)
self.editMenu.entryconfigure(COPY, state=state)
self.copyButton.config(state=state)
self.editMenu.entryconfigure(CUT, state=state)
self.cutButton.config(state=state)
示例3: context_menu
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import SEL [as 别名]
def context_menu(self, event):
modifier = TkUtil.menu_modifier()
menu = tk.Menu(self.master)
if self.editor.text.tag_ranges(tk.SEL):
menu.add_command(label=COPY, underline=0,
command=lambda: self.editor.text.event_generate(
"<<Copy>>"), image=self.menuImages[COPY],
compound=tk.LEFT, accelerator=modifier + "+C")
menu.add_command(label=CUT, underline=2,
command=lambda: self.editor.text.event_generate(
"<<Cut>>"), image=self.menuImages[CUT],
compound=tk.LEFT, accelerator=modifier + "+X")
menu.add_command(label=PASTE, underline=0,
command=lambda: self.editor.text.event_generate(
"<<Paste>>"), image=self.menuImages[PASTE],
compound=tk.LEFT, accelerator=modifier + "+V")
menu.add_separator()
menu.add_checkbutton(label=BOLD, underline=0,
image=self.menuImages[BOLD], compound=tk.LEFT,
variable=self.bold,
command=lambda: self.toggle_button(self.boldButton))
menu.add_checkbutton(label=ITALIC, underline=0,
image=self.menuImages[ITALIC], compound=tk.LEFT,
variable=self.italic,
command=lambda: self.toggle_button(self.italicButton))
menu.add_separator()
menu.add_radiobutton(label=ALIGN_LEFT, underline=6,
image=self.menuImages[ALIGNLEFT], compound=tk.LEFT,
variable=self.alignment, value=tk.LEFT,
command=self.toggle_alignment)
menu.add_radiobutton(label=ALIGN_CENTER, underline=6,
image=self.menuImages[ALIGNCENTER],
compound=tk.LEFT, variable=self.alignment, value=tk.CENTER,
command=self.toggle_alignment)
menu.add_radiobutton(label=ALIGN_RIGHT, underline=6,
image=self.menuImages[ALIGNRIGHT],
compound=tk.LEFT, variable=self.alignment, value=tk.RIGHT,
command=self.toggle_alignment)
menu.tk_popup(event.x_root, event.y_root)
示例4: select_all
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import SEL [as 别名]
def select_all(self, event):
''' Selects all data in the text widget. This event is
called when user presses Control-Key-a or Control-Key-A.
Returns:
str: string break.
'''
self.text.tag_add(SEL, '1.0', END)
self.text.mark_set(INSERT, '1.0')
self.text.see(INSERT)
return 'break'
示例5: select_all
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import SEL [as 别名]
def select_all(self, event):
self.out_text.tag_add(tk.SEL, "1.0", tk.END)
self.out_text.mark_set(tk.INSERT, "1.0")
self.out_text.see(tk.INSERT)
return 'break'
示例6: copy_text
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import SEL [as 别名]
def copy_text(self):
selection = self.text.tag_ranges(tk.SEL)
if selection:
self.clipboard_clear()
self.clipboard_append(self.text.get(*selection))
示例7: delete_text
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import SEL [as 别名]
def delete_text(self):
selection = self.text.tag_ranges(tk.SEL)
if selection:
self.text.delete(*selection)
示例8: enable_selection
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import SEL [as 别名]
def enable_selection(self):
state_selection = tk.ACTIVE if self.text.tag_ranges(tk.SEL) else tk.DISABLED
state_clipboard = tk.ACTIVE
try:
self.clipboard_get()
except tk.TclError:
state_clipboard = tk.DISABLED
self.menu.entryconfig(0, state=state_selection) # Cut
self.menu.entryconfig(1, state=state_selection) # Copy
self.menu.entryconfig(2, state=state_clipboard) # Paste
self.menu.entryconfig(3, state=state_selection) # Delete
开发者ID:PacktPublishing,项目名称:Tkinter-GUI-Application-Development-Cookbook,代码行数:15,代码来源:chapter4_07_disabled.py
示例9: add_hyperlink
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import SEL [as 别名]
def add_hyperlink(self):
selection = self.text.tag_ranges(tk.SEL)
if selection:
self.text.tag_add("link", *selection)
示例10: selectText
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import SEL [as 别名]
def selectText(self, event):
self.lfc_field_1_t.tag_add(tkinter.SEL, "1.0", tkinter.END)
return 'break' # 为什么要return 'break'
# 上传代码 用base64进行加密