本文整理汇总了Python中tkinter.END属性的典型用法代码示例。如果您正苦于以下问题:Python tkinter.END属性的具体用法?Python tkinter.END怎么用?Python tkinter.END使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类tkinter
的用法示例。
在下文中一共展示了tkinter.END属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import END [as 别名]
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")
示例2: receive_message
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import END [as 别名]
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')
示例3: load
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import END [as 别名]
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
示例4: goto_path
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import END [as 别名]
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)
示例5: load
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import END [as 别名]
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)
示例6: spinbox_command
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import END [as 别名]
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
示例7: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import END [as 别名]
def __init__(self, root, resource_dir, lang="fr"):
ttk.Frame.__init__(self, root)
self.resource_dir = resource_dir
self._lang = None
langs = os.listdir(os.path.join(self.resource_dir, "master"))
if langs:
self._lang = (lang if lang in langs else langs[0])
self.items = (os.listdir(os.path.join(self.resource_dir, "master", self._lang)) if self._lang else [])
self.items.sort(key=lambda x: x.lower())
max_length = max([len(item) for item in self.items])
self.select_workflow_label = ttk.Label(root, text=u"select workflow:")
#strVar = tkinter.StringVar()
self.masters = tkinter.Listbox(root, width=max_length+1, height=len(self.items))#, textvariable=strVar)
for item in self.items:
self.masters.insert(tkinter.END, item)
示例8: on_moved
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import END [as 别名]
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>>')
示例9: addProfile
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import END [as 别名]
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()
示例10: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import END [as 别名]
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))
示例11: on_demo_select
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import END [as 别名]
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)
示例12: populate_text
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import END [as 别名]
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"))
示例13: find
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import END [as 别名]
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
示例14: populate_text
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import END [as 别名]
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"))
示例15: populate_text
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import END [as 别名]
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"))