python基于tkinter实现的记事本实例

本文实例讲述了python基于tkinter实现的记事本。分享给大家供大家参考。具体如下:

from tkinter import *
root = tk(‘simple editor’)
mi=stringvar()
label(text=’please input something you like~’ ).pack()
te = text(height = 30,width =100)
te.pack()
label(text=’ file name ‘).pack(side = left)
entry(textvariable = mi).pack(side = left)
mi.set(‘*.txt’)
def save():
t = te.get(‘0.0′,’10.0′)
f = open(mi.get(),’w’)
f.write(t)
button(text = ‘save’ , command = save).pack(side = right)
button(text = ‘exit’ , command = root.quit).pack(side = right)
mainloop()

希望本文所述对大家的python程序设计有所帮助。

Posted in 未分类

发表评论