I am making a simple todo app with Qt in Python 3. I am using JSON to store the todo list data.
Here is the format of my JSON:
Category (todo, inprog or done). Then a list of tasks with 3 fields. name (str), desc (str), due (str).
Here is an example of the JSON I am dealing with:
{
"todo": [
{
"name": "todo-test",
"desc": "just a test task",
"due": "DD/MM/YYYY HH:MM:SS"
},
{
"name": "todo-test2",
"desc": "just a test task",
"due": "DD/MM/YYYY HH:MM:SS"
}
],
"inprog": [
{
"name": "inprog-test",
"desc": "just a test task",
"due": "DD/MM/YYYY HH:MM:SS"
},
{
"name": "inprog-test2",
"desc": "just a test task",
"due": "DD/MM/YYYY HH:MM:SS"
}
],
"done": [
{
"name": "done-test",
"desc": "just a test task",
"due": "DD/MM/YYYY HH:MM:SS"
},
{
"name": "done-test2",
"desc": "just a test task",
"due": "DD/MM/YYYY HH:MM:SS"
}
]
}
As you can see, it is very simple.
I need some help with moving an item from (for example) todo to inprogress. Here is my current, unfinished function.
def moveCheckbox(self, cb, state):
"""Deletes specified task (cb) from to-do.json and re-adds it
in the new category based on the state (state) of the checkbox.
"""
todo_text = cb.text()
todo_json = self.validate_todo_json()
print(todo_json)
if state == 0:
for item in todo_json['todo']:
if item.name == todo_text:
todo_json['todo'].remove(item)
todo_json['inprog'].append(item)
I am using checkboxes to represent the todo items. For people who are unfimiliar with Qt, state of 0 = unchecked, state of 1 = partial check, state of 2 = checked. This is the base layout of the current UI:
Each category is a state of checkbox.
In short, how can I move an item from the ‘todo’ category from my JSON, to the ‘inprog’ category (or from/to any other category)
