这是我的代码删除了一些位,这会将输出发送到" Notes.txt"文本文件,但它通常只发送一个小数点后跟随机的十进制数字。希望是初学者的错误。下面的代码片段:
class Window (Frame):
def __init__(self, master = None):
Frame.__init__(self, master)
self.master = master
self.init_window()
def init_window (self):#This sets up the 'Window Frame'
self.master.title("'Joe Banks' - Witty name to follow")
self.pack(fill=BOTH, expand=1)
#Irrelevant File Menus and buttons removed
#Adds Textbox for typing Notes etc.
blankTextbox = Text(app, width = 30, height=4, font=("CenturyGothic",18))
blankTextbox.place(x=270, y=550, anchor="c")
然后以不同的程序:
def saveTextboxToFile(self):
fileContent = str(Text(app, width = 30, height=4, font=("CenturyGothic",18)))
file = open("Notes.txt", "w")
file.write(fileContent)
file.close()