Project 1 - English Dictionary App & Library Book Management System
## Dictionary App
import json
print('welcome to the Dictionary App')
print('please select your Choice')
print('1.add a word')
print('2.Find the Meaning')
print('3.Update the Word')
print('4.Exist')
f=open('word.txt','w')
coll_words={}
json.dump(coll_words,f)
f.close
while True:
n=int(input('enter the choice NO.: '))
if n == 1:
f=open('word.txt','w')
word=input('Enter The Word: ')
meaning=input('Enter The Meaning: ')
coll_words[word]=meaning
json.dump(coll_words,f)
f.close()
elif n==2:
import json
f=open('word.txt','r+')
dic=json.load(f)
find=input('Enter The Word To Search')
if find in coll_words:
print('Meaning Is= ',coll_words.get(find))
else:
print('Oops Not Found')
json.dump(coll_words,f)
f.close()
elif n==3:
import json
f=open('word.txt','w')
word1=input('Enter The Word:')
update_meaning=input('Enter The Update Meaning: ')
coll_words[word1]=update_meaning
json.dump(coll_words,f)
f.close()
elif n==4:
print('thank you')
break
else:
print('welcome to the Dictionary App')
print('please select your Choice')
print('1.add a word')
print('2.Find the Meaning')
print('3.Update the Word')
print('4.Exist')
## Library Book Management System
from tkinter import *
import sqlite3
import tkinter.ttk as ttk
import tkinter.messagebox as tkMessageBox
root=Tk()
root.title('...Library Management Aplication...')
def Detabase():
global conn,cursor
conn=sqlite3.connect('simple.db')
cursor=conn.cursor()
cursor.execute('CREATE TABLE IF NOT EXISTS member(mem_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,booktitle TEXT,author TEXT,year TEXT,ISBN TEXT)')
def Create():
if BOOKTITLE.get()=="" or AUTHOR.get()=="" or YEAR.get=="" or ISBN.get=="" :
txt_result.config(text='Please Fill All',fg='red')
else:
Database()
cursor.execute('INSTER INTO member(booktitle,author,year,isbn) VALUES(?,?,?,?)',str(BOOKTITLE.get()),str(AUTHOR.get()),int(YEAR.get()),str(ISBN.get()))
conn.commit()
BOOKTITLE.set('')
AUTHOR.set('')
YEAR.set('')
ISBN.set('')
cursor.close()
conn.close()
txt_result.config(text='Record Insterd',fg='green')
def Read():
tree.delete(*tree.get_children)
Database()
for data in fetch:
tree.insert('','end',values=(data[1],data[2],data[3],data[4]))
cursor.close()
txt_result.config(text='Succefully fetched data',fg='black')
def Exit():
result=tkMessageBox.askquestion('Do you want Exit? (y/n)',icon='warning')
if result == 'yes':
root.destroy()
exit()
BOOKTITLE=StringVar()
AUTHOR=StringVar()
YEAR=StringVar()
ISBN=StringVar()
Top=Frame(root,width=900,height=50,bd=8,relief='raise')
Top.pack(side=TOP)
Left=Frame(root,width=300,height=500,bd=8,relief='raise')
Left.pack(side=LEFT)
Right=Frame(root,width=600,height=500,bd=8,relief='raise')
Left.pack(side=RIGHT)
Forms=Frame(Left,width=300,height=450)
Forms.pack(side=TOP)
Buttons=Frame(Left,width=300,height=100,bd=8,relief='raise')
Buttons.pack(side=BOTTOM)
txt_title=Label(Top,width=900,text='...Library Management Aplication...')
txt_title.pack()
txt_booktitle = Label (Forms, text="Booktitle:", font=('arial', 16), bd=15)
txt_booktitle.grid(row=0, stick="e")
txt_author = Label (Forms, text="Author:", font=("arial", 16), bd=15)
txt_author.grid(row=1, stick="e")
txt_year = Label (Forms, text="Year:", font=('arial', 16), bd=15)
txt_year.grid(row=2, stick="e")
txt_isbn = Label (Forms, text="ISBN:", font=('arial', 16), bd=15)
txt_isbn.grid(row=4, stick="e")
txt_result = Label (Buttons)
txt_result.pack(side=TOP)
booktitle=Entry(Forms, textvariable=BOOKTITLE, width=30)
booktitle.grid(row=0, column=1)
author=Entry(Forms, textvariable=AUTHOR, width=30)
author.grid(row=1, column=1)
year = Entry(Forms, textvariable=YEAR, width=30)
year.grid(row=4, column=1)
btn_display =Button(Buttons, width=10, text="Display", command=Create)
btn_display.pack(side=LEFT)
btn_search =Button(Buttons, width=10, text="Search", command=Read )
btn_search.pack(side=LEFT)
btn_add=Button (Buttons, width=10, text="Add", state=DISABLED)
btn_add.pack(side=LEFT)
btn_delete=Button(Buttons, width=10, text="Delete", state=DISABLED)
btn_delete.pack(side=LEFT)
btn_issue=Button(Buttons, width=10, text="Issue", state=DISABLED)
btn_issue.pack(side=LEFT)
btn_exit=Button(Buttons, width=10, text="Exit", command=Exit)
btn_exit.pack(side=LEFT)
scrollbary=Scrollbar(Right,orient=VERTICAL)
scrollbarx=Scrollbar(Right,orient=HORIZONTAL)
tree=ttk.Treeview(Right, columns=("booktitle", "author", "year", "isbn"))
scrollbary.config(command=tree.yview)
scrollbary.pack(side=RIGHT, fill=Y)
scrollbarx.config(command=tree.xview)
scrollbarx.pack (side=BOTTOM, fill=X)
tree.heading("booktitle", text="Booktitle", anchor=W)
tree.heading('author', text="Author", anchor=W)
tree.heading("year", text="Year", anchor=W)
tree.heading("isbn", text="ISBN", anchor=W)
tree.column('#0', stretch=NO, minwidth=0, width=0)
tree.column('#1', stretch=NO, minwidth=0, width=80)
tree.column('#2', stretch=NO, minwidth=0, width=120)
tree.column('#3', stretch=NO, minwidth=0, width=80)
tree.pack()
if __name__=='__main__':
root.mainloop()