GUI输入数据并保存


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()

优质内容筛选与推荐>>
1、NodeJS REST API with MySQL and Express
2、iar的使用问题
3、面向对象之 —— 类、元类、单例
4、Cocos设计模式之外观模式
5、mybatis自动生成model、dao及对应的mapper.xml文件


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号