Python tkinter.END Examples
The following are 30
code examples of tkinter.END().
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: textarea.py From Tkinter-GUI-Programming-by-Example with MIT License | 7 votes |
def find(self, text_to_find): length = tk.IntVar() idx = self.search(text_to_find, self.find_search_starting_index, stopindex=tk.END, count=length) if idx: self.tag_remove('find_match', 1.0, tk.END) end = f'{idx}+{length.get()}c' self.tag_add('find_match', idx, end) self.see(idx) self.find_search_starting_index = end self.find_match_index = idx else: if self.find_match_index != 1.0: if msg.askyesno("No more results", "No further matches. Repeat from the beginning?"): self.find_search_starting_index = 1.0 self.find_match_index = None return self.find(text_to_find) else: msg.showinfo("No Matches", "No matching text found")
Example #2
Source File: labelSettingsFrame.py From PyEveLiveDPS with GNU General Public License v3.0 | 7 votes |
def __init__(self, parent=None, title="", decimalPlaces=0, inThousands=0, *args, **kwargs): tk.Frame.__init__(self, parent, *args, **kwargs) gridFrame = self._nametowidget(parent.winfo_parent()) self.parent = self._nametowidget(gridFrame.winfo_parent()) self.grid(row="0", column="0", sticky="ew") self.columnconfigure(0,weight=1) self.singleLabel = singleLabel = tk.Label(self, text=title) singleLabel.grid(row="0",column="0", sticky="ew") self.listbox = listbox = tk.Spinbox(self, from_=0, to=9, width=1, borderwidth=1, highlightthickness=0) listbox.delete(0,tk.END) listbox.insert(0,decimalPlaces) listbox.grid(row="0", column="1") checkboxValue = tk.IntVar() checkboxValue.set(inThousands) self.checkbox = checkbox = tk.Checkbutton(self, text="K", variable=checkboxValue, borderwidth=0, highlightthickness=0) checkbox.var = checkboxValue checkbox.grid(row="0", column="2") singleLabel.bind("<Button-1>", lambda e:self.dragStart(e, listbox, checkbox))
Example #3
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 #4
Source File: Find.py From python-in-practice with GNU General Public License v3.0 | 6 votes |
def find(self, event=None): text = self.findEntry.get() assert text length = len(text) caseInsensitive = not self.caseSensitive.get() wholeWords = self.wholeWords.get() if wholeWords: text = r"\m{}\M".format(re.escape(text)) # Tcl regex syntax self.editor.tag_remove(FIND_TAG, "1.0", tk.END) insert = self.editor.index(tk.INSERT) start = self.editor.search(text, insert, nocase=caseInsensitive, regexp=wholeWords) if start and start == insert: start = self.editor.search(text, "{} +{} char".format( insert, length), nocase=caseInsensitive, regexp=wholeWords) if start: self.editor.mark_set(tk.INSERT, start) self.editor.see(start) end = "{} +{} char".format(start, length) self.editor.tag_add(FIND_TAG, start, end) return start, end return None, None
Example #5
Source File: demo.py From OpenCV-Python-Tutorial with MIT License | 6 votes |
def on_demo_select(self, evt): name = self.demos_lb.get( self.demos_lb.curselection()[0] ) fn = self.samples[name] loc = {} if PY3: exec(open(fn).read(), loc) else: execfile(fn, loc) descr = loc.get('__doc__', 'no-description') self.linker.reset() self.text.config(state='normal') self.text.delete(1.0, tk.END) self.format_text(descr) self.text.config(state='disabled') self.cmd_entry.delete(0, tk.END) self.cmd_entry.insert(0, fn)
Example #6
Source File: Editor.py From python-in-practice with GNU General Public License v3.0 | 6 votes |
def load(self, filename): self.delete("1.0", tk.END) try: with open(filename, "r", encoding="utf-8") as file: self.insert("1.0", file.read()) except EnvironmentError as err: self.set_status_text("Failed to load {}".format(filename)) return False self.mark_set(tk.INSERT, "1.0") self.edit_modified(False) self.edit_reset() self.master.title("{} \u2014 {}".format(os.path.basename(filename), APPNAME)) self.filename = filename self.set_status_text("Loaded {}".format(filename)) return True
Example #7
Source File: About.py From python-in-practice with GNU General Public License v3.0 | 6 votes |
def populate_text(self): self.text.insert(tk.END, "{}\n".format(APPNAME), ("title", "center")) self.text.insert(tk.END, "Copyright © 2012-13 Qtrac Ltd. " "All rights reserved.\n", ("center",)) self.text.insert(tk.END, "www.qtrac.eu/pipbook.html\n", ("center", "url", "above5")) self.add_lines(""" This program or module is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. It is provided for educational purposes and is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.""") self.add_lines(""" {} was inspired by tile fall/same game which was originally written for the Amiga and Psion by Adam Dawes.""".format(APPNAME)) self.text.insert(tk.END, "\n" + TkUtil.about(self.master, APPNAME, VERSION), ("versions", "center", "above3"))
Example #8
Source File: About.py From python-in-practice with GNU General Public License v3.0 | 6 votes |
def populate_text(self): self.text.insert(tk.END, "{}\n".format(APPNAME), ("title", "center")) self.text.insert(tk.END, "Copyright © 2012-13 Qtrac Ltd. " "All rights reserved.\n", ("center",)) self.text.insert(tk.END, "www.qtrac.eu/pipbook.html\n", ("center", "url", "above5")) self.add_lines(""" This program or module is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. It is provided for educational purposes and is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.""") self.text.insert(tk.END, "\n" + TkUtil.about(self.master, APPNAME, VERSION), ("versions", "center", "above3"))
Example #9
Source File: chatwindow.py From Tkinter-GUI-Programming-by-Example with MIT License | 6 votes |
def receive_message(self, message, smilies): """ Writes message into messages_area :param message: message text :param smilies: list of tuples of (char_index, smilie_file), where char_index is the x index of the smilie's location and smilie_file is the file name only (no path) :return: None """ self.messages_area.configure(state='normal') self.messages_area.insert(tk.END, message) if len(smilies): last_line_no = self.messages_area.index(tk.END) last_line_no = str(last_line_no).split('.')[0] last_line_no = str(int(last_line_no) - 2) for index, file in smilies: smilie_path = os.path.join(SmilieSelect.smilies_dir, file) image = tk.PhotoImage(file=smilie_path) smilie_index = last_line_no + '.' + index self.messages_area.image_create(smilie_index, image=image) self.messages_area.configure(state='disabled')
Example #10
Source File: settings.py From PyEveLiveDPS with GNU General Public License v3.0 | 6 votes |
def on_moved(self, event): if not event.dest_path.endswith('.json'): return try: currentProfileName = self.allSettings[self.selectedIndex.get()]["profile"] except AttributeError: return settingsFile = open(self.fullPath, 'r') self.allSettings = json.load(settingsFile) settingsFile.close() self.mainWindow.profileMenu.delete(0,tk.END) self.initializeMenu(self.mainWindow) i = 0 for profile in self.allSettings: if (profile["profile"] == currentProfileName): self.currentProfile = profile["profileSettings"] self.selectedIndex.set(i) self.mainWindow.event_generate('<<ChangeSettings>>') return i += 1 self.currentProfile = self.allSettings[0]["profileSettings"] self.selectedIndex.set(0) self.mainWindow.event_generate('<<ChangeSettings>>')
Example #11
Source File: textarea.py From Tkinter-GUI-Programming-by-Example with MIT License | 6 votes |
def find(self, text_to_find): length = tk.IntVar() idx = self.search(text_to_find, self.find_search_starting_index, stopindex=tk.END, count=length) if idx: self.tag_remove('find_match', 1.0, tk.END) end = f'{idx}+{length.get()}c' self.tag_add('find_match', idx, end) self.see(idx) self.find_search_starting_index = end self.find_match_index = idx else: if self.find_match_index != 1.0: if msg.askyesno("No more results", "No further matches. Repeat from the beginning?"): self.find_search_starting_index = 1.0 self.find_match_index = None return self.find(text_to_find) else: msg.showinfo("No Matches", "No matching text found")
Example #12
Source File: settings.py From PyEveLiveDPS with GNU General Public License v3.0 | 6 votes |
def addProfile(self, add=False, duplicate=False, rename=False): if (self.profileString.get() == "Default"): tk.messagebox.showerror("Error", "There can only be one profile named 'Default'") return for profile in self.allSettings: if self.profileString.get() == profile["profile"]: tk.messagebox.showerror("Error", "There is already a profile named '" + self.profileString.get() + "'") return if add: newProfile = copy.deepcopy(self.defaultProfile[0]) newProfile["profile"] = self.profileString.get() self.allSettings.insert(0, newProfile) elif duplicate: newProfile = copy.deepcopy(self.allSettings[self.selectedIndex.get()]) newProfile["profile"] = self.profileString.get() self.allSettings.insert(0, newProfile) elif rename: self.allSettings[self.selectedIndex.get()]["profile"] = self.profileString.get() self.allSettings.insert(0, self.allSettings.pop(self.selectedIndex.get())) self.mainWindow.profileMenu.delete(0,tk.END) self.initializeMenu(self.mainWindow) self.switchProfile() self.newProfileWindow.destroy()
Example #13
Source File: About.py From python-in-practice with GNU General Public License v3.0 | 6 votes |
def populate_text(self): self.text.insert(tk.END, "{}\n".format(APPNAME), ("title", "center")) self.text.insert(tk.END, "Copyright © 2012-13 Qtrac Ltd. " "All rights reserved.\n", ("center",)) self.text.insert(tk.END, "www.qtrac.eu/pipbook.html\n", ("center", "url", "above5")) self.add_lines(""" This program or module is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. It is provided for educational purposes and is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.""") self.text.insert(tk.END, "\n" + TkUtil.about(self.master, APPNAME, VERSION), ("versions", "center", "above3"))
Example #14
Source File: pynpuzzle.py From pynpuzzle with MIT License | 6 votes |
def spinbox_command(action): """ n input spinbox up and down handler. """ value = int(math.sqrt(int(n_spinbox.get()) + 1)) # If up button clicked if action == 'up': value += 1 # If down button clicked else: if value == 3: return value -= 1 value = value * value - 1 n_spinbox.delete(0, tkinter.END) n_spinbox.insert(0, value) change_app_n(value) # n spinbox
Example #15
Source File: viewer.py From networkx_viewer with GNU General Public License v3.0 | 6 votes |
def goto_path(self, event): frm = self.node_entry.get() to = self.node_entry2.get() self.node_entry.delete(0, tk.END) self.node_entry2.delete(0, tk.END) if frm == '': tkm.showerror("No From Node", "Please enter a node in both " "boxes to plot a path. Enter a node in only the first box " "to bring up nodes immediately adjacent.") return if frm.isdigit() and int(frm) in self.canvas.dataG.nodes(): frm = int(frm) if to.isdigit() and int(to) in self.canvas.dataG.nodes(): to = int(to) self.canvas.plot_path(frm, to, levels=self.level)
Example #16
Source File: map-creator.py From rpg-text with MIT License | 6 votes |
def load(self, x, y): name = "" for key, val in self.master.data.data.items(): if val.get('position') == [x, y]: name = key break if self.master.data.data[name] != {}: self.form_entries['Description'].delete('1.0', tk.END) self.form_entries["Description"].insert(tk.END, self.master.data.data[name]['description']) self.variables["Icon"].set(self.master.data.data[name]['map_icon']) self.variables["Location Name"].set(name) self.variables["NPCs"].set(" ".join(self.master.data.data[name]['npc'])) for e, en in zip(self.exits_var, self.exits_names): e.set(1 if en in self.master.data.data[name]['exits'] else 0) else: self.form_entries['Description'].delete('1.0', tk.END) self.variables["Icon"].set("") self.variables["Location Name"].set("") self.variables["NPCs"].set("") for e in self.exits_var: e.set(0)
Example #17
Source File: textarea.py From Tkinter-GUI-Programming-by-Example with MIT License | 6 votes |
def find(self, text_to_find): length = tk.IntVar() idx = self.search(text_to_find, self.find_search_starting_index, stopindex=tk.END, count=length) if idx: self.tag_remove('find_match', 1.0, tk.END) end = f'{idx}+{length.get()}c' self.tag_add('find_match', idx, end) self.see(idx) self.find_search_starting_index = end self.find_match_index = idx else: if self.find_match_index != 1.0: if msg.askyesno("No more results", "No further matches. Repeat from the beginning?"): self.find_search_starting_index = 1.0 self.find_match_index = None return self.find(text_to_find) else: msg.showinfo("No Matches", "No matching text found")
Example #18
Source File: settings.py From PyEveLiveDPS with GNU General Public License v3.0 | 5 votes |
def deleteProfileWindow(self): if (self.allSettings[self.selectedIndex.get()]["profile"] == "Default"): tk.messagebox.showerror("Error", "You can't delete the Default profile.") return okCancel = tk.messagebox.askokcancel("Continue?", "Are you sure you want to delete the current profile?") if not okCancel: return self.allSettings.pop(self.selectedIndex.get()) self.mainWindow.profileMenu.delete(0,tk.END) self.initializeMenu(self.mainWindow) self.switchProfile() self.currentProfile = self.allSettings[0]["profileSettings"]
Example #19
Source File: map-creator.py From rpg-text with MIT License | 5 votes |
def __init__(self, master=None): super().__init__(master) self.text = tk.Text(self, width=80, height=40) self.vsb = tk.Scrollbar(self, command=self.text.yview) self.text.pack(side=tk.LEFT, expand=True, fill=tk.BOTH) self.vsb.pack(side=tk.RIGHT, expand=True, fill=tk.Y) self.text.insert(tk.END, HELP_TXT) self.text.config(state=tk.DISABLED, xscrollcommand=self.vsb.set)
Example #20
Source File: Find.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
def close(self, event=None): self.editor.tag_remove(FIND_TAG, "1.0", tk.END) self.editor.tag_remove(REPLACE_TAG, "1.0", tk.END) self.withdraw()
Example #21
Source File: tgc_gui.py From TGC-Designer-Tools with Apache License 2.0 | 5 votes |
def tkinterPrintFunction(root, textfield, message): textfield.configure(state='normal') textfield.insert(tk.END, message + "\n") textfield.configure(state='disabled') textfield.see(tk.END) textfield.bind('<Button-3>', rightClickMenu, add='') root.update()
Example #22
Source File: gui.py From Telethon with MIT License | 5 votes |
def check_chat(self, event=None): """ Checks the input chat where to send and listen messages from. """ if self.me is None: return # Not logged in yet chat = self.chat.get().strip() try: chat = int(chat) except ValueError: pass try: old = self.chat_id # Valid chat ID, set it and configure the colour back to white self.chat_id = await self.cl.get_peer_id(chat) self.chat.configure(bg='white') # If the chat ID changed, clear the # messages that we could edit or reply if self.chat_id != old: self.message_ids.clear() self.sent_text.clear() self.log.delete('1.0', tkinter.END) if not self.me.bot: for msg in reversed( await self.cl.get_messages(self.chat_id, 100)): await self.on_message(msg) except ValueError: # Invalid chat ID, let the user know with a yellow background self.chat_id = None self.chat.configure(bg='yellow')
Example #23
Source File: gui.py From Telethon with MIT License | 5 votes |
def set_signed_in(self, me): """ Configures the application as "signed in" (displays user's name and disables the entry to input phone/bot token/code). """ self.me = me self.sign_in_label.configure(text='Signed in') self.sign_in_entry.configure(state=tkinter.NORMAL) self.sign_in_entry.delete(0, tkinter.END) self.sign_in_entry.insert(tkinter.INSERT, utils.get_display_name(me)) self.sign_in_entry.configure(state=tkinter.DISABLED) self.sign_in_button.configure(text='Log out') self.chat.focus() # noinspection PyUnusedLocal
Example #24
Source File: gui.py From Telethon with MIT License | 5 votes |
def sign_in(self, event=None): """ Note the `event` argument. This is required since this callback may be called from a ``widget.bind`` (such as ``'<Return>'``), which sends information about the event we don't care about. This callback logs out if authorized, signs in if a code was sent or a bot token is input, or sends the code otherwise. """ self.sign_in_label.configure(text='Working...') self.sign_in_entry.configure(state=tkinter.DISABLED) if await self.cl.is_user_authorized(): await self.cl.log_out() self.destroy() return value = self.sign_in_entry.get().strip() if self.code: self.set_signed_in(await self.cl.sign_in(code=value)) elif ':' in value: self.set_signed_in(await self.cl.sign_in(bot_token=value)) else: self.code = await self.cl.send_code_request(value) self.sign_in_label.configure(text='Code:') self.sign_in_entry.configure(state=tkinter.NORMAL) self.sign_in_entry.delete(0, tkinter.END) self.sign_in_entry.focus() return
Example #25
Source File: gui.py From Telethon with MIT License | 5 votes |
def on_message(self, event): """ Event handler that will add new messages to the message log. """ # We want to show only messages sent to this chat if event.chat_id != self.chat_id: return # Save the message ID so we know which to reply to self.message_ids.append(event.id) # Decide a prefix (">> " for our messages, "<user>" otherwise) if event.out: text = '>> ' else: sender = await event.get_sender() text = '<{}> '.format(sanitize_str( utils.get_display_name(sender))) # If the message has media show "(MediaType) " if event.media: text += '({}) '.format(event.media.__class__.__name__) text += sanitize_str(event.text) text += '\n' # Append the text to the end with a newline, and scroll to the end self.log.insert(tkinter.END, text) self.log.yview(tkinter.END) # noinspection PyUnusedLocal
Example #26
Source File: program6.py From python-gui-demos with MIT License | 5 votes |
def btn1func(self): self.entry.delete(0, tk.END) # delete all from 0 to END character in Entry Widget
Example #27
Source File: viewer.py From networkx_viewer with GNU General Public License v3.0 | 5 votes |
def get_node_list(self): """Get nodes in the node list and clear""" # See if we forgot to hit the plus sign if len(self.node_entry.get()) != 0: self.add_node() nodes = self.node_list.get(0, tk.END) self.node_list.delete(0, tk.END) return nodes
Example #28
Source File: viewer.py From networkx_viewer with GNU General Public License v3.0 | 5 votes |
def remove_filter(self, event=None): all_items = self.filter_list.get(0, tk.END) if event is None: # When no event passed, this function was called via the "clear" # button. items = all_items else: # Remove currently selected item items = (self.filter_list.get(tk.ANCHOR),) for item in items: self.canvas.remove_filter(item) idx = all_items.index(item) self.filter_list.delete(idx) all_items = self.filter_list.get(0, tk.END)
Example #29
Source File: viewer.py From networkx_viewer with GNU General Public License v3.0 | 5 votes |
def add_filter(self, event=None, filter_lambda=None): if filter_lambda is None: filter_lambda = self.filter_entry.get() if self.canvas.add_filter(filter_lambda): # We successfully added the filter; add to list and clear entry self.filter_list.insert(tk.END, filter_lambda) self.filter_entry.delete(0, tk.END)
Example #30
Source File: pynpuzzle.py From pynpuzzle with MIT License | 5 votes |
def fill_puzzle_frame(puzzle_frame, lst): """ Fills a puzzle frame with a puzzle list. """ global OUTPUT_EDITABLE lst = lst[:] lst = ['' if x == 0 else x for x in lst] # Enable editing the output puzzle temporarily OUTPUT_EDITABLE = True i = 0 for child in puzzle_frame.winfo_children(): child.delete(0, tkinter.END) child.insert(0, lst[i]) if puzzle_frame is output_puzzle_frame and lst[i] == '': child['highlightbackground'] = 'Orange' elif puzzle_frame is output_puzzle_frame: # Change the child's highlightbackground color to entry widget's default property using another # entry widget which we are sure has default property's value child['highlightbackground'] = output_step_text['highlightbackground'] i += 1 # Disable editing the output puzzle OUTPUT_EDITABLE = False