以下是我创建待办事项列表应用程序的代码
from tkinter import ...
// i have just not mentioned all imports
root = Tk()
root.title("My Todo List App")
root.configure(background="light green")
root.geometry("550x500")
root.resizable(width=False , height=False)
title_label = ttk.Label(root, text="Title",background="light green",font=("TkDefaultFont",16))
title_label.grid(row=0, column=0, sticky=W)
title_text = StringVar()
title_entry = ttk.Entry(root, width=25, textvariable=title_text)
title_entry.grid(row=0, column=1, sticky=W)
add_btn = Button(root, text="Add Task", bg="blue", fg="white", font="helvetica 1- bold", command="")
add_btn.grid(row=0, column=2, sticky=W)
root.mainloop()
我在运行上述代码时在 Visual Studio 代码中遇到的错误是:
C:\Users\tkurd\AppData\Local\Programs\Python\Python39\python.exe C:/Users/tkurd/Desktop/todolist/todo.py
Traceback (most recent call last):
File "C:\Users\tkurd\Desktop\todolist\todo.py", line 22, in <module>
add_btn = Button(root, text="Add Task", bg="blue", fg="white", font="helvetica 1- bold", command="")
File "C:\Users\tkurd\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 2650, in __init__
Widget.__init__(self, master, 'button', cnf, kw)
File "C:\Users\tkurd\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 2572, in __init__
self.tk.call(
_tkinter.TclError: expected integer but got "1-"
Process finished with exit code 1