Skip to content

frauikram/Python-Todo-App-TinkerUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python-Todo-App-TinkerUI

In this Python code:

  1. We create a TodoApp class inheriting from tk.Tk, which represents the main application window.
  2. Inside the TodoApp class, we initialize the GUI elements such as a Listbox to display the to-do items, an Entry widget for users to input new to-do items, and a Button to add new items.
  3. The add_todo method is called when the user clicks the "Add" button. It retrieves the text from the Entry widget, adds it to the list of to-do items, clears the Entry, and updates the displayed list.
  4. The update_todo_list method refreshes the Listbox with the current list of to-do items.
  • When the TodoApp instance is created, it calls the load_todo_items method to load the todo items from the todo_items.json file.

  • Whenever a new todo item is added, edited, or deleted, the save_todo_items method is called to save the updated todo items to the file.

  • The todo items are stored in a JSON format in the file, making it easy to load and save them using the json module.

  • To run this code, make sure you have Tkinter installed (it's included in Python's standard library), then execute the script. You should see a window with a text entry field, a button, and a listbox where you can add and view to-do items. The app state will be retained even after closing and reopening the application, as the todo items will be loaded from and saved to the file.