当前位置: 首页>>代码示例>>Python>>正文


Python ScrolledText.insert方法代码示例

本文整理汇总了Python中ScrolledText.insert方法的典型用法代码示例。如果您正苦于以下问题:Python ScrolledText.insert方法的具体用法?Python ScrolledText.insert怎么用?Python ScrolledText.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ScrolledText的用法示例。


在下文中一共展示了ScrolledText.insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_widgets

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import insert [as 别名]
    def create_widgets(self, parent, controller):

        self.info = tk.Label(self, text="Enter a stock ticker")
        self.info.pack()

        self.e = ttk.Entry(self)    # entry form for stock symbol
        self.e.pack()

        self.info2 = tk.Label(self, text="Enter timespan (6m, 1y, 3y)")
        self.info2.pack()

        self.span = tk.Entry(self)
        self.span.pack(side=tk.TOP)
        self.span.focus_set()

        self.b = ttk.Button(self, text='Submit', command=lambda: self.get_input())
        # self.b.grid(row=3, column=1, sticky=tk.N)
        self.b.pack(side=tk.TOP)

        self.info3 = tk.Label(self, text="Results")
        self.info3.pack(side=tk.LEFT)

        global text
        text = ScrolledText(self, font=("Consolas",10), padx=10, pady=10)
        text.insert(tk.INSERT, "\n")
        text.pack(side=tk.BOTTOM, expand=True)

        self.b1 = tk.Button(self, text='Event Plot', command=lambda: self.chart_events())
        self.b1.pack(side=tk.RIGHT)
开发者ID:ramenhood,项目名称:StockDataMining,代码行数:31,代码来源:gui2.py

示例2: GredAboutBox

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import insert [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")
开发者ID:ProgVal,项目名称:Gato-mirror,代码行数:27,代码来源:ObjectGred.py

示例3: compilePythonCode

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import insert [as 别名]
 def compilePythonCode(self):
     if(self.currentFile):
         self.saveFile()
         original_stdout = sys.stdout
         try:
             a = compiler.compile(self.currentText, self.currentFile, 
                                 mode = "exec")
             # (http://stackoverflow.com/questions/4904079/
             # execute-a-block-of-python-code-with-exec-capturing-all-its-output)
             # captures stdout in temp stringIO buffer to get output
             # and then reverts changes
             buffer = StringIO()
             sys.stdout = buffer
             eval(a)
             sys.stdout = original_stdout
             val = buffer.getvalue()
             rt = Tk()
             outputText = ScrolledText(rt, width = 50)
             outputText.insert(END, val)
             outputText.pack()
             rt.mainloop()
         except:
             print "Error!"
             self.displayMessageBox("Error","There is an error in the code.")
             sys.stdout = original_stdout
     else:
         self.saveAs()
开发者ID:manikpanwar,项目名称:CollaborativeCoder,代码行数:29,代码来源:textEditor.py

示例4: App

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import insert [as 别名]
class App(Thread):
  server = socket()
  server.bind(('localhost', input("Port: ")))
  server.listen(5)
  client,addr = server.accept()
  def __init__(self, master):
    Thread.__init__(self)
    frame = Frame(master)
    frame.pack()
    self.gettext = ScrolledText(frame, height=10,width=100, state=NORMAL)
    self.gettext.pack()
    sframe = Frame(frame)
    sframe.pack(anchor='w')
    self.pro = Label(sframe, text="Server>>");
    self.sendtext = Entry(sframe,width=80)
    self.sendtext.focus_set()
    self.sendtext.bind(sequence="<Return>", func=self.Send)
    self.pro.pack(side=LEFT)
    self.sendtext.pack(side=LEFT)
    self.gettext.insert(END,'Welcome to Chat\n')
    self.gettext.configure(state=DISABLED)
  def Send(self, args):
    self.gettext.configure(state=NORMAL)
    text = self.sendtext.get()
    if text=="": text=" "
    self.gettext.insert(END,'Me >> %s \n'%text)
    self.sendtext.delete(0,END)
    self.client.send(text)
    self.sendtext.focus_set()
    self.gettext.configure(state=DISABLED)
    self.gettext.see(END)
  def run(self):
    Receive(self.client, self.gettext)
开发者ID:praven0894,项目名称:Chat-with-tkinter-and-socket,代码行数:35,代码来源:Server.py

示例5: createTextItem

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import insert [as 别名]
    def createTextItem(self, frame, sname, name, eid, w, h, cspan=1, rspan=1, txt=""):
        stxt = ScrolledText(frame, width=int(w), height=int(h))
        stxt.insert(END, txt.strip())
        stxt.tag_config("csel", background="blue",foreground="white")
	self.stext[sname+":"+eid] = stxt
	key = name+":gui:"+eid

	return [stxt, cspan, rspan]
开发者ID:okadahiroyuki,项目名称:okada,代码行数:10,代码来源:eSEAT.py

示例6: App

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import insert [as 别名]
class App(Thread):
  client = socket()
  def __init__(self, master):
    Thread.__init__(self)
    frame = Frame(master)    
    frame.pack()
    
    gframe = Frame(frame)
    gframe.pack(anchor='w')
    self.lblserver = Label(gframe, text="IP Server :")
    self.txtserver =  Entry(gframe,width=40)
    self.lblserver.pack(side=LEFT)
    self.txtserver.pack(side=LEFT)
    self.lblport = Label(gframe, text="Port :")
    self.txtport =  Entry(gframe,width=40)
    self.lblport.pack(side=LEFT)
    self.txtport.pack(side=LEFT)
    self.koneksi = Button(gframe, text='Connect', command=self.Connect).pack(side=LEFT)
    
    self.gettext = ScrolledText(frame, height=10,width=100)    
    self.gettext.pack()    
    self.gettext.configure(state=DISABLED)
    
    sframe = Frame(frame)
    sframe.pack(anchor='w')
    self.pro = Label(sframe, text="Client>>")
    self.sendtext = Entry(sframe,width=80)
    self.sendtext.focus_set()
    self.sendtext.bind(sequence="<Return>", func=self.Send)
    self.pro.pack(side=LEFT)
    self.sendtext.pack(side=LEFT)

  def Connect(self):     
    try:      
      self.client.connect((str(self.txtserver.get()), int(self.txtport.get())))
      self.gettext.configure(state=NORMAL)
      self.gettext.insert(END,'Start to Chat\n')
      self.gettext.configure(state=DISABLED)
      self.start()      
    except:      
      tkMessageBox.showinfo("Error", "Unconnected")
    
  def Send(self, args):
    self.gettext.configure(state=NORMAL)
    text = self.sendtext.get()
    if text=="": text=" "
    self.gettext.insert(END,'Me >> %s\n'%text)
    self.sendtext.delete(0,END)
    self.client.send(text)
    self.sendtext.focus_set()
    self.gettext.configure(state=DISABLED)
    self.gettext.see(END)
    
  def run(self):
    Receive(self.client, self.gettext)

  def __del__(self):
    self.client.close()
开发者ID:harissaint,项目名称:Tugas-OOP1,代码行数:60,代码来源:client.py

示例7: __init__

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import insert [as 别名]
class editor:
    def __init__(self, rt):
        if rt == None:
            self.t = Tk()
        else:
            self.t = Toplevel(rt)
        self.t.title("Tkeditor %d" % len(t1))
        self.bar = Menu(rt)

        self.filem = Menu(self.bar)
        self.filem.add_command(label="打开", command=self.openfile)
        self.filem.add_command(label="新建", command=neweditor)
        self.filem.add_command(label="保存", command=self.savefile)
        self.filem.add_command(label="关闭", command=self.close)
        self.filem.add_separator()
        self.filem.add_command(label="退出", command=die)

        self.helpm = Menu(self.bar)
        self.helpm.add_command(label="关于", command=about)
        self.bar.add_cascade(label="文件", menu=self.filem)
        self.bar.add_cascade(label="帮助", menu=self.helpm)
        self.t.config(menu=self.bar)

        self.f = Frame(self.t, width=512)
        self.f.pack(expand=1, fill=BOTH)

        self.st = ScrolledText(self.f, background="white")
        self.st.pack(side=LEFT, fill=BOTH, expand=1)

        self.open = Button(self)
        self.open["text"] = "open"
        self.open["fg"] = "Blue"
        self.open["command"] = self.openfile
        self.open.pack({"side": "left"})
        self.open.pack({"anchor": "nw"})

    def close(self):
        self.t.destroy()
        print "close"

    def openfile(self):
        p1 = END
        oname = askopenfilename(filetypes=[("Python file", "*.*")])
        if oname:
            for line in fileinput.input(oname):
                self.st.insert(p1, line)
            self.t.title(oname)

    def savefile(self):
        sname = asksaveasfilename()
        if sname:
            ofp = open(sname, "w")
            ofp.write(self.st.get(1.0, END))
            ofp.flush()
            ofp.close()
            self.t.title(sname)
开发者ID:shawn0lee0,项目名称:OMOOC2py,代码行数:58,代码来源:notebook_.py

示例8: __init__

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import insert [as 别名]
class editor:
    def __init__(self,rt):

        self.top=Tk()
        self.top.title('记事本')
        self.top.geometry('300x400')
        self.bar=Menu(self.top)
  
        self.filem=Menu(self.bar)
        self.filem.add_command(label="打开",command=self.openfile)
        self.filem.add_command(label="新建",command=self.neweditor)
        self.filem.add_command(label="保存",command=self.savefile)
        self.filem.add_command(label="关闭",command=self.close)

        self.helpm=Menu(self.bar)
        self.helpm.add_command(label="Help",command=self.about)
        self.bar.add_cascade(label="文件",menu=self.filem)
        self.bar.add_cascade(label="帮助",menu=self.helpm)
        self.top.config(menu=self.bar)
  
        self.f=Frame(self.top,width=512)
        self.f.pack(expand=1,fill=BOTH)
  
        self.st=ScrolledText(self.f,background="white")
        self.st.pack(side=LEFT,fill=BOTH,expand=1)
        
    def close(self):
        self.top.destroy()
 
    def openfile(self):
        p1=END
        oname=askopenfilename()#filetypes=[("Python file","*.*")])
        if oname:
            for line in fileinput.input(oname):
                self.st.insert(p1,line)
                self.top.title(oname)
 
    def savefile(self):
        sname=asksaveasfilename()
        if sname:
            ofp=open(sname,"w")
            ofp.write(self.st.get(1.0,END).encode('utf-8'))
            ofp.flush()
            ofp.close()
            self.top.title(sname)
 
    def neweditor(self):
        global root
        self.top.append(editor(root))
        
        
    def about(self):
        tkMessageBox.showwarning("Tkeditor",'What?\n记事本也要帮助?')
开发者ID:wsywxywr,项目名称:free-mini,代码行数:55,代码来源:final.py

示例9: __init__

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import insert [as 别名]
 def __init__(self,filenames={}):
   self.a = Tk()
   self.a.wm_title("Makefile Module Summary Logs")
   self.n = notebook(self.a, LEFT)
   self.frames = {}
   for filename in filenames:
     f = Frame(self.n())
     st = ScrolledText(f, width=100, height=50)
     logfile = open(filenames[filename], 'r')
     st.insert(END, logfile.read())
     st.pack()
     self.frames[f] = st
     x = self.n.add_screen(f, filename)
开发者ID:ConicLabs,项目名称:client_component_template,代码行数:15,代码来源:logging_gui.py

示例10: LogWindow

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import insert [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))
开发者ID:VladJamir,项目名称:cmsc135,代码行数:52,代码来源:logviewer.py

示例11: Application

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import insert [as 别名]
class Application(Frame):
	
	def __init__(self, master=None):
		Frame.__init__(self, master)
		self.pack()
		self.createWidgets()

	def getnew(self,event): 
	# When press ENTER, write diary to local file
	# and print out it in Text frame
	# and also clear the Entry box
		line = self.newlog.get()
		f = open('diary log.txt','a+')
		f.write('%s\n' % line)
		f.close()
		self.t.insert(END,"%s\n" %line)
		self.t.see(END)
		self.e.delete(0,END)

	def createWidgets(self):   
		self.newlog = StringVar(self) # define StringVar
		
		self.l = Label(self, text = "Input here: ") # Label Widget 提示输入
		self.l.grid(row = 0, column = 0, sticky = W)
		
		self.e = Entry(self, textvariable = self.newlog, width = 80) # Entry box 输入框
		self.e.bind("<Return>", self.getnew) # bind ENTER to function getnew
		self.e.grid(row = 0, column = 1, sticky = W)
		self.e.focus_set() # make the mouse focus on the entry box
		
		self.t = ScrolledText(self) # ScrolledText 打印出文档的框
		self.t.grid(columnspan = 2, sticky = W)
		f = open('diary log.txt','a+') 
		self.t.insert(END,f.read()) 
		self.t.see(END)
		
		self.b = Button(self, text="QUIT", fg="red", command=self.quit) # 退出的button
		self.b.grid(row = 2, column = 0, sticky = W)
开发者ID:PythonNing,项目名称:OMOOC2py,代码行数:40,代码来源:diarygui.py

示例12: Application

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import insert [as 别名]
class Application(Frame):

	def __init__(self, master=None):
		Frame.__init__(self, master)
		self.pack()
		self.createWidgets()

	def createWidgets(self): # 创建组件(包括文本框、输入框、)
		# 创建文本框
		self.text = ScrolledText(self) 
		target = open('test.txt', 'a+')  # 打开test.txt,并进入读取与追加状态
		target.seek(0)
		self.text.insert(END, target.read()) # 打印文档记录
		self.text.pack(side= BOTTOM)

		# 创建输入框并可以输入 
		self.content = StringVar(self)
		self.enter = Entry(self,textvariable=self.content)
		self.enter.bind("<Return>", self.write)  # bind第二参数可以调用函数
		self.enter.pack(side=TOP,fill = X)

	def write(self,target): # 输入内容后,按<Return>消失,同时内容一能保存到txt文档,二能在文本框显示
		content = self.content.get()
		target = open('test.txt', 'a+')  # 打开test.txt,并进入读取与追加状态
		date = time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime()) # 计算时间(年月日时分秒) 
		target.write(date) # 写入时间
		target.write("\n") # 给写入空一行
		target.write(content) # 写入输入的日记内容
		target.write("\n\n") # 重新开一行,保持每行只有一条日记内容
		target.close()
		self.text.insert(END,date)
		self.text.insert(END,"\n")
		self.text.insert(END,content) # 在文本框显示
		self.text.insert(END,"\n\n")
		self.text.see(END) # 指定位置
		self.enter.delete(0,END) # 清除输入框内容,需由bind的Return激活
开发者ID:junjielizero,项目名称:OMOOC2py,代码行数:38,代码来源:demo.py

示例13: __init__

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import insert [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()
#.........这里部分代码省略.........
开发者ID:cenan,项目名称:snpptmngr,代码行数:103,代码来源:snip.py

示例14: TextEditor

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import insert [as 别名]
class TextEditor(EventBasedAnimationClass):

    @staticmethod
    def make2dList(rows, cols):
        # From 15-112 class notes
        a=[]
        for row in xrange(rows): a += [[0]*cols]
        return a

    @staticmethod
    def readFile(filename, mode="rt"):
        # From 15-112 class notes
        # rt = "read text"
        with open(filename, mode) as fin:
            return fin.read()

    @staticmethod
    def writeFile(filename, contents, mode="wt"):
        # From 15-112 class notes
        # wt = "write text"
        with open(filename, mode) as fout:
            fout.write(contents)


    def highlightError(self, lineNumber):
        # highlights error in the code based on line number
        self.textWidget.tag_remove("error",1.0,END)
        self.textWidget.tag_add("error", "%d.0"%lineNumber,
            "%d.end"%lineNumber)
        self.textWidget.tag_config("error", underline = 1)

    def colorIsBlack(self, color):
        # ranks whether a color is nearing black or white
        color = color[1:]
        count = int(color,16)
        if(count<(16**len(color) -1 )/2):
            return True
        return False

    def styleTokens(self,tokenisedText,colorScheme,
                    startIndex,seenlen,seenLines,flag):
        # apply style to tokens in the text
        for token in tokenisedText:
            styleForThisToken = colorScheme.style_for_token(token[0])
            if(styleForThisToken['color']):
                self.currentColor = "#" + styleForThisToken['color'] 
            else:
                if(self.colorIsBlack(colorScheme.background_color)):
                    self.currentColor = "White"
                else: self.currentColor = "Black"
            if(token[1] == "\n"): seenLines += 1
            if(seenLines > 23 and flag): break
            # the '#' is to denote hex value
            textWidget = self.textWidget
            newSeenLen = seenlen + len(token[1])
            textWidget.tag_add(startIndex+"+%dc"%seenlen,
                startIndex+"+%dc"%(seenlen),
                startIndex+"+%dc"%(newSeenLen))
            self.textWidget.tag_config(startIndex+"+%dc"%seenlen,
                foreground = self.currentColor)
            seenlen = newSeenLen

    def checkErrors(self):
        # checks whether there is an error in the code by parsing it
        # and analysing the traceback
        errors = MyParse().pythonCodeContainsErrorOnParse(self.currentText)
        if(errors[0]):
            try:
                lineNumber=int(errors[1][-5][errors[1][-5].find("line ")+5:])
            except:
                lineNumber=int(errors[1][-7][errors[1][-7].find("line ")+5:])
            self.highlightError(lineNumber)
        else:
            self.textWidget.tag_remove("error",1.0,END)

    def highlightText(self,lineCounter = "1",columnCounter = "0",flag = False):
        # highlight text since syntax mode is on
        text = self.currentText.split("\n")
        text = "\n".join(text[int(lineCounter)-1:])
        startIndex = lineCounter + "." + columnCounter
        seenlen, seenLines = 0,0
        tokenisedText = pygments.lex(text, self.lexer)
        if(self.colorScheme):
            colorScheme = pygments.styles.get_style_by_name(self.colorScheme)
        else:
            colorScheme = pygments.styles.get_style_by_name(
                self.defaultColorScheme)
        if(self.colorIsBlack(colorScheme.background_color)):
            self.insertColor = "White"
        else: self.insertColor = "Black"
        self.textWidget.config(background = colorScheme.background_color,
            highlightbackground = colorScheme.highlight_color,
            highlightcolor = colorScheme.highlight_color,
            insertbackground = self.insertColor)
        self.styleTokens(tokenisedText,colorScheme,startIndex,seenlen,
            seenLines, flag)
        if(self.fileExtension == ".py" and self.errorDetectionMode):
            self.checkErrors()

    def editDistance(self,currentWord, word):
#.........这里部分代码省略.........
开发者ID:manikpanwar,项目名称:CollaborativeCoder,代码行数:103,代码来源:textEditor.py

示例15: initialisation

# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import insert [as 别名]
	def initialisation(self):
		global input_pipe
		global output_pipe

		if len(sys.argv) > 2 :
			print 'output_pipe : ', output_pipe
		global ChaineALire
		global st
		global fp
		global colorbox
		global sortieTube
		global entreeTube



		texte = """ Welcome in GUI for ARINC 653 emulator 
"""

		#on cree un fenetre principale 'fp' a� partir du 'modele' Tk   
		#fp = Tk()
		self.title('ARINC 653 Partition')	

		#Declaration du texte deroulant dans 'fp'
		st = ScrolledText(self,wrap="word")
		st.grid(column=1,columnspan=2,rowspan=2,sticky='nw')

		#Creation d'un panneau 'menu_bottom' insere dans 'fp'
#		menu_bottom = Frame(self,borderwidth=2)
#		menu_bottom.grid(column=1,columnspan=3,sticky='sw')

		##Creation d'une etiquette inseree dans 'menu_bottom'
		#etiquette = Label(menu_bottom,text = 'Commande : ')
		#etiquette.grid(row=1,column=1,sticky='w')

		##Creation d'un boutton dans 'menu_bottom'
		#b = Button(menu_bottom,text='execute',command=self.affiche_commande)
		#b.grid(row=1,column=3,sticky='e')

		##Creation d'un boite d'edition dans 'nenu_top'
		#entre = Entry(menu_bottom,width=20,relief='sunken')
		#entre.insert(END,'Texte a afficher')
		#entre.grid(row=1,column=2,sticky='ew')
			
		#Creation d'une etiquette inseree
		etiquette = Label(self,text = 'Command : ')
		etiquette.grid(row=2,column=0,sticky='w')			
		
		#Creation d'un boutton
		b = Button(self,text='execute',command=self.affiche_commande)
		b.grid(row=2,column=2,sticky='e')

		#Creation d'un boite d'edition dans 'nenu_top'
		entre = Entry(self,width=20,relief='sunken')
		entre.insert(END,'Text to send')
		entre.grid(row=2,column=1,sticky='ew')
		
		partitionbox = Label(self ,text = 'Active partition : ')
		partitionbox.grid(column=0,row=0,sticky='n')
		
		self.labelVariable = StringVar()
		self.backcolorlabel = StringVar()
		self.frontcolorlabel = StringVar()
		self.backcolorlabel = "LightBlue"
		self.frontcolorlabel = "Black"
		label = Label(self,textvariable=self.labelVariable,
			anchor="w",fg=self.frontcolorlabel,bg=self.backcolorlabel,height=28)
		label.grid(column=0,row=1,sticky='EW')
		


		#on insete le texte 'texte' dans le widget 'texte deroulant' nomme 'st'
		st.insert(END,texte)
		#on applique a� tout le texte la police par defaut
		st.config(font = 'Arial 12')
		st.config(foreground='Black')
		#on configure le fond du 'texte derouant'
		st.config(background='LightBlue')
		#e = Entry(st,width=25)


		self.grid_columnconfigure(1,weight=1)
		self.rowconfigure(1,weight=1)
		
		self.resizable(False,True)
		self.update()
		self.geometry(self.geometry())
		
		try:
			assert input_pipe != ''
		
		except AssertionError:
			showerror('error', "no pipe choosed")
			input_pipe = tkFileDialog.askopenfilename(title='Choose the input pipe to open', defaultextension ='.fifo')

		#openning the INPUT pipe
		try:
			assert input_pipe != ''	

			try :

#.........这里部分代码省略.........
开发者ID:ARISSIM,项目名称:ARISS,代码行数:103,代码来源:gui_for_emulator.py


注:本文中的ScrolledText.insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。