开发者社区> 问答> 正文

如何将输入框中的键入行打印为txt文档中的文本

我想打印的文本内的条目作为文本在一个。txt文件,但经过三天多的尝试,我仍然没有得到它的工作。它不应该像它是那么难,但GUI只是不会找到在FrameStart1中的条目,我不断得到: 是一个错误。

    image = PhotoImage(file='C:/Users/plarkin2020334/Pictures/DQ_Logocp.png')
    def __init__(self, parent, *args, **kwargs):
        tkinter.Frame.__init__(self, parent, *args, **kwargs)
        Label(self, image=self.image).place(relx=0, rely=0, anchor=NW)
        Label(self, text="Enter any additional Instructiuons for the day:", background="#3f49e5").place(relx=.0, rely=.45)
        Button(self, text="Add to Todays List", command=self.add_list()).place(relx=.30, rely=.51)
        self.entry = tkinter.Entry(self)

    def add_list(self):
        file = open("List.txt", "a+")
        file.write(self.entry.get())
        file.close()

问题来源StackOverflow 地址:/questions/59379566/how-to-print-the-typed-line-in-the-entry-box-as-text-in-a-txt-document

展开
收起
kun坤 2019-12-29 21:57:10 496 0
1 条回答
写回答
取消 提交回答
  • 精于基础,广于工具,熟于业务。

    你的代码和你的问题描述不一样啊。。。读取键盘输入一般使用scan就可以了。

    2019-12-30 09:00:56
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载