Challenge

Project 1 - English Dictionary App & Library Book Management System

#CHALLENGE 13-PROJECT 1(A)


# ENGLISH DICTIONARY APP

import sys
import fileinput

print("******************************************** WELCOME TO MY DICTIONARY ************************************************")

chiceStr='''

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Main Menu ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Press 1 --> For Add a new word
Press 2 --> For Find the meaning
Press 3 --> For Update a word
Press 4 --> For Exit '''
def NEW():
while True:
def mainFuc():
print(chiceStr)
choice=int(input("Enter Your Choice 1 to 4 \n"))
if choice==1:
Add_New_Word()
elif choice==2:
Find_Meaning()
elif choice==3:
Update_Word()
elif choice==4:
Exit()
else:
print("Your Choice is wrong ")
mainFuc()


def Add_New_Word():
f = open('words.txt','a+')
word = input("Enter your word:")
meaning = input("Enter the Meaning of the word:")
a = word + " : " + meaning
f.write("\n")
f.write(a)
print("data stored sucsessfully!")
f.close()


def Find_Meaning():
readFile = open('words.txt', 'r')
print(readFile)
word = input("Enter word to find the meaning: ")
for i in readFile:
if word in i:
print("This word is present in the dictionary:", i)
break
readFile.close()


def Update_Word():
word = input("Enter text to be replaced:")
replacement_Word = input("Enter replacement text:")
f=open('words.txt','a+')
for line in f.readlines():
a=line.replace(word, replacement_Word)
f.close()
print('Word is successfully updated !')



def Exit():
sys.exit()

NEW()
Add_New_Word()
Find_Meaning()
Update_Word()
Exit()


#CHALLENGE 13-PROJECT 1(B)

# LIBRARY BOOK MANAGEMENT SYSTEM

#Libraries

from tkinter import *
import sqlite3
import tkinter.ttk as ttk
import tkinter.messagebox as tkMessageBox

root = Tk()
root.title("LIBRARY BOOK MANAGEMENT SYSTEM BY YOGESH")
root.geometry("1550x800")
#Methods

def Database():
global conn,cursor
conn = sqlite3.connect('books.db')
cursor = conn.cursor()
cursor.execute("CREATE TABLE IF NOT EXISTS book(booktitle TEXT, author TEXT, year INTEGER,isbn VARCHAR)")

def Create():
if BOOKTITLE.get() == "" or AUTHOR.get() == "" or YEAR.get()== "" or ISBN.get()=="":
txt_result.config(text="Please enter all the fields",fg="red")
else:
Database()

cursor.execute("INSERT INTO book(booktitle, author,year,isbn) VALUES(?,?,?,?)",(str(BOOKTITLE.get()),str(AUTHOR.get()),str(YEAR.get()),str(ISBN.get())))

conn.commit()
BOOKTITLE.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 book ORDER BY AUTHOR ASC")
fetch = cursor.fetchall()
for data in fetch:
tree.insert('','end',values =(data[0],data[1],data[2],data[3]))
cursor.close()
txt_result.config(text = "Successfully collected data !",fg = "black")

def Update():
if not tree.selection():
txt_result.config(text="Please select an item first",fg="red")
else:
result=tkMessageBox.askquestion('UPDATE','Do you want to update this Item. ',icon='warning')
if result=='yes':
curItem = tree.focus()
contents=(tree.item(curItem))
selecteditem=contents['values']
tree.delete(curItem)
Database()
CUrsor.execute("UPDATE Book SET booktitle=%s, author=%s, year=%s, isbn=%s",
(str(BOOKTITLE.get()),str(AUTHER.get()),str(YEAR.get()),str(ISBN.get()),))
BOOKTITLE.set("")
AUTHER.set("")
YEAR.set("")
ISBN.set("")
conn.commit()
conn.close()
txt_result.config(text="The item is successfully updated!",fg='blue')



def Delete():
if not tree.selection():
txt_result.config(text="Please select an item first",fg="red")
else:
result=tkMessageBox.askquestion('DELETE','Do you want to delete this data. ',icon='warning')
if result=='yes':
curItem = tree.focus()
contents=(tree.item(curItem))
selecteditem=contents['values']
tree.delete(curItem)
Database()
cursor.execute("DELETE FROM book WHERE booktitle=%d"%selected[0])
conn.commit()
conn.close()
txt_result.config(text="The item successfully deleted from the database!",fg='red')




def Exit():
result = tkMessageBox.askquestion('EXIT ? (Yes/No)',icon='warning')
if result == 'yes':
root.destroy()
exit()

#variable declaration

BOOKTITLE= StringVar()
AUTHOR= StringVar()
YEAR= StringVar()
ISBN= StringVar()

#FRAME

Top = Frame(root,width=900,height=50,bd=8,relief='raise',bg="red")
Top.pack(side=TOP)
Left = Frame(root,width=300,height=500,bd=8,relief='raise',bg="cyan")
Left.pack(side=LEFT)
Right = Frame(root,width=600,height=500,bd=8,relief='raise',bg="yellow")
Right.pack(side=RIGHT)

Forms = Frame(Left,width=500,height=450)
Forms.pack(side=TOP)

Buttons = Frame(Left,width=300,height=100,bd=8,relief='raise')
Buttons.pack(side=BOTTOM)

#label

txt_title = Label(Top,width=900,font=('arial',24), text=" LIBRARY BOOK MANAGEMENT APPLICATION ")
txt_title.pack()
txt_bookname=Label(Forms,text="Booktitle:", font=('arial',18),bd=15)
txt_bookname.grid(row=0,stick="e")
txt_author=Label(Forms,text="Author:", font=('arial',18),bd=15)
txt_author.grid(row=1,stick="e")

txt_year=Label(Forms,text="Year:", font=('arial',18),bd=15)
txt_year.grid(row=3,stick="e")
txt_isbn=Label(Forms,text="ISBN:", font=('arial',18),bd=15)
txt_isbn.grid(row=4,stick="e")

txt_result=Label(Buttons)
txt_result.pack(side=TOP)

#Entry

bookname=Entry(Forms,textvariable=BOOKTITLE, 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=3,column=1)
isbn=Entry(Forms,textvariable=ISBN, width=30)
isbn.grid(row=4,column=1)


#buttons
btn_update=Button(Buttons,width=10,text="Add",command=Create)
btn_update.pack(side=LEFT)
btn_create=Button(Buttons,width=10,text="Read",command=Read)
btn_create.pack(side=LEFT)
btn_delete=Button(Buttons,width=10,text="Update",command=Update)
btn_delete.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

scrollbary= Scrollbar(Right, orient=VERTICAL)
scrollbarx=Scrollbar(Right, orient=HORIZONTAL)

tree = ttk.Treeview(Right)
tree["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=150)

tree.pack()

root.mainloop()

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.