码迷,mamicode.com
首页 > 其他好文 > 详细

GUI输入数据并保存

时间:2017-08-23 00:34:04      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:loop   span   color   dep   try   import   address   rip   delete   

from tkinter import *

def write_to_file():
    fileContent = open("deliveries.txt","a")
    fileContent.write(depot.get()+"\n")
    fileContent.write(description.get()+"\n")
    fileContent.write(address.get("1.0",END)+"\n")
    fileContent.close()
    depot.delete(0,END)
    description.delete(0,END)
    address.delete("1.0",END)

app = Tk()
app.title("Head-Ex Deliveries")

Label(app,text = "Depot:").pack()
depot = Entry(app)
depot.pack()

Label(app,text = "Description:").pack()
description = Entry(app)
description.pack()

Label(app,text = "Address:").pack()
address = Text(app)
address.pack()

Button(app,text = "Save",width = 10,command = write_to_file).pack()
app.mainloop()

 

GUI输入数据并保存

标签:loop   span   color   dep   try   import   address   rip   delete   

原文地址:http://www.cnblogs.com/liuyang92/p/7414192.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!