Python tkinter.SEL Examples
The following are 15
code examples of tkinter.SEL().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tkinter
, or try the search function
.
Example #1
Source File: window.py From LPHK with GNU General Public License v3.0 | 6 votes |
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"
Example #2
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
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)
Example #3
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
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)
Example #4
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
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)
Example #5
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
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)
Example #6
Source File: text_frame_gui.py From pyDEA with MIT License | 5 votes |
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'
Example #7
Source File: wb_runner.py From WhiteboxTools-ArcGIS with MIT License | 5 votes |
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'
Example #8
Source File: wb_runner.py From whitebox-python with MIT License | 5 votes |
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'
Example #9
Source File: chapter4_07.py From Tkinter-GUI-Application-Development-Cookbook with MIT License | 5 votes |
def copy_text(self): selection = self.text.tag_ranges(tk.SEL) if selection: self.clipboard_clear() self.clipboard_append(self.text.get(*selection))
Example #10
Source File: chapter4_07.py From Tkinter-GUI-Application-Development-Cookbook with MIT License | 5 votes |
def delete_text(self): selection = self.text.tag_ranges(tk.SEL) if selection: self.text.delete(*selection)
Example #11
Source File: chapter4_07_disabled.py From Tkinter-GUI-Application-Development-Cookbook with MIT License | 5 votes |
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
Example #12
Source File: chapter4_07_disabled.py From Tkinter-GUI-Application-Development-Cookbook with MIT License | 5 votes |
def copy_text(self): selection = self.text.tag_ranges(tk.SEL) if selection: self.clipboard_clear() self.clipboard_append(self.text.get(*selection))
Example #13
Source File: chapter4_07_disabled.py From Tkinter-GUI-Application-Development-Cookbook with MIT License | 5 votes |
def delete_text(self): selection = self.text.tag_ranges(tk.SEL) if selection: self.text.delete(*selection)
Example #14
Source File: chapter3_06.py From Tkinter-GUI-Application-Development-Cookbook with MIT License | 5 votes |
def add_hyperlink(self): selection = self.text.tag_ranges(tk.SEL) if selection: self.text.tag_add("link", *selection)
Example #15
Source File: codegui.py From dayworkspace with GNU Lesser General Public License v3.0 | 5 votes |
def selectText(self, event): self.lfc_field_1_t.tag_add(tkinter.SEL, "1.0", tkinter.END) return 'break' # 为什么要return 'break' # 上传代码 用base64进行加密