Home >Backend Development >Python Tutorial >Python基于Tkinter实现的记事本实例

Python基于Tkinter实现的记事本实例

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 11:18:361748browse

本文实例讲述了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程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn