get() missing 1 required positional argument: 'index1'
错误如下:Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Charlie\AppData\Local\Programs\Python\Python38\lib\tkinter\__init__.py", line 1883, in __call__
return self.func(*args)
File "D:\my.code\BookBook\dist\BookBook.py", line 401, in ok
f.write(nowTime + '\n'+ nameEntered.get() + '\n' + adEntered.get() + '\n'+ b +'\n\n')
TypeError: get() missing 1 required positional argument: 'index1'
部分代码:
monty = tk.LabelFrame(text='写日记')
monty.grid(column=0, row=0, padx=20, pady=30)
ttk.Label(monty, text="心情:").grid(column=0, row=0, sticky='W')
name = tk.StringVar()
nameEntered = tk.Entry(monty, width=35, textvariable=name)
nameEntered.grid(column=1, row=0, sticky='W')
ttk.Label(monty, text="我想说:").grid(column=0, row=2, sticky='W')
adEntered = tk.Text(monty, width=35,height=3)
adEntered.grid(column=1, row=2, sticky='W')
nowTime = str(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
ac = ttk.Button(monty, text="退出", width=10, command=ex)
ac.grid(column=5, row=3, rowspan=2, ipady=7)
def adder():
import tkinter.filedialog
filename = tkinter.filedialog.askopenfilename()
with open('fj.txt','w') as f:
f.write(filename)
mBox.showwarning('提示', '已完成!')
action = ttk.Button(monty, text="增加附件", width=10, command=adder)
action.grid(column=1, row=3, rowspan=2, ipady=7)
def ok():
a = open('fj.txt')
b = a.read()
with open('fj.txt', 'w') as f:
f.write('无附件')
with open('diary.dia', 'a+') as f:
f.write(nowTime + '\n'+ nameEntered.get() + '\n' + adEntered.get() + '\n'+ b +'\n\n')
with open('one.txt','a+') as f:
f.write(adEntered.get() + '\n')
with open('number.txt','a+') as f:
f.write('1')
mBox.showwarning('提示', '已完成!') 报错:nameEntered.get()中的get调用的时候缺一个位置参数。 hrp 发表于 2021-2-21 20:39
报错:nameEntered.get()中的get调用的时候缺一个位置参数。
所以如何解决啊?
页:
[1]