python基于Tkinter库实现简单文本编辑器实例
来源:中文源码网 浏览: 次 日期:2018年9月2日
【下载文档: python基于Tkinter库实现简单文本编辑器实例.txt 】
(友情提示:右键点上行txt文档名->目标另存为)
python基于Tkinter库实现简单文本编辑器实例 本文实例讲述了python基于Tkinter库实现简单文本编辑器的方法。分享给大家供大家参考。具体实现方法如下:
## { { { http://code.activestate.com/recipes/578568/ (r1)
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)