Implemented most of the api placeholders #23
@@ -11,7 +11,7 @@ if "win" in sys.platform.lower():
|
|||||||
else:
|
else:
|
||||||
DEFAULT_URL = "http://0.0.0.0:8000"
|
DEFAULT_URL = "http://0.0.0.0:8000"
|
||||||
|
|
||||||
BASE_W = 580
|
BASE_W = 600
|
||||||
BASE_H = 400
|
BASE_H = 400
|
||||||
|
|
||||||
TITLE_APP = "ToDo Application"
|
TITLE_APP = "ToDo Application"
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class ToDoList(object):
|
|||||||
|
|
|||||||
|
|
||||||
def remove(self, index):
|
def remove(self, index):
|
||||||
"""
|
"""
|
||||||
Remove item at index from db
|
Remove item AT INDEX from db
|
||||||
```suggestion
created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```
Кажется, лишний print Кажется, лишний print
```suggestion
created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```
Кажется, лишний print Кажется, лишний print
|
|||||||
"""
|
"""
|
||||||
item = self.items_[index]
|
item = self.items_[index]
|
||||||
self.items_.remove(item)
|
self.items_.remove(item)
|
||||||
@@ -85,10 +85,10 @@ class ToDoList(object):
|
|||||||
```suggestion
created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```
```suggestion
created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```
Кажется, лишний print Кажется, лишний print
Кажется, лишний print Кажется, лишний print
|
|||||||
|
|
||||||
def dispose(self):
|
def dispose(self):
|
||||||
print(f"To-do list id '{self.id}' is being disposed of...")
|
print(f"To-do list id '{self.id}' is being disposed of...")
|
||||||
if "DEBUG" in os.environ:
|
|
||||||
```suggestion
created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```
Кажется, лишний print Кажется, лишний print
|
|||||||
return
|
|
||||||
```suggestion
created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```
Кажется, лишний print Кажется, лишний print
|
|||||||
for item in self.items_:
|
for item in self.items_:
|
||||||
item.dispose()
|
item.dispose()
|
||||||
|
if "DEBUG" in os.environ:
|
||||||
```suggestion
created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```
Кажется, лишний print Кажется, лишний print
|
|||||||
|
return
|
||||||
```suggestion
created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```
Кажется, лишний print Кажется, лишний print
|
|||||||
self.user.lists_delete(self.id)
|
self.user.lists_delete(self.id)
|
||||||
|
|
||||||
def sync(self):
|
def sync(self):
|
||||||
@@ -229,11 +229,11 @@ class User(UserApi):
|
|||||||
```suggestion
created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```
```suggestion
created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```
Кажется, лишний print Кажется, лишний print
Кажется, лишний print Кажется, лишний print
|
|||||||
|
|
||||||
def removeUserList(self, id):
|
def removeUserList(self, id):
|
||||||
"""
|
"""
|
||||||
Remove existing user to-do list from the serverreturns:
|
Remove existing user to-do list BY ID from the serverreturns:
|
||||||
```suggestion
created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```
Кажется, лишний print Кажется, лишний print
```suggestion
created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```
Кажется, лишний print Кажется, лишний print
|
|||||||
"""
|
"""
|
||||||
to_remove = [item for item in self.lists_ if item.id == id][0]
|
to_remove = [item for item in self.lists_ if item.id == id][0]
|
||||||
self.lists_.remove(to_remove)
|
self.lists_.remove(to_remove)
|
||||||
if not ("DEBUG" in os.environ):
|
# if not ("DEBUG" in os.environ):
|
||||||
```suggestion
created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```
Кажется, лишний print Кажется, лишний print
```suggestion
created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```
Кажется, лишний print Кажется, лишний print
|
|||||||
to_remove.dispose()
|
to_remove.dispose()
|
||||||
return self.lists_
|
return self.lists_
|
||||||
|
|
||||||
|
|||||||
```suggestion
created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```
```suggestion
created_item = ToDoItem(id=random.randint(100, 1000), text=text, user=self.user)
```
Кажется, лишний print Кажется, лишний print
Кажется, лишний print Кажется, лишний print
|
|||||||
@@ -82,7 +82,7 @@ class ToDoListWidget(tk.Frame):
|
|||||||
add = tk.Button(self, text="Добавить заметку", command=self.add_command)
|
add = tk.Button(self, text="Добавить заметку", command=self.add_command)
|
||||||
add.pack(side="top")
|
add.pack(side="top")
|
||||||
|
|
||||||
delete = tk.Button(self, text="Удалить лист", command=placeholder)
|
delete = tk.Button(self, text="Удалить лист", command=self.master.delete_list)
|
||||||
delete.pack(side="top")
|
delete.pack(side="top")
|
||||||
|
|
||||||
def update(self, itemList=None):
|
def update(self, itemList=None):
|
||||||
@@ -106,6 +106,17 @@ class ToDoListWidget(tk.Frame):
|
|||||||
|
|
||||||
|
|
||||||
class WorkSpaceFrame(tk.Frame):
|
class WorkSpaceFrame(tk.Frame):
|
||||||
|
def delete_list(self, *args):
|
||||||
|
selection = self.listBox.curselection()
|
||||||
|
cur = selection[0]
|
||||||
|
self.user.removeUserList(self.lists[cur].id)
|
||||||
|
self.lists = self.user.fetchUserLists()
|
||||||
|
self.update_lists()
|
||||||
|
if len(self.lists) > 1:
|
||||||
|
self.listBox.selection_set(first=cur - 1)
|
||||||
|
elif len(self.lists) > 0:
|
||||||
|
self.listBox.selection_set(first=0)
|
||||||
|
|
||||||
def __init__(self, user, master=None, url=None) -> None:
|
def __init__(self, user, master=None, url=None) -> None:
|
||||||
"""
|
"""
|
||||||
Функция инициаизации класса
|
Функция инициаизации класса
|
||||||
@@ -154,16 +165,36 @@ class WorkSpaceFrame(tk.Frame):
|
|||||||
# add scroll bar to list box
|
# add scroll bar to list box
|
||||||
self.listBox.config(yscrollcommand=scrollbar.set)
|
self.listBox.config(yscrollcommand=scrollbar.set)
|
||||||
|
|
||||||
# fill list box
|
# init list view
|
||||||
|
self.update_lists()
|
||||||
|
|
||||||
|
# canvas for todo lists
|
||||||
|
# canvas = tk.Canvas(self)
|
||||||
|
# canvas.pack(side="left", fill="both", expand=1)
|
||||||
|
# scrollbar = tk.Scrollbar(self, orient="vertical")
|
||||||
|
# scrollbar.config(command=canvas.yview)
|
||||||
|
# scrollbar.pack(side="left", fill="y")
|
||||||
|
# canvas.configure(yscrollcommand=scrollbar.set)
|
||||||
|
|
||||||
|
# todo lists
|
||||||
|
self.toDoList = ToDoListWidget(self)
|
||||||
|
# self.toDoList = ToDoListWidget(canvas)
|
||||||
|
self.toDoList.pack(side="left", fill="y")
|
||||||
|
# canvas.bind('<Configure>', lambda *argv: print(self.toDoList.winfo_height()))
|
||||||
|
# canvas.create_window((0,0), window=self.toDoList, anchor='nw')
|
||||||
|
|
||||||
|
# select list!
|
||||||
|
if len(self.lists) > 0:
|
||||||
|
self.listBox.selection_set(first=0)
|
||||||
|
self.listBox_selected()
|
||||||
|
|
||||||
|
def update_lists(self):
|
||||||
|
self.listBox.delete(0, "end")
|
||||||
for item in self.lists:
|
for item in self.lists:
|
||||||
s = f"{str(item)}: {item.created_at.strftime('%Y-%m-%d %H:%M:%S')}"
|
s = f"{str(item)}: {item.created_at.strftime('%Y-%m-%d %H:%M:%S')}"
|
||||||
self.listBox.insert(tk.END, s)
|
self.listBox.insert(tk.END, s)
|
||||||
self.listBox.pack()
|
self.listBox.pack()
|
||||||
len(self.lists) > 0 and self.listBox.selection_set(first=0)
|
return len(self.lists)
|
||||||
|
|
||||||
# todo lists
|
|
||||||
self.toToList = ToDoListWidget(self)
|
|
||||||
self.toToList.pack(side="left", fill="both", expand=1)
|
|
||||||
|
|
||||||
def add_list(self, *args):
|
def add_list(self, *args):
|
||||||
text = self.add_list_text.get(1.0, "end").strip()
|
text = self.add_list_text.get(1.0, "end").strip()
|
||||||
@@ -174,18 +205,13 @@ class WorkSpaceFrame(tk.Frame):
|
|||||||
self.lists = self.user.fetchUserLists()
|
self.lists = self.user.fetchUserLists()
|
||||||
|
|
||||||
# fill list box
|
# fill list box
|
||||||
self.listBox.delete(0, "end")
|
self.update_lists()
|
||||||
for item in self.lists:
|
len(self.lists) > 0 and self.listBox.selection_set(first=len(self.lists) - 1)
|
||||||
s = f"{str(item)}: {item.created_at.strftime('%Y-%m-%d %H:%M:%S')}"
|
|
||||||
self.listBox.insert(tk.END, s)
|
|
||||||
self.listBox.pack()
|
|
||||||
len(self.lists) > 0 and self.listBox.selection_set(first=0)
|
|
||||||
|
|
||||||
def listBox_selected(self, *args):
|
def listBox_selected(self, *args):
|
||||||
|
self.toDoList.clear()
|
||||||
self.toToList.clear()
|
|
||||||
|
|
||||||
selection = self.listBox.curselection()
|
selection = self.listBox.curselection()
|
||||||
cur = selection[0]
|
cur = selection[0]
|
||||||
|
|
||||||
self.toToList.fill(self.lists[cur])
|
self.toDoList.fill(self.lists[cur])
|
||||||
|
|||||||
Reference in New Issue
Block a user
Кажется, лишний print
Кажется, лишний print