小编Pio*_*otr的帖子

在基于 python/tkinter 的文本编辑器中实现文本自动完成

我想在下面代码框中提供的这个简单 Tkinter 文本编辑器的主文本窗口(不是 Tkinter.entry - 可以找到相关示例)中使用自动完成算法。我认为 beeing 的自动完成算法取决于自动完成的单词列表,即代码示例[1] 中提供的

到目前为止,我发现了两个自动完成的代码示例,一个是使用输入框 [1] 的 Tkinter,另一个是 IDLE [2]的外部模块(由 Jerry King,)。

到目前为止,我通过将 [1] 代码的元素移动到文本编辑器中来生成工作代码的所有尝试都失败了。请注意,我对 Tkinter 很陌生,因此也在整个框架中挣扎

# taken from http://www.java2s.com/Code/Python/GUI-Tk/SimpleEditor.htm


from Tkinter import * 
from tkSimpleDialog import askstring
from tkFileDialog   import asksaveasfilename

from tkMessageBox import askokcancel          

class Quitter(Frame):                        
    def __init__(self, parent=None):          
        Frame.__init__(self, parent)
        self.pack()
        widget = Button(self, text='Quit', command=self.quit)
        widget.pack(expand=YES, fill=BOTH, side=LEFT)
    def quit(self):
        ans = askokcancel('Verify exit', "Really quit?")
        if ans: Frame.quit(self)


class ScrolledText(Frame):
    def __init__(self, parent=None, text='', file=None):
        Frame.__init__(self, …
Run Code Online (Sandbox Code Playgroud)

python text autocomplete editor tkinter

5
推荐指数
1
解决办法
2710
查看次数

标签 统计

autocomplete ×1

editor ×1

python ×1

text ×1

tkinter ×1