Created
September 26, 2023 19:56
-
-
Save princetechs/b4332c9505bef05e9de69d7809a80d66 to your computer and use it in GitHub Desktop.
a tkintre todo app using code interpreter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tkinter as tk | |
| window = tk.Tk() | |
| window.title('Todo App') | |
| # Create a text entry widget | |
| entry = tk.Entry(window) | |
| entry.pack() | |
| # Create a button to add tasks | |
| add_button = tk.Button(window, text='Add Task') | |
| add_button.pack() | |
| # Create a listbox widget | |
| listbox = tk.Listbox(window) | |
| listbox.pack() | |
| # Create buttons to mark tasks as complete or delete them | |
| complete_button = tk.Button(window, text='Complete') | |
| complete_button.pack() | |
| delete_button = tk.Button(window, text='Delete') | |
| delete_button.pack() | |
| # Create functions to handle button clicks | |
| def add_task(): | |
| task = entry.get() | |
| listbox.insert(tk.END, task) | |
| entry.delete(0, tk.END) | |
| def complete_task(): | |
| selected_task = listbox.curselection() | |
| if selected_task: | |
| listbox.itemconfig(selected_task, fg='gray') | |
| def delete_task(): | |
| selected_task = listbox.curselection() | |
| if selected_task: | |
| listbox.delete(selected_task) | |
| add_button.config(command=add_task) | |
| complete_button.config(command=complete_task) | |
| delete_button.config(command=delete_task) | |
| window.mainloop() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment