Daily planner made of tkinter & sqlite3
lucakim27 / planner Goto Github PK
View Code? Open in Web Editor NEWA planner made of tkinter GUI python & Sqlite3 database
A planner made of tkinter GUI python & Sqlite3 database
I wanna delete a current dates tasks and im not sure how to delete a specific row which is combined between "Tasks" and "Date" field name in the table.
Thanks for your help in advance!
import tkinter as tk
from tkinter import ttk
from tkinter import messagebox
from tkcalendar import Calendar, DateEntry
import sqlite3 as sq
root = tk.Tk()
root.title('Planner')
root.geometry("530x300+500+500")
# Making a database file called "planner.db"
conn = sq.connect('PlannerDB.db')
# The database will be saved in the location where your 'py' file is saved
cur = conn.cursor()
# Create table - PLANNER
cur.execute('''CREATE TABLE IF NOT EXISTS PLANNER
([Tasks] text, [Date] date)''')
task = []
# clear tkinter listbox
def clearList():
t.delete(0,'end')
def addTask():
word = e1.get()
date = cal.get_date()
rows = [(word, date)]
if len(word)==0:
messagebox.showinfo('Empty Entry', 'Enter task name')
elif l1.cget("text")=="":
messagebox.showinfo('Empty Entry', 'Enter date')
else:
task.append(word)
cur.executemany('INSERT INTO PLANNER VALUES (?, ?)', rows)
selectDate()
e1.delete(0,'end')
# If the value you delete exists then it also gets deleted on any dates.
def delOne():
try:
val = t.get(t.curselection())
cur.execute('DELETE FROM PLANNER WHERE Tasks = (?)', (val,))
selectDate()
except:
messagebox.showinfo('Cannot Delete', 'No Task Item Selected')
def deleteAll():
mb = messagebox.askyesno('Delete All','Are you sure?')
date = cal.get_date()
if mb==True:
cur.execute('DELETE FROM PLANNER WHERE Date = (?)', (date,))
selectDate()
def bye():
root.destroy()
def selectDate():
l1["text"] = cal.get_date()
clearList()
cur.execute("SELECT * FROM PLANNER")
values = []
for val in cur:
if (str(cal.get_date()) == val[1]):
values.append(val[0])
for i in values:
t.insert("end", i)
l1 = ttk.Label(root, text="")
l1.place(x=370 ,y=30)
l2 = ttk.Label(root, text='Enter down below')
e1 = ttk.Entry(root, width=21)
t = tk.Listbox(root, height=11, selectmode='SINGLE')
b1 = ttk.Button(root, text='Add task', width=20, command=addTask)
b2 = ttk.Button(root, text='Delete', width=20, command=delOne)
b3 = ttk.Button(root, text='Delete all', width=20, command=deleteAll)
b4 = ttk.Button(root, text='Exit', width=20, command=bye)
b5 = ttk.Button(root, text='Select', width=20, command=selectDate)
cal = DateEntry(root, width=30, bg="darkblue", fg="black", year=2021)
cal.grid()
#Place geometry
l2.place(x=90, y=50)
e1.place(x=50, y=80)
b1.place(x=40, y=110)
b2.place(x=40, y=140)
b3.place(x=40, y=170)
b4.place(x=40, y =200)
b5.place(x=300, y=0)
t.place(x=320, y=50)
root.mainloop()
conn.commit()
cur.close()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.