Project 1 - English Dictionary App & Library Book Management System
# 1A: English Dictionary App
data = json.load(open('data.json'))
print('Welcome to the Dictionary App')
print('Please sarch your word and automatically it will show the result')
print('Add a word')
print('meaning')
print('Update')
print('Exit')
def dictionary(word):
# Run, RuN, RUN
word = word.lower()
if word in data:
return data[word]
elif word.title() in data:
return data[word.title()]
elif word.upper() in data:
return data[word.upper()]
else:
return "The word is not in our DB."
if __name__ == '__main__':
word = input("Enter the word to sarch:")
output = dictionary(word)
print('Searcing...\n')
print('Search Done!\n')
if type(output) == list:
for item in output:
print(item)
else:
print(output)
print('Thank you for choosing Dictionary app')
Welcome to the Dictionary App Please sarch your word and automatically it will show the result Add a word meaning Update Exit Enter the word to sarch:run Searcing... Search Done! To move quickly by alternately making a short jump off of either foot. To perform an action, as in executing a program or a command. To develop in a direction. To flee; to take to one's heels; to cut and run. To direct or control (e.g. projects, businesses, etc.). To move along, of liquids. To compete in a race. Thank you for choosing Dictionary app
library Book Management System
In this project, a Library Book Management System will be implemented with the front end GUI developed using Tkinter and the backend database implemented in SQLite. It is a single window tkinter GUI application which will implement CRUD( create, read, update, delete) operations on a ‘books’ database, in SQLite. The window will contain text widgets to accept / display book title, author, year of publication, ISBN (optional) and a large text area/ list box to display the records which match the search criteria.
# 1B: library management system
from tkinter import *
import sqlite3
import tkinter.ttk as ttk
import tkinter.messagebox as tkMessageBox
root = Tk()
root.title('Library Book Management System ')
# Methods
def Database():
global conn, cursor
conn = sqlite3.connect('simple11.db')
cursor = conn.cursor()
cursor.execute("CREATE TABLE IF NOT EXISTS member(me_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, bookname TEXT, author TEXT,year TEXT,isbn TEXT)")
def Create():
if BOOKNAME.get()==""or AUTHOR.get()=="" or YEAR.get() =="" or ISBN.get=="":
txt_result.config(text="please enter all the fields",fd="red")
else:
Database()
cursor.execute("INSERT INTO member(bookname,author,year,isbn) VALUES(?,?,?,?)",(str(BOOKNAME.get()),str(AUTHOR.get()),str(YEAR.get()),str(ISBN.get())))
conn.commit()
BOOKNAME.set("")
AUTHOR.set("")
YEAR.set("")
ISBN.set("")
cursor.close()
conn.close()
txt_result.config(text="Record Inserted !",fg="green")
def Read():
tree.delete(*tree.get_children())
Database()
cursor.execute('SELECT * FROM member ORDER BY bookname ASC')
fetch = cursor.fetchall()
for data in fetch:
tree.insert('','end',values=(data[1],data[2],data[3],data[4]))
cursor.close()
txt_result.config(text="Successfully fetched data !",fg="black")
def Update():
con = sqlite3.connect('simple11.db')
cur = con.cursor()
cur.execute("UPDATE member SET author=?,year=?,isbn=? WHERE bookname =?",(author.get(),year.get(),isbn.get(),bookname.get(),))
con.commit()
con.close()
txt_result.config(text="Successfully Updated data !",fg="black")
def Delete():
con = sqlite3.connect('simple11.db')
cur = con.cursor()
cur.execute("DELETE FROM member WHERE bookname =? ",(bookname.get(),))
con.commit()
con.close()
txt_result.config(text="Successfully deleted data !",fg="black")
def Exit():
result = tkMessageBox.askquestion('Do you want to exit ? (y/n)',icon='warning')
if result == 'yes':
root.destroy()
exit()
# variable decalration
BOOKNAME = StringVar()
AUTHOR = StringVar()
YEAR = StringVar()
ISBN = StringVar()
# Frame
Top = Frame(root,width = 600,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=1500,height=600,bd=8,relief='raise')
Right.pack(side=RIGHT)
Forms = Frame(Left,width = 600,height=450)
Forms.pack(side=TOP)
Buttons= Frame(Left,width=300,height =100,bd=8,relief='raise')
Buttons.pack(side=BOTTOM)
# Labels
txt_title = Label(Top,width=900,text='Library Book Management System ')
txt_title.pack()
txt_bookname = Label(Forms, text='Bookname:',font=('arial',16),bd= 15)
txt_bookname.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=3, stick='e')
txt_result = Label(Buttons)
txt_result.pack(side=TOP)
# Entry Widget
bookname = Entry(Forms, textvariable = BOOKNAME, width=30)
bookname.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=2, column=1)
isbn = Entry(Forms, textvariable = ISBN, width=30)
isbn.grid(row=3, column=1)
# Buttons widget
btn_create = Button(Buttons, width =10, text='Create',command= Create)
btn_create.pack(side=LEFT)
btn_read = Button(Buttons, width =10, text='Read',command= Read)
btn_read.pack(side=LEFT)
btn_update = Button(Buttons, width =10, text='Update',command = Update)
btn_update.pack(side=LEFT)
btn_delete = Button(Buttons, width =10, text='Delete',command = Delete)
btn_delete.pack(side=LEFT)
btn_exit = Button(Buttons, width =10, text='Exit',command=Exit)
btn_exit.pack(side=LEFT)
# List widget
scrollbary = Scrollbar(Right, orient=VERTICAL)
scrollbarx = Scrollbar(Right, orient=HORIZONTAL)
tree = ttk.Treeview(Right, columns = ("bookname","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('bookname', text='bookname', 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=120)
tree.column('#2', stretch=NO, minwidth=0, width=120)
tree.column('#3', stretch=NO, minwidth=0, width=120)
tree.column('#4', stretch=NO, minwidth=0, width=120)
tree.pack()
# Initialization
if __name__=='__main__':
root.mainloop()