本文整理汇总了Python中ScrolledText.delete方法的典型用法代码示例。如果您正苦于以下问题:Python ScrolledText.delete方法的具体用法?Python ScrolledText.delete怎么用?Python ScrolledText.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScrolledText
的用法示例。
在下文中一共展示了ScrolledText.delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GredAboutBox
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import delete [as 别名]
class GredAboutBox(GatoDialogs.AboutBox):
def body(self, master):
self.resizable(0,0)
self.catIconImage = PhotoImage(data=GatoIcons.gred)
self.catIcon = Label(master, image=self.catIconImage)
self.catIcon.pack(side=TOP)
label = Label(master, text=GatoDialogs.crnotice1)
label.pack(side=TOP)
label = Label(master, font="Helvetica 10",
text=GatoDialogs.crnotice2, justify=CENTER)
label.pack(side=TOP)
color = self.config("bg")[4]
self.infoText = ScrolledText(master, relief=FLAT,
padx=3, pady=3,
background=color,
#foreground="black",
wrap='word',
width=60, height=12,
font="Times 10")
self.infoText.pack(expand=0, fill=X, side=BOTTOM)
self.infoText.delete('0.0', END)
self.infoText.insert('0.0', GatoGlobals.gLGPLText)
self.infoText.configure(state=DISABLED)
self.title("Gred - About")
示例2: Add_Group
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import delete [as 别名]
class Add_Group(Frame):
def __init__(self, parent, app):
Frame.__init__(self, parent)
self.parent = parent
self.app = app
#Frame to hold Keyword Group new Entry and new keywords text box
addKGFrame = Frame(parent, bg="#E8E8E8", relief=RAISED)
addKGFrame.pack(fill=BOTH, expand=True, side=LEFT, padx=10, pady=10)
#Label for Entry Box
addGroupLabel = Label(addKGFrame, text="Enter New Group Name",bg="#E8E8E8")
addGroupLabel.pack(side=TOP)
#Entry Box for new Keyword Group
self.addGroup = Entry(addKGFrame, width=30, relief=SUNKEN)
self.addGroup.pack(side=TOP, fill=X, expand=True, pady=5)
#Label for New Keywords for Group Text Box
addKGLabel = Label(addKGFrame, text="Enter New Keywords (Optional)",bg="#E8E8E8")
addKGLabel.pack(side=TOP, fill=X, expand=True, pady=5)
#Canvas for Text Box to Enter New Keywords for New Group
addKGCanvas = Canvas(addKGFrame, bg="#E8E8E8", relief=SUNKEN)
addKGCanvas.pack(side=TOP, fill=BOTH, expand=True, pady=5)
#Keywords for new group scrollable text box
self.addKGText = ScrolledText(addKGCanvas, wrap=WORD, width=25,
height=15, relief=SUNKEN, highlightthickness=0, bd=1, padx=1, pady=1)
self.addKGText.pack(fill=BOTH, side=TOP, expand=True)
#Button to add new Keyword Group and Keywords
addKGButton = Button(addKGFrame, text="Add Group",
width=30, highlightbackground='#E8E8E8', command=self.group_add)
addKGButton.pack(side=TOP, fill=BOTH, expand=True)
#Function to add the keyword group
def group_add(self):
newGroup = self.addGroup.get()
if newGroup != "":
self.app.key_group.keyword_groups[newGroup] = []
text = self.addKGText.get('1.0', 'end-1c').splitlines()
for line in text:
self.app.key_group.keyword_groups[newGroup].append(line)
self.app.Groups.groupList.delete(0, END)
for x in self.app.key_group.keyword_groups:
self.app.Groups.groupList.insert(END, '%s' % x)
self.addKGText.delete('1.0', END)
self.addGroup.delete(0, END)
示例3: LogWindow
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import delete [as 别名]
class LogWindow(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.master.title("Network Simulator Log")
self.text = ScrolledText(self)
self.text.pack(fill=BOTH, expand=1)
self.pack(fill=BOTH, expand=1)
self.text.config(
background="black",
foreground="white",
font=Font(
family="Courier", weight="bold"),
# state=DISABLED,
wrap=NONE, )
self.text.tag_config("DEBUG", foreground="green")
self.text.tag_config("ERROR", foreground="red")
self.text.tag_config("CRITICAL", foreground="red")
self.text.tag_config("EXCEPTION", foreground="red")
self.text.tag_config("WARNING", foreground="yellow")
self.text.tag_config("INFO", foreground="white")
self.text.bind("<Key>", lambda e: 'break')
self.text.bind("<Return>", self._clear)
self.queue = Queue()
self._update()
def _clear(self, event):
self.text.delete(1.0, END)
return 'break'
def _update(self):
try:
while True:
text, level = self.queue.get(block=False)
at_bottom = self.text.yview()[1] == 1.0
# self.text.config(state=NORMAL)
if len(self.text.get(1.0, END).strip()) != 0:
text = "\n" + text
self.text.insert(END, text, str(level))
# self.text.config(state=DISABLED)
if at_bottom:
self.text.yview_moveto(1.0)
except Empty:
pass
self.after(50, self._update)
def append(self, entry, level="INFO"):
self.queue.put((entry, level))
示例4: PyGrbl_Editor
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import delete [as 别名]
class PyGrbl_Editor(Frame):
def __init__(self, master, app):
Frame.__init__(self, master = master)
## WHO AM I ?
#print("Who am I: " + self.winfo_class()) # = 'Frame' !!
#print("Who is my master: " + master.__class__.__name__) # = Frame
#print("Who is my app: " + app.__class__.__name__) # = PyGrbl_GUI
#print("Who am I: " + self.__class__.__name__) # = 'PyGrbl_Editor'
self.app = app
self.app.servicemenu.entryconfig("Editor", state = "normal")
self.app.apps.append(self.__class__.__name__)
self.openFileTrace = self.app.fileOpenFlag.trace_variable('w', self.fileOpenTraceAction)
self.editorWaiting = False # to prevent conflict gCodeChecker & Editor 'fileOpenTrace'
self.createEditorWidgets()
self.master.rowconfigure(0, weight = 1)
self.master.columnconfigure(0, weight = 1)
self.grid(column = 0, row = 0, sticky = (N, S, W, E))
def createEditorWidgets(self):
# Text Pad
self.textPad = ScrolledText(self, width = 30, height = 10, font = "TkTextFont")
self.textPad.grid(row = 0, column = 0, padx = 10, pady = 10, sticky = (N, S, W, E))
self.columnconfigure(0, weight = 1)
self.rowconfigure(0, weight = 1)
self.save = Button(self, text = "Save", width = 6, command = lambda: self.saveFile())
self.save.grid(row = 0, column = 1, padx = 10, pady = 10, sticky = N)
def fileOpenTraceAction(self, name, index, mode):
try:
if self.app.fileOpenFlag.get() == True:
if self.app.currentApp == self.app.Editor:
contents = self.app.inFile.read()
contents = contents.replace('\r', '')
self.app.inFile.seek(0) # reset inFile cursor to top of file
self.textPad.insert(1.0, contents)
elif self.editorWaiting:
contents = self.app.inFile.read()
self.app.inFile.seek(0) # reset inFile cursor to top of file
self.textPad.insert(1.0, contents)
self.editorWaiting = False
else:
self.editorWaiting = True
self.after(1000, self.fileOpenTraceAction(name, index, mode))
elif self.app.fileOpenFlag.get() == False:
self.textPad.delete(1.0, END)
if self.app.debugMode > 1: print("fileOpenTraceAction: Ok")
except:
print("fileOpenTraceAction: Error")
def saveFile(self):
filename = asksaveasfile(mode = 'w')
if filename:
data = self.textPad.get(1.0, END+'-1c')
filename.write(data)
filename.close()
示例5: Wiki_Window
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import delete [as 别名]
class WikiPedia:
def Wiki_Window(self, window):
self.window = window
self.window.geometry("1500x1500")
def Notebook(self):
self.notebook = ttk.Notebook(self.window)
self.framePyRat = ttk.Frame(self.notebook, width=2500, height=1000)
self.frameAbout = ttk.Frame(self.notebook, width=2500, height=1000)
self.notebook.add(self.framePyRat, text='PyPedia')
self.notebook.add(self.frameAbout, text='About')
self.notebook.grid(row=0)
def Design(self):
ttk.Labelframe(self.window, width=1350, height=140).grid(row=0, sticky = NW)
Label(self.window, text="Welcome To PyPedia",font=("Helvetica",20)).grid(row=0, column=0, sticky = NW, pady=50, padx = 450)
image = Image.open("wikilogo.png")
photo = ImageTk.PhotoImage(image)
label = Label(image=photo)
label.image = photo
label.grid(row=0, column=0, sticky = NW, padx=1150)
def search(self):
global infowiki
infowiki = StringVar()
ttk.Labelframe(self.window, width=1350, height=600).grid(row=0, sticky = NW, pady=150, column=0)
ttk.Labelframe(self.window, width=500, height=300).grid(row=0, sticky = NW, pady=174, column=0, padx=800)
ttk.Labelframe(self.window, width=750, height=600).grid(row=0, sticky = NW, pady=174, column=0, padx=20)
self.WikiInfo = ScrolledText(self.window, width=65,height=18, bd=7,font=("Helvetica",15))
self.WikiInfo.grid(row=0, sticky = NW, pady=280, column=0, padx=20)
self.WikiInfo.insert(END, "Please Search For Content\n")
def Content(self):
global infowiki
infowiki = StringVar()
Label(self.window, text="Search:: ",font=("Helvetica",18)).grid(row=0, column=0, sticky = NW, pady=210, padx=30)
Entry(self.window, width=30, bd=4,textvariable=infowiki, font=("Helvetica",15)).grid(row=0, column=0, sticky = NW, pady=210, padx=140, ipady=3)
Button(self.window,text="Go", bd=5, command = self.thread).grid(row=0, column=0, sticky = NW, pady=210, padx=500, ipady=1, ipadx=20)
self.snip = Spinbox(self.window, from_=0, to=1000, width=10)
self.snip.grid(row=0, column=0, sticky = NW, pady=215, padx=590, ipady=1, ipadx=20)
Label(self.window, text="Sentence::",font=("Helvetica",12)).grid(row=0, column=0, sticky = NW, pady=190, padx=595)
ttk.Labelframe(self.window, width=500, height=300).grid(row=0, sticky = NW, pady=480,padx=800, column=0)
Label(self.window, text="Information ",font=("Helvetica",18)).grid(row=0, column=0, sticky = NW, pady=500, padx=815)
Label(self.window, text="Image (0)(0)",font=("Helvetica",18)).grid(row=0, column=0, sticky = NW, pady=160, padx=970)
def Info(self):
Label(self.window, text="Title :",font=("Helvetica",15)).grid(row=0, column=0, sticky = NW, pady=540, padx=815)
Label(self.window, text="Url :",font=("Helvetica",15)).grid(row=0, column=0, sticky = NW, pady=580, padx=815)
Label(self.window, text="Total Image In Url :",font=("Helvetica",15)).grid(row=0, column=0, sticky = NW, pady=625, padx=815)
Label(self.window, text="Main Image :",font=("Helvetica",15)).grid(row=0, column=0, sticky = NW, pady=670, padx=815)
def GoSearch(self):
try:
text = " "
Label(self.window, text=text,font=("Helvetica",12)).grid(row=0, column=0, sticky = NW, pady=540, padx=870)
Label(self.window, text=text,font=("Helvetica",12)).grid(row=0, column=0, sticky = NW, pady=580, padx=860)
Label(self.window, text=text,font=("Helvetica",12)).grid(row=0, column=0, sticky = NW, pady=625, padx=985)
Label(self.window, text=text,font=("Helvetica",12)).grid(row=0, column=0, sticky = NW, pady=670, padx=940)
self.WikiInfo.delete(1.0, END)
self.WikiInfo.insert(END, "Title :: "+infowiki.get())
self.WikiInfo.insert(END, "\n")
self.WikiInfo.insert(END, "\n")
WikiData.wikiSearch(infowiki.get(), self.snip.get())
self.WikiInfo.insert(END, WikiData.GivingFuck())
self.Info()
Label(self.window, text=WikiData.title(),font=("Helvetica",12)).grid(row=0, column=0, sticky = NW, pady=540, padx=870)
Label(self.window, text=WikiData.url(),font=("Helvetica",12)).grid(row=0, column=0, sticky = NW, pady=580, padx=860)
Label(self.window, text=WikiData.imageAll(),font=("Helvetica",12)).grid(row=0, column=0, sticky = NW, pady=625, padx=985)
Label(self.window, text=WikiData.imageFront(),font=("Helvetica",12)).grid(row=0, column=0, sticky = NW, pady=670, padx=940)
WikiData.getImage()
WikiData.ResizeImage()
image = Image.open("RE_IMAGE.png")
photo = ImageTk.PhotoImage(image)
self.label = Label(image=photo, bd=8)
self.label.image = photo
self.label.grid(row=0, column=0, sticky = NW, pady=200, padx=830 )
#.........这里部分代码省略.........
示例6: MemoPadFrame
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import delete [as 别名]
class MemoPadFrame( Frame ):
def __init__(self, master=None):
Frame.__init__(self, master)
# Modelの初期化
self.version = (0, 2, 5)
self.memos = MemoPad()
self.memos.addObserver(self)
# change-logger のバインド
self.changeLogger = ChangeLogger()
self.memos.addObserver( self.changeLogger )
# View-Controller の初期化
self.master.title( 'MemoPad %d.%d.%d' % self.version )
self.make_listPanel(self)
self.make_editAria(self)
self.pack(fill=BOTH)
# データの復帰
self.memos.loadImage()
def bye():
self.saveMemo() # 現在編集中のメモをセーブ
self.memos.saveImage()
print 'bye'
self.master.destroy()
self.master.protocol('WM_DELETE_WINDOW', bye )
def make_listPanel(self, parent):
frm = Frame(parent)
# リストの生成・配置
def changeTarget(evt):
try: index = int(self.memoList.curselection()[0])
except: index = None
self.saveMemo()
if index != None: self.selectMemo( index )
self.memoList = ScrolledListbox(frm,
selectmode=BROWSE,
width=72,
height=7 )
self.memoList.bind("<ButtonRelease>", changeTarget )
self.memoList.bind('<B1-Motion>', changeTarget )
self.memoList.pack(side=LEFT, fill=BOTH)
# ボタンの作成
btnfrm = Frame(frm)
def appendMemo():
self.saveMemo()
self.memos.appendMemo()
Button( btnfrm,
text='new',
command=appendMemo ).pack(side=TOP, fill=X)
def deleteMemo():
self.saveMemo()
self.memos.removeMemo()
Button( btnfrm,
text='delete',
command=deleteMemo ).pack(side=TOP, fill=X)
btnfrm.pack(side=LEFT)
frm.pack(side=TOP, fill=X)
def make_editAria(self, parent):
self.text = ScrolledText( parent )
self.text.pack(side=TOP, fill=BOTH)
def updateTitle(evt):
'''実験コード。まだ
改行や行末改行の削除に弱いです
'''
# print self.text.index('1.end')
# print self.text.index(INSERT)
if self.text.index(INSERT).split('.')[0] == '1': # 1行目
itemnum = self.memos.getSelectedIndex()
self.memoList.delete(itemnum)
self.memoList.insert(itemnum,
"%s | %s" % (self.memos[itemnum].getDatetime().strftime("%Y-%m-%d %H:%M"),
u'%s%s%s' % ( self.text.get('1.0', INSERT),
#.........这里部分代码省略.........
示例7: __init__
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import delete [as 别名]
class SimpleTextEditor:
def __init__(self, parent):
self.parent = parent
self.textWidget = ScrolledText(parent, width=80, height=50, font=(tkFont.Font(family= "Consolas", size= "12")))
self.textWidget.pack()
self.menuBar = tk.Menu(parent, tearoff=0)
# About Menu
self.about_menu = tk.Menu(self.menuBar, tearoff= 0)
self.menuBar.add_cascade(label= "Text Perfect", menu= self.about_menu)
self.about_menu.add_command(label= "About", command= self.about_command)
# File Menu
self.file_menu = tk.Menu(self.menuBar, tearoff = 0)
self.menuBar.add_cascade(label = "File", menu=self.file_menu)
self.file_menu.add_command(label="New", command=self.new_command, accelerator="Cmd+N")
self.parent.bind_all("<Command-n>", self.new_command)
self.parent.bind_all("<Command-N>", self.new_command)
self.file_menu.add_command(label="New Tab", command=self.new_tab, accelerator="Cmd+Opt+N")
self.parent.bind_all("<Command-Option-n>", self.new_tab)
self.parent.bind_all("<Command-Option-N>", self.new_tab)
self.file_menu.add_separator()
self.file_menu.add_command(label="Open", command=self.open_command, accelerator="Cmd+O")
self.parent.bind_all("<Command-o>", self.open_command)
self.parent.bind_all("<Command-O>", self.open_command)
self.file_menu.add_command(label="Save", command=self.save_command, accelerator="Cmd+S")
self.parent.bind_all("<Command-s>", self.save_command)
self.parent.bind_all("<Command-S>", self.save_command)
self.file_menu.add_separator()
self.file_menu.add_command(label= "Quit", command= self.exit_program, accelerator="Cmd+W")
self.parent.bind_all("<Command-w>", self.exit_program)
self.parent.bind_all("<Command-W>", self.exit_program)
# Edit Menu
self.edit_menu = tk.Menu(self.menuBar, tearoff=0)
self.menuBar.add_cascade(label= "Edit", menu= self.edit_menu)
self.edit_menu.add_command(label = "Cut", command = self.cut_command, accelerator="Cmd+X")
self.parent.bind_all("<Command-Shift-x>", self.cut_command)
self.parent.bind_all("<Command-Shift-X>", self.cut_command)
self.edit_menu.add_command(label = "Copy", command = self.copy_command, accelerator="Cmd+C")
self.parent.bind_all("<Command-Shift-c>", self.copy_command)
self.parent.bind_all("<Command-Shift-C>", self.copy_command)
self.edit_menu.add_command(label = "Paste", command = self.paste_command, accelerator="Cmd+V")
self.parent.bind_all("<Command-Shift-v>", self.paste_command)
self.parent.bind_all("<Command-Shift-V>", self.paste_command)
self.edit_menu.add_separator()
self.edit_menu.add_command(label= "Find", command= self.find_command)
parent.config(menu=self.menuBar)
##################################################
def open_command(self, event=None):
file = tkFileDialog.askopenfile(parent=root,mode='rb',title='Select a file')
if file != None:
contents = file.read()
self.textWidget.insert("1.0",contents)
file.close()
def save_command(self, event=None):
file = tkFileDialog.asksaveasfile(mode= 'w')
if file != None:
data = self.textWidget.get("1.0", END+'-1c') #strip trailing \n at EOF
file.write(data)
file.close()
def exit_program(self, event=None):
if tkMessageBox.askokcancel("Quit", "Are you sure you want to quit?"):
self.parent.destroy()
#Opens up new text widget correctly but screws up closing the parent window via the menu
def new_command(self, event=None):
win = Toplevel()
SimpleTextEditor.__init__(self, win)
#Currently under construction
def new_tab(self, event=None):
#self.parent.add(self.textWidget, text="new tab", state='normal')
new_frame = tk.Frame(self.parent)
self.parent.add(new_frame, text='new', state='normal')
def cut_command(self, event=None):
text = self.textWidget.get(SEL_FIRST, SEL_LAST)
self.textWidget.delete(SEL_FIRST, SEL_LAST)
self.textWidget.clipboard_clear()
self.textWidget.clipboard_append(text)
def copy_command(self, event=None):
text = self.textWidget.get(SEL_FIRST, SEL_LAST)
self.textWidget.clipboard_clear()
self.textWidget.clipboard_append(text)
def paste_command(self, event=None):
try:
text = self.textWidget.selection_get(selection= 'CLIPBOARD')
self.textWidget.insert(INSERT, text)
except TclError:
pass
#.........这里部分代码省略.........
示例8: TextEditor
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import delete [as 别名]
#.........这里部分代码省略.........
# checks words in current text and adds them to suggestionDict
# based on whether they are similar or not
if(currentWord == ""): return []
listOfWords = self.currentText.split()
for word in listOfWords:
word = self.cleanWord(word)
if word!= currentWord[:-1]:
similar = self.wordsAreSimilar(currentWord, word)
if(similar[0] and word not in self.suggestionDict):
self.suggestionDict[word] = similar[1]
self.sortSuggestionDict
return self.suggestionDict
def getCurrentWord(self):
# gets current word user is typing
word = self.textWidget.get(self.textWidget.index("insert wordstart"),
self.textWidget.index("insert wordend"))
if(word == "\n" or word == " "):
word = self.textWidget.get(
self.textWidget.index("insert -1c wordstart"),
self.textWidget.index("insert wordend"))
word = word.replace("\n","")
return word
def openFile(self):
# opens a file, also detects whether it is
# a program or not
self.initProgrammingModeAttributes()
path = tkFileDialog.askopenfilename()
if(path):
self.currentFilePath = path
self.currentFile = os.path.basename(path)
self.currentText = TextEditor.readFile(path)
self.textWidget.delete(1.0,END)
self.textWidget.insert(1.0,self.currentText)
self.fileExtension = os.path.splitext(path)[1]
self.root.wm_title(self.currentFile)
if(self.fileExtension != ".txt" and
pygments.lexers.guess_lexer_for_filename(
"example%s"%self.fileExtension,[])):
self.programmingMode = True
self.lexer = pygments.lexers.guess_lexer_for_filename(
"example%s"%self.fileExtension,[])
self.highlightText()
def saveFile(self):
if(self.currentFilePath):
TextEditor.writeFile(self.currentFilePath, self.currentText)
def saveAs(self):
# saves a file, automatically adds extension
path = tkFileDialog.asksaveasfilename()
if(path):
if(self.fileExtension): path += self.fileExtension
else: path += ".txt"
TextEditor.writeFile(path, self.currentText)
self.currentFilePath = path
self.currentFile = os.path.basename(path)
self.root.wm_title(self.currentFile)
if(self.fileExtension !=".txt" and
pygments.lexers.guess_lexer_for_filename(
"example%s"%self.fileExtension,[])):
self.programmingMode = True
self.lexer = pygments.lexers.guess_lexer_for_filename(
"example%s"%self.fileExtension,[])
self.highlightText()
示例9: App
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import delete [as 别名]
#.........这里部分代码省略.........
if symbol is None:
return
if (symbol.get_type() == kconf.BOOL or (symbol.get_type() == kconf.TRISTATE and not self.conf.is_tristate_enabled())):
if (symbol.is_choice_symbol() and len(symbol.get_parent().get_items()) == 1):
self.msg.set("A boolean choice, exactly one config option must be set to y, so no change here!")
return
if (symbol.get_value() == "y"):
print("Setting " + symbol.get_name() + " to n")
symbol.set_user_value("n")
if (symbol.get_value() == "y"):
self.msg.set("A boolean choice that is the only 'y' in the choice group can not be set to 'n'")
symbol.set_user_value("y")
return
self.tree.set(mitem, "value", symbol.get_value())
else:
print("Setting " + symbol.get_name() + " to y")
symbol.set_user_value("y")
self.tree.set(mitem, "value", symbol.get_value())
print("Dependents for " + symbol.get_name() + " {" + symbol.get_visibility() + "} " + " [" + symbol.get_value() + "]:")
for sym in symbol.get_dependent_symbols():
print(sym.get_name() + " {"+sym.get_visibility() + "} " + " [" + sym.get_value() + "] ")
mitem = self.search_for_item(sym.get_name(), None)
if (mitem):
self.tree.set(mitem, "value", sym.get_value())
print("========================================")
elif (symbol.get_type() == kconf.TRISTATE and self.conf.is_tristate_enabled()):
nono = False
if (symbol.is_choice_symbol() and len(symbol.get_parent().get_items()) == 1):
self.msg.set("A single tristate choice in one choice group can not be set to 'n'")
nono = True
# 'y'->'m'->'n'->'y'->'m'->'n'->...
if (symbol.get_value() == "y"):
print("Setting " + symbol.get_name() + " to m")
symbol.set_user_value("m")
if (symbol.get_value() == "y"):
self.msg.set("A tristate choice that is the only 'y' in the choice group can not be set to 'n'")
symbol.set_user_value("y")
return
self.tree.set(mitem, "value", symbol.get_value())
elif (symbol.get_value() == "m"):
print("Setting " + symbol.get_name() + " to n")
symbol.set_user_value("n")
if (symbol.get_value() == "m"):
self.msg.set("A tristate choice that is the only 'm' in the choice group can not be set to 'n'")
symbol.set_user_value("m")
return
self.tree.set(mitem, "value", symbol.get_value())
else:
print("Setting " + symbol.get_name() + " to y")
symbol.set_user_value("y")
self.tree.set(mitem, "value", symbol.get_value())
print("Dependents for " + symbol.get_name() + " {" + symbol.get_visibility() + "} " + " [" + symbol.get_value() + "]:")
for sym in symbol.get_dependent_symbols():
print(sym.get_name() + " {"+sym.get_visibility() + "} " + " [" + sym.get_value() + "] ")
mitem = self.search_for_item(sym.get_name(), None)
if (mitem):
self.tree.set(mitem, "value", sym.get_value())
print("========================================")
elif (symbol.get_type() == kconf.INT or symbol.get_type() == kconf.HEX or symbol.get_type() == kconf.STRING):
self.pop = PopupWindow(self.root, symbol.get_name(), symbol.get_value())
self.root.wait_window(self.pop.top)
if (self.pop.v == True):
print("Setting " + symbol.get_name() + " to " + self.pop.value)
symbol.set_user_value(self.pop.value)
print("Now " + symbol.get_name() + " is " + symbol.get_value())
self.tree.set(mitem, "value", symbol.get_value())
return
def OnSelection(self, event):
mitem = self.tree.focus()
values = self.tree.item(mitem,"values");
if (values):
symbol = self.conf.get_symbol(values[0])
if (symbol):
self.msg.set("Please Double Click to update config option value!")
self.help.delete(1.0, END)
help = symbol.get_help()
if (help):
self.help.insert(INSERT, help)
return
def OnSaveConfig(self):
self.conf.write_config(".config")
self.conf.write_config_python("config.py")
header_dir = conf.get_config_header_dir()
dstfile = os.path.join(header_dir, "config.h")
dstdir = os.path.split(dstfile)[0]
if not os.path.exists(dstdir):
os.makedirs(dstdir)
self.conf.write_config_header(dstfile)
self.msg.set("Configurations Saved!")
return
def OnQuitConfig(self):
self.root.quit()
return
示例10: ScaleDemo
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import delete [as 别名]
class ScaleDemo(Frame):
def smooth(self,x,window_len=11):
s=numpy.r_[2*x[0]-x[window_len-1::-1],x,2*x[-1]-x[-1:-window_len:-1]]
w=numpy.hanning(window_len)
y=numpy.convolve(w/w.sum(),s,mode='same')
return y[window_len:-window_len+1]
def __init__(self):
self.fileName=""
self.rawData=""
self.processedData=""
self.file_loaded = False
self.f = Frame.__init__(self)
self.pack()
self.master.title("Wheeze")
self.master.geometry("1020x650")
self.menu = Menu(self)
self.master.config(menu=self.menu)
self.tkMenu = Menu(self.menu)
self.menu.add_cascade(label="File", menu=self.tkMenu)
self.tkMenu.add_command(label="Open", command=self.readData)
self.tkMenuData = Menu(self.menu)
self.menu.add_cascade(label="Data", menu=self.tkMenuData)
self.tkMenuData.add_command(label="Process", command=self.breath_stats)
self.tkMenuData.add_command(label="Save", command=self.saveData)
self.left_frame = Frame(height=150, width=50)
self.left_frame.pack(side=LEFT, fill=BOTH, expand=1)
self.right_frame = Frame(height=150, width=50)
self.right_frame.pack(side=LEFT, fill=BOTH, expand=1)
self.top_frame1 = Frame(self.left_frame, borderwidth=5, relief=RIDGE)
self.top_frame1.pack(side=TOP, fill=BOTH, expand=1)
self.bottom_frame1 = Frame(self.left_frame, borderwidth=5, relief=RIDGE,)
self.bottom_frame1.pack(side=BOTTOM, fill=BOTH, expand=1)
self.top_frame2 = Frame(self.right_frame, borderwidth=5, relief=RIDGE)
self.top_frame2.pack(side=TOP, fill=BOTH, expand=1)
self.bottom_frame2 = Frame(self.right_frame, borderwidth=5, relief=RIDGE,)
self.bottom_frame2.pack(side=BOTTOM, fill=BOTH, expand=1)
f = Figure(figsize=(5, 4), dpi=80)
self.ax1 = f.add_subplot(121)
self.ax4 = f.add_subplot(122)
self.dataPlot = FigureCanvasTkAgg(f, master=self.top_frame2)
self.dataPlot.get_tk_widget().pack(side=BOTTOM, fill=BOTH)
f = Figure(figsize=(3, 4), dpi=65)
self.ax2 = f.add_subplot(111)
self.l1 = self.ax1.axvline(color='r')
self.l2 = self.ax1.axvline(color='r')
self.dataPlot2 = FigureCanvasTkAgg(f, master=self.top_frame1)
self.dataPlot2.get_tk_widget().pack(side=TOP, fill=BOTH)
f = Figure(figsize=(3, 4), dpi=65)
self.dataPlot3 = FigureCanvasTkAgg(f, master=self.top_frame1)
self.ax3 = f.add_subplot(111)
self.dataPlot3.get_tk_widget().pack(side=TOP, fill=BOTH)
self.scrolled_text = ScrolledText(self.bottom_frame2)
self.scrolled_text.pack(side=TOP, fill=BOTH)
self.control1 = Scale(self.bottom_frame1 , from_=0, to=100, showvalue=0, orient=HORIZONTAL, command=self.updatePlot1)
self.control1.pack(fill=X)
self.control1.set(0)
self.control2 = Scale(self.bottom_frame1 , from_=0, to=100, showvalue=0, orient=HORIZONTAL, command=self.updatePlot2)
self.control2.pack(fill=X)
self.control2.set(100)
self.control_smooth = Scale(self.bottom_frame1 , from_=0, to=100, showvalue=1, orient=HORIZONTAL, command=self.updatePlot3)
self.control_smooth.pack(fill=X)
self.control_smooth.set(4)
self.dataPlot.show()
self.dataPlot2.show()
def updatePlot1(self, scaleValue):
end = int(scaleValue)
self.l1.set_xdata(end)
self.dataPlot3.draw()
self.plot_data(self.control1.get(), self.control2.get(),self.control_smooth.get())
def updatePlot2(self, scaleValue):
end = int(scaleValue)
self.l2.set_xdata(end)
self.dataPlot3.draw()
self.plot_data(self.control1.get(), self.control2.get(),self.control_smooth.get())
def updatePlot3(self,scaleValue):
self.plot_data(self.control1.get(), self.control2.get(),self.control_smooth.get())
def plot_data(self, start_data, end_data,smooth_val):
if self.file_loaded == True :
self.scrolled_text.delete(1.0, END)
#.........这里部分代码省略.........
示例11: __init__
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import delete [as 别名]
#.........这里部分代码省略.........
self.rti = Tkinter.Label(master, image = rtimg)
self.rti.image=rtimg
self.rti.grid(row=5, column=2, columnspan=1, padx=5, pady=5)
'''
# User credentials field
cred_label_text = ['Server IP: ','Username: ','Password: ']
self.cred_text = []
self.cred_label = []
credpane = []
for i in range(0,3):
credpane.append(Tkinter.PanedWindow())
self.cred_label.append(Tkinter.Label(master, text=cred_label_text[i]))
self.cred_text.append((Tkinter.Entry(master,width=50)))
credpane[i].add(self.cred_label[i])
credpane[i].add(self.cred_text[i])
credpane[i].grid(row=5+i, column=1, columnspan=1, padx=5, pady=5, sticky=Tkinter.E)
self.cred_but = Tkinter.Button(master, text='Login', command=self.loginWithCred)
self.cred_but.grid(row=8, column=1, columnspan=1, padx=5, pady=5)
# Add more GUI stuff here
def processIncoming(self):
"""
Handle all the messages currently in the queue (if any).
"""
#self.counter = 0
#self.queue.put('asdas')
while self.queue.qsize():
try:
self.msg = str(self.queue.get(0)) + '\n'
# Check contents of message and do what it says
# As a test, we simply print it
self.tele.insert('end', self.msg)
if(float(self.tele.index('end')) > 11.0):
self.tele.delete('1.0','end')
self.msg2 = self.queue2.get(0) + '\n'
#print self.msg2
if(self.msg2.find('Target') == 0):
#self.targetpics[self.counter] = self.msg2
self.targetpics.append(self.msg2)
#self.counter += 1
else:
self.rt.insert('end', self.msg2)
except Queue.Empty:
pass
def getObstacles(self):
# GET obstacles request
c = pycurl.Curl()
buffer = StringIO()
c.setopt(pycurl.URL, interop_api_url+'obstacles')
c.setopt(pycurl.WRITEDATA, buffer)
c.setopt(pycurl.COOKIEFILE, 'sessionid.txt')
c.perform()
obstacles_json = json.loads(buffer.getvalue())
print("\n\n" + "====Obstacles====")
obstacles = json.dumps(obstacles_json, sort_keys=True,indent=4, separators=(',', ': '))
print obstacles
self.obs.insert('end', obstacles)
def nextPic(self):
if(self.currentImage < len(self.targetpics) - 1):
self.currentImage += 1
示例12: __init__
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import delete [as 别名]
class Textee:
def __init__(self, master):
self.master = master
self.theme = 'dark' # the startup will always be opposite
self.options = TexteeOptions()
self.status_bar = TexteeStatusBar(master)
self.create_menu(master)
self.create_ui(master)
self.set_bindings(master)
self.file = None
self.find_text = ''
self.font_dialog = None
self.find_and_replace_dialog = None
self.windows = []
def create_menu(self, master):
self.menu = Menu(master)
master.config(menu=self.menu)
filemenu = Menu(self.menu)
self.menu.add_cascade(label="File", menu=filemenu)
filemenu.add_command(label="New", command=self.new_file)
filemenu.add_command(label="Open...", command=self.open_file)
filemenu.add_command(label="Save", command=self.save_file)
filemenu.add_command(label="Save As", command=lambda: self.save_file(save_as=True))
filemenu.add_separator()
filemenu.add_command(label="New window", command=self.new_window)
filemenu.add_separator()
filemenu.add_command(label="Print", command=self.printer)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=self.exit)
editmenu = Menu(self.menu)
self.menu.add_cascade(label='Edit', menu=editmenu)
editmenu.add_command(label='Copy', command=lambda: event_generate(self.editor, 'Copy'))
editmenu.add_command(label='Paste', command=lambda: event_generate(self.editor, 'Paste'))
editmenu.add_command(label='Undo', command=lambda: event_generate(self.editor, 'Undo'))
editmenu.add_separator()
editmenu.add_command(label='Goto', command=self.goto_line) # need to develop custom find with regex
editmenu.add_command(label='Find', command=self.find) # need to develop custom find with regex
editmenu.add_command(label='Find & Replace', command=self.find_and_replace) # need to test the replace logic in separate playground
editmenu.add_separator()
editmenu.add_command(label='Check spelling', command=self.spell_check) # need to see how to use system's grammer check.. if not possible remove it.
formatmenu = Menu(self.menu)
self.menu.add_cascade(label='Format', menu=formatmenu)
formatmenu.add_command(label='Font', command=self.select_font) # pop-up to select system fonts
formatmenu.add_checkbutton(label='Wrap', onvalue=True, offvalue=False, variable=self.options.wrap, command=self.toggle_wrap)
viewmenu = Menu(self.menu)
self.menu.add_cascade(label='View', menu=viewmenu)
viewmenu.add_checkbutton(label='Status bar', onvalue=True, offvalue=False, variable=self.options.status_bar, command=lambda: self.status_bar.display(self.options.status_bar.get()))
viewmenu.add_command(label='Toggle theme', command=self.toggle_theme)
helpmenu = Menu(self.menu)
self.menu.add_cascade(label="Help", menu=helpmenu)
helpmenu.add_command(label="About", command=lambda : self.about())
def create_ui(self, master):
self.editor = ScrolledText(master, width=100, height=50, highlightthickness=0)
self.editor.config(undo=True)
self.editor.pack(expand=YES, fill='both', padx=0, pady=0)
self.toggle_theme()
#print_configs(self.editor)
# Create pop-menu for the entire editor.. do some cool stuff with it
self.editor.popmenu = Menu(self.master, tearoff=0)
# TODO : later need to do smart copy/paste i.e. selected text copy of entire line copy
self.editor.popmenu.add_command(label='Copy', command=lambda: event_generate(self.editor, 'Copy'))
self.editor.popmenu.add_command(label='Paste', command=lambda: event_generate(self.editor, 'Paste'))
# TODO : disable undo when not available, not sure if its possible. Need to check research later
self.editor.popmenu.add_command(label='Undo', command=lambda: event_generate(self.editor, 'Undo'))
self.editor.popmenu.add_separator()
# TODO : 'share' this will be the best feature in the editor, share the file with the future textee sharing api
self.editor.popmenu.add_command(label='Share', command=do_nothing)
# add status bar by default, it can be hidden from menu
self.status_bar.update_status('Hi there')
def set_bindings(self, master):
master.bind_class('Text', '<Control-a>', select_all)
master.bind_class('Text', '<Control-s>', lambda event: self.save_file())
master.bind_class('Text', '<Control-o>', lambda event: self.open_file())
master.bind_class('Text', '<Control-n>', lambda event: self.new_file())
master.bind_class('Text', '<Control-g>', lambda event: self.goto_line())
master.bind_class('Text', '<Control-f>', lambda event: self.find())
master.bind_class('Text', '<Control-p>', lambda event: self.printer())
master.bind_class('Text', '<Control-;>', lambda event: self.find_and_replace()) # this function is only for temporoy use - for dev purpose only
# editor section bindings only
self.editor.bind('<Button-2>', self.show_right_click_menu) # for right-click
self.editor.bind('<Button-3>', self.show_right_click_menu) # for middle-click (scroll press)
#display the current cursor position
self.display_current_position()
def new_file(self):
self.file = None
self.editor.delete('1.0', END+'-1c') # clear all the contents
#.........这里部分代码省略.........
示例13: __init__
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import delete [as 别名]
class MainWnd:
def __init__(self, parent):
self.search_str = StringVar()
self.parent = parent
root.protocol("WM_DELETE_WINDOW", self.ask_quit)
self.parent.title("snippets")
self.parent.configure(padx=10, pady=10)
self.parent.minsize(630, 480)
self.create_widgets()
db_path = os.path.join(abspath(dirname(__file__)), "snip.db")
db_exists = os.path.isfile(db_path)
self.connection = sqlite3.connect(db_path)
self.connection.row_factory = dict_factory
self.cursor = self.connection.cursor()
if not db_exists:
self.cursor.execute('create table snippet (caption, content)')
self.fill_list()
self.snip_content.focus_set()
def ask_quit(self):
if tkMessageBox.askokcancel("Quit", "You want to quit now?"):
self.parent.destroy()
def __del__(self):
self.connection.close()
def create_widgets(self):
self.search_box = Entry(self.parent, textvariable=self.search_str)
self.search_str.set("New snippet")
self.search_box.pack(fill=X)
self.toolbar_f = Frame(self.parent, pady=5)
self.toolbar_f.pack(fill=X)
self.newbtn = Button(self.toolbar_f, text="New", command=self.on_new)
self.newbtn.pack(side=LEFT)
self.savebtn = Button(self.toolbar_f, text="Save", command=self.on_save)
self.savebtn.pack(side=LEFT)
self.updatebtn = Button(self.toolbar_f, text="Update", command=self.on_update)
self.updatebtn.pack(side=LEFT)
self.delbtn = Button(self.toolbar_f, text="Delete", command=self.on_delete)
self.delbtn.pack(side=LEFT)
self.copybtn = Button(self.toolbar_f, text="Copy to clipboard", command=self.on_copy)
self.copybtn.pack(side=LEFT)
self.quitbtn = Button(self.toolbar_f, text="Quit", command=self.on_quit)
self.quitbtn.pack(side=LEFT)
self.pwin = PanedWindow(self.parent, showhandle=True)
self.pwin.pack(fill=BOTH, expand=1)
self.list_f = Frame(self.pwin)
self.list_sb = Scrollbar(self.list_f, orient=VERTICAL)
self.snip_list = Listbox(self.list_f, yscrollcommand=self.list_sb.set)
self.list_sb.config(command=self.snip_list.yview)
self.snip_list.bind('<ButtonRelease-1>', self.on_snippet_selected)
self.snip_list.pack(side=LEFT, fill=BOTH, expand=1)
self.list_sb.pack(side=RIGHT, fill=Y)
self.pwin.add(self.list_f)
self.pwin.paneconfigure(self.list_f, minsize=177)
self.snippetFont = Font(family="courier", size=11, weight=NORMAL)
self.snip_content = ScrolledText(self.pwin, height=20, width=40,
padx=5, pady=5,
font=self.snippetFont)
self.pwin.add(self.snip_content)
# noinspection PyTypeChecker
def fill_list(self):
self.snip_list.delete(0, END)
self.cursor.execute('select * from snippet')
for r in self.cursor.fetchall():
self.snip_list.insert(END, r['caption'])
def on_new(self):
self.search_str.set("")
self.snip_content.delete(1.0, END)
def on_save(self):
self.cursor.execute(
'insert into snippet (caption,content) values (?,?)',
(self.search_str.get(), self.snip_content.get(1.0, END),))
self.connection.commit()
self.fill_list()
def on_update(self):
self.cursor.execute(
'update snippet set content=? where caption=?',
(self.snip_content.get(1.0, END), self.search_str.get()))
self.connection.commit()
#.........这里部分代码省略.........
示例14: App
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import delete [as 别名]
class App(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.set_style()
self.master.grid()
self.create_widgets()
sys.stdout = TextEmit(self.st2, 'stdout')
sys.stderr = TextEmit(self.st2, 'stderr')
self.cached_dict_of_dict = {}
def set_style(self):
s = ttk.Style()
s.configure('TButton', padding=(5))
s.configure('TCombobox', padding=(5))
s.configure('exe.TButton', foreground='red')
def parse_data(self):
data_file = self.com.get()
print('\n[Data File]: %s' % data_file)
print('=' * 52)
user_input = self.st1.get('0.1', 'end-1c')
query_list = CSV_Dict.get_query_list(user_input)
if data_file and query_list:
if data_file not in self.cached_dict_of_dict:
c = CSV_Dict.from_raw_data(os.path.join(DATA_PAHT,
data_file))
current_dict = c.detailed_dict
self.cached_dict_of_dict[data_file] = current_dict
else:
current_dict = self.cached_dict_of_dict[data_file]
print('[Dictionary count]: %s\n' % len(current_dict.keys()))
print('\n' + '=' * 52)
CSV_Dict.do_query(query_list, current_dict)
print('===== [Mission Complete] =====\n')
else:
sys.stderr.write('----- [Mission Failed] -----\n')
print('\n')
def clear_output(self):
self.st2.configure(state='normal')
self.st2.delete('1.0', 'end')
self.st2.configure(state='disabled')
def show_summary_of_data_file(self):
data_file = os.path.join(DATA_PAHT, self.com.get())
base_name = self.com.get()
if not os.path.isfile(data_file):
sys.stderr.write('>>>>> [Error]: Data file does not exist: %s\n' %
data_file)
print('\n[Show Data File Summary] %s' % base_name)
print('=' * 52)
with open(data_file, 'r') as f:
for i, line in enumerate(f):
if i < SUMMARY_LINE:
print('[ %d ] %s' % (i, line.strip()))
else:
print('[ 10] ... ...')
print('[...] ... ...')
break
def create_widgets(self):
self.content = ttk.Frame(self.master, padding=(5))
self.b1 = ttk.Button(self.content, text='Clear Query')
self.combo_value = StringVar()
self.com = ttk.Combobox(self.content, textvariable=self.combo_value,
state='readonly')
if not os.path.isdir(DATA_PAHT):
os.mkdir(data_folder)
self.com['values'] = os.listdir(DATA_PAHT)
if len(self.com['values']) > 0:
self.com.current(0)
else:
sys.stderr.write('Please put csv data file in data folder and '
'restart this program.')
self.b2 = ttk.Button(self.content, text='Data Summary',
command=self.show_summary_of_data_file)
self.b3 = ttk.Button(self.content, text='Query', style='exe.TButton')
self.b4 = ttk.Button(self.content, text='Clear Log')
self.st1 = ScrolledText(self.content)
self.st2 = ScrolledText(self.content)
self.b1.grid(row=0, column=0, sticky=(W))
self.b2.grid(row=0, column=1, sticky=(E))
self.com.grid(row=0, column=1, sticky=(W+E))
self.b3.grid(row=0, column=2, sticky=(W))
self.b4.grid(row=0, column=3, sticky=(E))
self.st1.grid(row=1, column=0, columnspan=2, sticky=(W+E+S+N))
self.st2.grid(row=1, column=2, columnspan=2, sticky=(W+E+S+N))
self.content.grid(row=0, column=0, sticky=(W+E+S+N))
self.b1['command'] = lambda: self.st1.delete('0.1', 'end')
self.b3['command'] = self.parse_data
self.b4['command'] = self.clear_output
self.master.rowconfigure(0, weight=1)
self.master.columnconfigure(0, weight=1)
self.content.rowconfigure(0, weight=0)
self.content.rowconfigure(1, weight=1)
self.content.columnconfigure(0, weight=1)
#.........这里部分代码省略.........
示例15: __init__
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import delete [as 别名]
class UI:
def __init__(self, password):
self.password = password
self.window = Tk()
self.day = StringVar()
self.day.set(date.today().day)
self.month = StringVar()
self.month.set(date.today().month)
self.year = StringVar()
self.year.set(date.today().year)
self.text = StringVar()
self.dateFrame = Frame(self.window)
self.dateFrame["padx"] = 20
self.dateFrame["pady"] = 10
self.dateFrame.pack()
self.dayL = Label(self.dateFrame)
self.dayL["text"] = "Tag:"
self.dayL.pack(side='left', padx=10)
self.dayI = Entry(self.dateFrame)
self.dayI["width"] = 5
self.dayI["textvariable"] = self.day
self.dayI.pack(side='left', padx=5)
self.monthL = Label(self.dateFrame)
self.monthL["text"] = "Monat:"
self.monthL.pack(side='left', padx=5)
self.monthI = Entry(self.dateFrame)
self.monthI["width"] = 5
self.monthI["textvariable"] = self.month
self.monthI.pack(side='left', padx=5)
self.yearL = Label(self.dateFrame)
self.yearL["text"] = "Jahr:"
self.yearL.pack(side='left', padx=5)
self.yearI = Entry(self.dateFrame)
self.yearI["width"] = 5
self.yearI["textvariable"] = self.year
self.yearI.pack(side='left', padx=5)
self.button = Button(self.dateFrame)
self.button["text"] = "Erstellen"
self.button["width"] = 20
self.button["command"] = self.buttonCallback
self.button.pack(side='left', padx=20)
self.textI = ScrolledText(self.window)
self.updateTextI("e")
self.textI.pack()
self.exportB = Button(self.window)
self.exportB["text"] = "Export"
self.exportB["width"] = 20
self.exportB["command"] = self.exportButtonCallback
self.exportB.pack(pady=15)
self.buttonCallback()
self.window.mainloop()
def updateTextI(self, t):
self.textI.delete("1.0", END)
self.textI.insert(END, t)
def buttonCallback(self):
d = "%s-%s-%s" % (self.year.get(), self.month.get(), self.day.get())
#print(getAccountingString(d))
self.updateTextI(getAccountingString(d, self.password))
def exportButtonCallback(self):
pass