Python Programming and Django Overview
Python Programming and Django Overview
INTRODUCTION
1.1. About Python
Python was conceived in the late 1980s as a successor to the ABC language. Python 2.0,
released in 2000, introduced features like list comprehensions and a garbage
collection system capable of collecting reference cycles. Python 3.0, released in 2008,
was a major revision of the language that is not completely backward-compatible, and
much Python 2 code does not run unmodified on Python 3.
The Python 2 language, i.e. Python 2.7.x, is "sunsetting" on January 1, 2020 (after
extension; first planned for 2015), and the Python team of volunteers will not fix security
issues, or improve it in other ways after that date. With the end-of-life, only Python 3.5.x
and later will be supported.
Python interpreters are available for many operating systems. A global community of
programmers develops and maintains CPython, an open source reference implementation.
A non-profit organization, the Python Software Foundation, manages and directs
resources for Python and CPython development.
The Python interpreter has a number of built-in functions. They are loaded
automatically as the interpreter starts and are always available. For example, print()
1
and input() for I/O, number conversion functions int(),float(),complex(), data type
conversions list(),tuple(), set(), etc.
Built-in modules are written in C and integrated with the Python interpreter. Each built-in
module contains resources for certain system-specific functionalities such as OS
management, disk IO, etc. The standard library also contains many Python scripts (with
the .py extension) containing useful utilities.
2
1.2.3. Overview of DJANGO:
Django is a high-level Python Web framework that encourages rapid
development and clean, pragmatic design. Built by experienced developers, it takes care
of much of the hassle of Web development, so you can focus on writing your app
without needing to reinvent the wheel. It’s free and open source.
[Link] Files used in DJANGO
● [Link] – this is a file that will store most configuration settings for your django
project.
● [Link]– this file is for resolving http request/response for our web app.
● [Link] – it is the file where you will define the database models. Django will
automatically translate models defined here into database tables.
● [Link] – this file stores the information about locations where URLs of your django
project have been declared. A django project identifies a URL related to its web
application if this file [Link] somehow points to it.
● [Link] – this is a file in the (outer) project folder. It is used to manage the project
and perform some administrative tasks such as running built-in server and many
others.
● _init_.py – this is a file inside every package/sub-package of python. Without this file
the folder is not treated as an importable package.
● [Link] – this is used for application production of your project.
● [Link] – it is a configuration file for the built-in django admin app.
● [Link] – it is a configuration file for the app itself.
● [Link] – this file is for our app-specific tests.
● migrations/ – this folder keep track of changes in [Link] file and updates database
accordingly.
● templates/ –this component is responsible for the presentation of data/webpage to the
user/client.
1.2.4 Overview of Files concept
3
[Link] File handling:
File is a named location on disk to store related information. It is used to permanently
store data in a non-volatile memory (e.g. hard disk).Since, random access memory
(RAM) is volatile which loses its data when computer is turned off, we use files for
future use of the [Link] we want to read from or write to a file we need to open it
first. When we are done, it needs to be closed, so that resources that are tied with the
file are [Link], in Python, a file operation takes place in the following order.
[Link] File-modes:
4
Text Binary
File File Description Notes
Mode Mode
‘r’ ‘rb’ Read only File must exist already, otherwise python raises I/O error.
If the file does not exist, file is created.
‘w’ ‘wb’ Write only If the file is exists, python will truncate existing data and
over write in the file.
File opens in write only mode.
‘a’ ‘ab’ append If the exists, the data in the file is retained and new data
being written will be appended to the end.
‘r+b’ Read and File must exist, otherwise error is raised.
‘r+’ or
write Both reading and writing operations can take place.
‘rb+’
File is created if does not exist.
‘w+b’ Write and
‘w+’ or If file exists, file is truncated.
read
‘wb+’ Both reading and writing operations can take place.
File is created if does not exist.
‘a+b’ Write and If file exists, file’s existing data is retained, new data is
‘a+’ or
read appended.
‘ab+’
Both reading and writing operations can take place.
5
number of data. If size parameter is not specified, it reads and returns up to the end of the
file.
>>> f = open("[Link]",'r')
>>>[Link](4) # read the first 4 data
'This'
Alternately, we can use readline() method to read individual lines of a file. This method
reads a file till the newline, including the newline character.
>>>[Link]()
'This is my first file\n'
Lastly, the readlines() method returns a list of remaining lines of the entire file. All these
reading method return empty values when end of file (EOF) is reached.
>>>[Link]()
['This is my first file\n', 'This file\n', 'contains three
lines\n']
We can change our current file cursor (position) using the seek() method. Similarly, the
tell() method returns our current position (in number of bytes).
>>>[Link]() # get the current file position
56
>>>[Link](0) # bring file cursor to initial position
0
>>>print([Link]()) # read the entire file
This is my first file
This file
contains three lines
In order to write into a file in Python, we need to open it in write 'w', append 'a' or
exclusive creation 'x' [Link] need to be careful with the 'w' mode as it will overwrite
into the file if it already exists. All previous data are [Link] a string or sequence
of bytes (for binary files) is done using write() method. This method returns the number
of characters written to the file.
with open("[Link]",'w') as f:
[Link]("my first file\n")
[Link]("This file\n\n")
[Link]("contains three lines\n")
6
This program will create a new file named '[Link]' if it does not exist. If it does exist, it is
overwritten.
Python also has a method that can write all lines at the same time to a file. Python’s
“writelines()” method takes a list of lines as input and writes to a file object that is open
with write/append access. For example to write our list of all line “all_lines”, using
“writelines().
outF = open("[Link]", "w")
[Link](all_lines)
[Link]()
7
2. SYSTEM REQUIREMENTS
● RAM: Minimum 1 GB
8
3. OBJECTIVE OF THE PROJECT
The Hostel Management System has been developed to overcome the problems
faced by the practice of manual system. This software will terminate all the drawbacks of
the existing system. This software avoids the errors while entering data by the user. It also
provides error messages while entering invalid data. The main objective of the project is
to manage the details of hostel, room, bed, student registration. This project is built at
administrative end and thus it can be used only by the administrator
. It provides the searching facilities based on various factors such as hostel, bed,
student, student registration. Hostel management system also manage the applications of
leave of each students with reason and time of exit and time of return. The existing
system is a manually maintained. All the hostel records like allocated beds, time of exit,
in time, leave application should be maintained for each students, which is difficult to do
in the system existing.
This existing system consume more time, inaccuracy of data, errors, difficult to
update and difficult to handle data. This proposed system is a computerized version of the
existing system. This system provides easy and quick access over data than the existing
system. It is also easy to handle, user friendly, and decreases the human made errors. An
option of visitor’s information is added in this project which collects the information of
the visitors like mobile number, reason for visiting, address of the visitor and name of the
visitor.
This system uses the text files to store the information of each students which is
entered as input by the user. This project contains one text file for each purposes like for
the purpose of storing the information of students, for storing information of rooms, for
storing the leave applications, and storing the in time, out time for the students and a file
for storing the visitors information. These text file can further used for easy retrieval of
data and updating of data.
9
4. MODULES PURPOSES
10
5. SOURCE CODE
from [Link] import *
from tkinter import *
from PIL import ImageTk, Image
from tkinter import font
import os
from PIL import Image
def date():
from datetime import datetime
# current date time
now = [Link]()
t = [Link]("%H:%M")
s1 = [Link]("%H:%M,%Y-%m-%d")
s1 = str(s1)
return s1
#Main Canvas
base = Tk()
bg =
[Link](file="C:\\Users\\LL-12\\Downloads\\Hostel-management-system-main
\\Hostel-management-system-main\\[Link]")
canvas = Canvas(base,width= 1900, height= 1000)
[Link](fill= "both", expand=True)
canvas.create_image(0, 0, image=bg, anchor="nw")
G=1
def main():
global G
canvas = Canvas(base, bg='lightseagreen', height=0, width=0, borderwidth=0)
[Link](x=-1, y=100)
can = Canvas(base, bg='silver', height=675, width=1500, borderwidth=5, relief='groove')
[Link](x=320, y=105)
#Add student
def add_stud():
canvas = Canvas(base, bg='silver', height=675, width=1215)
[Link](x=320, y=105)
first_name = Label(base, text="First Name", font=("Arial 15 bold"), bg='silver',
fg="black")
first_name.place(x=400, y=150)
fir_name_entry = Entry(base, width=15, font=("Arial 15"))
fir_name_entry.place(x=400, y=180)
fir_name_entry.focus()
11
last_name = Label(base, text="Last Name", font=("Arial 15 bold"), bg="silver",
fg="black")
last_name.place(x=610, y=150)
last_name_entry = Entry(base, width=15, font=("Arial 15"))
last_name_entry.place(x=610, y=180)
father_name = Label(base, text="Father Name", font=("Arial 15 bold"), bg="silver",
fg="black")
father_name.place(x=400, y=220)
fathr_name_entry = Entry(base, width=15, font=("Arial 15"))
fathr_name_entry.place(x=400, y=250)
mother_name = Label(base, text="Mother Name", font=("Arial 15 bold"), bg="silver",
fg="black")
mother_name.place(x=610, y=220)
mther_name_entry = Entry(base, width=15, font=("Arial 15"))
mther_name_entry.place(x=610, y=250)
dob = Label(base, text="DOB", font=("Arial 15 bold"), bg="silver", fg="black")
[Link](x=400, y=300)
dob_entry = Entry(base, width=15, font=("Arial 15 bold"))
dob_entry.place(x=400, y=330)
m1 = Label(base, text="(Y-M-D)", font=("Arial 12 bold"), bg="silver", fg="black")
[Link](x=450, y=300)
contact = Label(base, text="Roll No", font=("Arial 15 bold"), bg="silver", fg="black")
[Link](x=610, y=300)
cont_entry = Entry(base, width=15, font=("Arial 15 bold"))
cont_entry.place(x=610, y=330)
message = Label(base, text="(Roll No. will be your Hostel ID)", font=("Arial 10 bold"),
bg="silver",fg="black")
[Link](x=690, y=300)
email = Label(base, text="Email", font=("Arial 15 bold"), bg="silver", fg="black")
[Link](x=400, y=370)
email_entry = Entry(base, width=15, font=("Arial 15 bold"))
email_entry.place(x=400, y=410)
address = Label(base, text="Address", font=("Arial 15 bold"), bg="silver", fg="black")
[Link](x=610, y=370)
addrs_entry = Entry(base, width=15, font=("Arial 15 bold"))
addrs_entry.place(x=610, y=410)
vehicle = Label(base, text="Health issues:", font=("Arial 15 bold"), bg="silver",
fg="black")
[Link](x=400, y=450)
vehicle_entry = Entry(base, width="15", font=("Arial 15 bold"))
vehicle_entry.place(x=400, y=490)
m2 = Label(base, text="(If any)", font=("Arial 11 bold"), bg="silver", fg="black")
[Link](x=550, y=450)
work_place = Label(base, text="Work Place/College", font=("Arial 15 bold"),
bg="silver", fg="black")
work_place.place(x=610, y=450)
place_entry = Entry(base, width="15", font=("Arial 15 bold"))
place_entry.place(x=610, y=490)
gender = Label(base, text="Gender", font=("Arial 15 bold"), bg="silver", fg="black")
[Link](x=400, y=580)
12
G=1
def selected():
global G
if [Link]() == 1:
G=1
elif [Link]() == 2:
G=2
elif [Link]() == 0:
G=0
else:
G=1
c1 = IntVar()
a = Radiobutton(base, text="Male", bg="silver", fg="black", font=("Arial 15 bold"),
variable=c1, value=1, command=selected)
b = Radiobutton(base, text="Female", bg="silver", fg="black", font=("Arial 15 bold"),
variable=c1, value=2, command=selected)
c = Radiobutton(base, text="Other", bg="silver", fg="black", font=("Arial 15 bold"),
variable=c1, value=0, command=selected)
[Link](x=490, y=580)
[Link](x=580, y=580)
[Link](x=680, y=580)
#Room availability
def available_roome():
rooms_availble = Label(base, text="Rooms Available", font=("Arial 20 bold"),
bg="lightseagreen", fg="white", padx=140)
rooms_availble.place(x=950, y=110)
x = " Room No. | Beds "
room = Label(base, text=x, font=("Arial 15 bold"), bg="dark slate grey", fg="white")
[Link](x=950, y=150)
global G
bed1 = None
bed2 = None
bed3 = None
if G == 1:
f1 = open("room_info_boys.txt","r")
bed1 = "B1"
bed2 = "B2"
bed3 = "B3"
elif G==2:
f1 = open("room_info_girls.txt","r")
bed1 = "G1"
bed2 = "G2"
bed3 = "G3"
elif G==0:
f1 = open("room_info_others.txt","r")
bed1 = "O1"
bed2 = "O2"
bed3 = "O3"
else:
13
file_name = "room_info_boys.txt"
bed1 = "B1"
bed2 = "B2"
bed3 = "B3"
all_lines = [Link]()
count = 1
rooms = []
for i in all_lines:
temp1 = str(i)
one_line = [Link](',')
if one_line[1] == bed1 and one_line[2] == bed2 and one_line[3] == bed3:
temp = []
count = 2
[Link](one_line[0])
[Link](bed1)
[Link](bed2)
[Link](bed3)
[Link](temp)
if one_line[1] != bed1 and one_line[2] == bed2 and one_line[3] == bed3:
count = 2
temp = []
[Link](one_line[0])
[Link]("NA")
[Link](bed2)
[Link](bed3)
[Link](temp)
if one_line[1] == bed1 and one_line[2] != bed2 and one_line[3] == bed3:
temp = []
count = 2
[Link](one_line[0])
[Link](bed1)
[Link]("NA")
[Link](bed3)
[Link](temp)
if one_line[1] == bed1 and one_line[2] == bed2 and one_line[3] != bed3:
temp = []
count = 2
[Link](one_line[0])
[Link](bed1)
[Link](bed2)
[Link]("NA")
[Link](temp)
if one_line[1] == bed1 and one_line[2] != bed2 and one_line[3] != bed3:
temp = []
count = 2
[Link](one_line[0])
[Link](bed1)
[Link]("NA")
[Link]("NA")
[Link](temp)
14
if one_line[1] != bed1 and one_line[2] == bed2 and one_line[3] != bed3:
temp = []
count = 2
[Link](one_line[0])
[Link]("NA")
[Link](bed2)
[Link]("NA")
[Link](temp)
if one_line[1] != bed1 and one_line[2] != bed2 and one_line[3] == bed3:
temp = []
count = 2
[Link](one_line[0])
[Link]("NA")
[Link]("NA")
[Link](bed3)
[Link](temp)
if one_line[1] != bed1 and one_line[2] != bed2 and one_line[3] != bed3:
temp = []
count = 2
[Link]("--")
[Link]("NA")
[Link]("NA")
[Link]("NA")
[Link](temp)
if count == 1:
#No room
y = "No Rooms Available"
x = Label(base, text=y, font=("Arial", 30), bg="dark slate grey", fg="white")
[Link](x=950, y=300)
else:
x1co = 1000
y1co = 200
x2co = 1250
y2co = 200
flag = 1
for i in rooms:
r_no = Label(base, text=i[0], font=("Arial", 15), bg="silver", fg="black")
r_no.place(x=x1co, y=y1co)
y = i[1] + " " + i[2] + " " + i[3]
r_bk_no = Label(base, text=y, font=("Arial", 15), bg="silver", fg="black")
r_bk_no.place(x=x2co, y=y2co)
y1co = y1co + 40
y2co = y2co + 40
count = 2
if flag >= 8:
break
flag = flag + 1
[Link]()
c1 = Canvas(base, height=4, width=1000)
[Link](x=940, y=550)
15
r1 = Label(base, text="Room No.", font=("Arial 15 bold"), bg="silver", fg="black")
[Link](x=950, y=570)
r2 = Entry(base, width=15, font=("Arial 15 bold"))
[Link](x=1050, y=570)
r3 = Label(base, text="Bed No.", font=("Arial 15 bold"), bg="silver", fg="black")
[Link](x=950, y=610)
r4 = Entry(base, width=15, font=("Arial 15 bold"))
[Link](x=1050, y=610)
r5 = Label(base, text="(B1 B2 B3)", font=("Arial 10 bold"), bg="silver", fg="black")
[Link](x=1050, y=640)
r6 = Label(base, text="( Girl = G1 )", font=("Arial 15 bold"), bg="silver", fg="black")
[Link](x=1250,y=570)
r7 = Label(base, text="( Other = O1)",font=("Arial 15 bold"), bg="silver",
fg="black")
[Link](x=1220,y=610)
def student():
global G
bed1 = None
bed2 = None
bed3 = None
file_name = None
if G == 1:
file_name = "room_info_boys.txt" #Room information[boys]
bed1 = "B1"
bed2 = "B2"
bed3 = "B3"
elif G == 2:
file_name = "room_info_girls.txt" #Room information[Girls]
bed1 = "G1"
bed2 = "G2"
bed3 = "G3"
elif G == 0:
file_name = "room_info_others.txt"
bed1 = "O1"
bed2 = "O2"
bed3 = "O3"
else:
file_name = "room_info_boys.txt"
bed1 = "B1"
bed2 = "B2"
bed3 = "B3"
f1 = open("student_info.txt", "a")
f2 = open(file_name,"a")
16
n = str(fir_name_entry.get()) + " "
b = str([Link]()).upper()
ln = str(last_name_entry.get()).lower()
f = str(fathr_name_entry.get()).lower()
m = str(mther_name_entry.get()).lower()
d = str(dob_entry.get()).lower()
add = str(addrs_entry.get()).lower()
c = str(cont_entry.get()).lower()
e = str(email_entry.get())
w = str(place_entry.get()).lower()
v = str(vehicle_entry.get()).lower()
da = date().lower()
rom = str([Link]()).lower()
[Link](
c + "," + n + ln + "," + f + "," + m + "," + d + "," + e + "," + w + "," + v + "," + da +
"," +
b + "," + rom + "," + "\n")
[Link]()
fobj = open(file_name, "r")
fdata_ls = [Link]()
[Link]()
rdate = date()
fobj = open(file_name, "w")
if b == bed1:
for oneline in fdata_ls:
if [Link](rom + ",") and oneline.__contains__(","+bed1): # write
date
new_oneline = [Link](","+bed1+",", "," + c + ",")
new_oneline2 = new_oneline.replace(",NOT,", "," + rdate + ",")
[Link](new_oneline)
else:
[Link](oneline)
else:
if b == bed2:
for oneline in fdata_ls:
if [Link](rom + ",") and oneline.__contains__(","+bed2): # write
date
new_oneline = [Link](","+bed2+"," , "," + c + ",")
new_oneline2 = new_oneline.replace(",NOT," , "," + rdate + ",")
[Link](new_oneline)
else:
[Link](oneline)
else:
for oneline in fdata_ls:
if [Link](rom + ",") and oneline.__contains__(","+bed3): # write
date
new_oneline = [Link](","+bed3+"," , "," + c + ",")
new_oneline2 = new_oneline.replace(",NOT," , "," + rdate + ",")
[Link](new_oneline)
else:
17
[Link](oneline)
[Link]()
l = Label(base, text="Student Added Successfully!!", font=("Arial 15 bold"),
bg='silver', fg="black")
[Link](x=650, y=670)
add_student = Button(base, text="Save", font=("Arial 20 bold"), bg="white",
fg="black" ,command=student)
add_student.place(x=1050, y=670)
c1 = IntVar()
a = Radiobutton(base, text="Male", bg="silver", fg="black", font=("Arial 15 bold"),
variable=c1, value=1, command=selected)
b = Radiobutton(base, text="Female", bg="silver", fg="black", font=("Arial 15 bold"),
variable=c1, value=2, command=selected)
c = Radiobutton(base, text="Other", bg="silver", fg="black", font=("Arial 15 bold"),
variable=c1, value=0, command=selected)
[Link](x=490,y=580)
[Link](x=580,y=580)
[Link](x=680,y=580)
continu = Button(base, text="Continue", font=("Arial 15 bold"), bg="white",
fg="black", command=available_roome)
[Link](x=490, y=670)
line = Canvas(base, height=670, width=0)
[Link](x=940, y=105)
#Add Room
def add_room():
canvas = Canvas(base, bg='silver', height=675, width=1210)
[Link](x=320, y=105)
h1 = Label(base, text="Add New Room", bg="dark slate grey", font=("Arial 20
bold"), fg="white", padx=500, pady=10)
[Link](x=320, y=105)
n_rm_n = Label(base, text="New Room No.", font=("Arial 20 bold"), bg="silver",
fg="black")
n_rm_n.place(x=500, y=300)
rm_n_entry = Entry(base, width=20, font=("Arial 15 bold"))
rm_n_entry.place(x=750, y=303)
gender = Label(base,text="Gender", font=("Arial 20 bold"), bg="silver", fg="black")
[Link](x=500,y=350)
global G
G=1
def selected():
global G
if [Link]() == 1:
G=1
if [Link]() == 2:
G=2
if [Link]() == 0:
G=0
18
c1 = IntVar()
19
l = Label(base, text="Room Is Already Added!", font=("Arial 25 bold"),
bg='silver', fg="black")
[Link](x=650, y=600)
[Link]()
count = 2
[Link]()
if count != 2:
q = "NOT"
f1 = open(file_name, "a")
[Link](r + "," + bed1 + "," + bed2 + "," + bed3 + "," + q + "," + "\n")
[Link]()
l = Label(base, text="ROOM Successfully Added....!", font=("Arial 25 bold"),
bg='silver', fg="black")
[Link](x=650, y=600)
ad_rm_btn = Button(base, text="Add Room", font=("Arial 20 bold"), bg="white",
fg="black", command=add)
ad_rm_btn.place(x=550, y=500)
def in_out_time():
canvas = Canvas(base, bg='silver', height=675, width=1210)
[Link](x=320, y=105)
#Out time
a = "---------------Out time---------------"
out_time_h1 = Label(base, text=a, font=("Arial 20 bold"), bg="dark slate grey",
fg="white", padx=20, pady=10)
out_time_h1.place(x=320, y=115)
out_time = Label(base, text="Enter ID", font=("Arial 20 bold"), bg="silver",
fg="black")
out_time.place(x=370, y=200)
out_time_entry = Entry(base, width=20, font=("Arial 20 bold"))
out_time_entry.place(x=520, y=200)
out_time_entry.focus()
purpose = Label(base, text="Purpose", font=("Arial 20 bold"), bg="silver",
fg="black")
[Link](x=370, y=270)
purpose_entry = Entry(base, width=20, font=("Arial 20 bold"))
purpose_entry.place(x=520, y=270)
def save1():
Id = str(out_time_entry.get())
pur1 = str(purpose_entry.get())
t = date()
f1 = open("[Link]", "a")
20
[Link](Id + "," + pur1 + "," + t + "," + "OUTTIME" + "," + "REMARK" + "\n")
[Link]()
done = Label(base, text="Successful!", font=("Arial 20 bold"), bg="silver",
fg="black")
[Link](x=900, y=300)
save1 = Button(base, text="Save", font=("Arial 20 bold"), bg="white", fg="black",
command=save1)
[Link](x=1050, y=220)
a1 = "---------------In time---------------"
in_time_h1 = Label(base, text=a1, font=("Arial 20 bold"), bg="dark slate grey",
fg="white", padx=20, pady=10)
in_time_h1.place(x=320, y=400)
in_time = Label(base, text="Enter ID", font=("Arial 20 bold"), bg="silver",
fg="black")
in_time.place(x=370, y=500)
in_time_entry = Entry(base, width=20, font=("Arial 20 bold"))
in_time_entry.place(x=680, y=500)
in_time_entry.focus()
'''in_time_h1 = Label(base, text=a1, font=("FONT"), bg="COLOR", fg="COLOR",
padx=X POSITION, pady=Y POSTION)
in_time_h1.place(x=320, y=400)
in_time = Label(base, text="Enter ID", font=("COLOR"), bg="COLOR",
fg="COLOR")
in_time.place(x=370, y=500)
in_time_entry = Entry(base, width=20, font=("Arial 20 bold"))
in_time_entry.place(x=680, y=500)
in_time_entry.focus()'''
ot_entry = Label(base, text="Outtime Entry", font=("Arial 20 bold"), bg="silver",
fg="black")
ot_entry.place(x=370, y=550)
ot_entry_entry = Entry(base, width=20, font=("Arial 20 bold"))
ot_entry_entry.place(x=680, y=550)
#Intime
def search_outtime():
s_id = str(in_time_entry.get())
fobj = open("[Link]", "r")
fdata_ls = [Link]()
count = 1
for oneline in fdata_ls:
if [Link](s_id + ",") and oneline.__contains__(",OUTTIME,"): #
write date
count = 2
y = [Link](",")
tv = StringVar()
[Link](y[2] + " " + y[3])
ot = Entry(base, width=20, textvariable=tv, font=("Arial 20 bold"))
[Link](x=680, y=550)
21
break
[Link]()
if count == 1:
tv = StringVar()
[Link]("Invalid Id")
ot = Entry(base, width=20, textvariable=tv, font=("Arial 20 bold"))
[Link](x=680, y=550)
def save2():
sel_opt = str(r_sel.get())
s_id = str(in_time_entry.get())
fobj = open("[Link]", "r")
fdata_ls = [Link]()
[Link]()
rdate = date()
count = 1
fobj = open("[Link]", "w")
for oneline in fdata_ls:
if [Link](s_id + ",") and oneline.__contains__(",OUTTIME,"): #
write date
new_oneline = [Link](",OUTTIME,", "," + rdate + ",")
new_oneline2 = new_oneline.replace(",REMARK", "," + sel_opt + ",")
[Link](new_oneline2)
count = 2
else:
[Link](oneline)
if count == 2:
done = Label(base, text="Successful...!", font=("Arial 20 bold"), bg="silver",
fg="black")
[Link](x=700, y=650)
if count == 1:
done = Label(base, text="Please Give Correct Information", font=("Arial 20
bold"), bg="silver", fg="black")
[Link](x=600, y=650)
[Link]()
sear_ot = Button(base, text="Search Outtime", font=("Arial 18 bold"), bg="white",
command=search_outtime)
sear_ot.place(x=1050, y=520)
save2 = Button(base, text="Save", font=("Arial 20 bold"), bg="white", fg="black",
command=save2)
[Link](x=1050, y=650)
r_sel = StringVar(base)
ls = ['Before Time', 'On Time', 'Late']
r_sel.set(ls[0])
remark = OptionMenu(base, r_sel, *ls)
[Link](width=20, font=("Arial 15 bold"), fg="black")
[Link](x=680, y=610)
22
#Visitor's information
def visitor():
canvas = Canvas(base, bg='silver', height=675, width=1210)
[Link](x=320, y=105)
h1 = Label(base, text="Visitor's Information", bg="dark slate grey", font=("Arial 20
bold"), fg="white", padx=480, pady=10)
[Link](x=320, y=105)
v_name = Label(base, text="Name", font=("Arial 20 bold"), bg="silver", fg="black")
v_name.place(x=350, y=200)
v_name_entry = Entry(base, width=20, font=("Arial 20 bold"))
v_name_entry.place(x=500, y=200)
v_contact = Label(base, text="Contact", font=("Arial 20 bold"), bg="silver",
fg="black")
v_contact.place(x=350, y=300)
v_contact_entry = Entry(base, width=20, font=("Arial 20 bold"))
v_contact_entry.place(x=500, y=300)
v_reason = Label(base, text="Reason", font=("Arial 20 bold"), bg="silver",
fg="black")
v_reason.place(x=350, y=400)
v_reason_entry = Entry(base, width=20, font=("Arial 20 bold"))
v_reason_entry.place(x=500, y=400)
v_address = Label(base, text="Address", font=("Arial 20 bold"), bg="silver",
fg="black")
v_address.place(x=350, y=500)
v_address_entry = Entry(base, width=20, font=("Arial 20 bold"))
v_address_entry.place(x=500, y=500)
st_name = Label(base, text="Student Name", font=("Arial 20 bold"), bg="silver",
fg="black")
st_name.place(x=850, y=200)
st_name_entry = Entry(base, width=15, font=("Arial 20 "))
st_name_entry.place(x=1100, y=200)
def search():
def reset():
[Link]()
st_name_entry.delete(0, END)
st_name_entry.place(x=1100, y=200)
def add_visitor():
vn = str(v_name_entry.get())
vcon = str(v_contact_entry.get())
vr = str(v_reason_entry.get())
vadd = str(v_address_entry.get())
sn = str(st_name_entry.get())
d = str(date())
fp = open("visitor_info.txt", "a")
[Link](sn + "," + vn + "," + vcon + "," + vr + "," + vadd + "," + d + "," + "\n")
[Link]()
s = Label(base, text="Successful!", font=("Arial 20 bold"), bg="silver",
fg="Black", padx=100)
[Link](x=950, y=650)
23
reset_btn = Button(base, text="Reset", font=("Arial 20 bold"), command=reset)
reset_btn.place(x=1200, y=280)
s_n = str(st_name_entry.get())
fobj = open("student_info.txt", "r")
fdata_ls = [Link]()
count = 1
for oneline in fdata_ls:
if oneline.__contains__("," + s_n + ","):
# write date
count = 2
y = [Link](",")
tv = StringVar()
[Link](y[11])
ot_name = Label(base, text="Room No.", font=("Arial 20 bold"), bg="silver")
ot_name.place(x=850, y=400)
ot = Entry(base, width=15, textvariable=tv, font=("Arial 20 bold"),
justify=CENTER)
[Link](x=1100, y=400)
add_btn = Button(base, text="Add Visitor", font=("Arial 20 bold"),
command=add_visitor)
add_btn.place(x=1000, y=500)
break
[Link]()
if count == 1:
tv = StringVar()
[Link]("Invalid Name")
ot = Entry(base, width=15, textvariable=tv, font=("Arial 20 bold"), fg="red")
[Link](x=1100, y=200)
24
all_lines = [Link]()
for i in all_lines:
temp = str(i)
one_line = [Link](',')
t = []
[Link](one_line[11])
[Link](one_line[1])
[Link](one_line[0])
[Link](one_line[6])
[Link](t)
x1co = 800
y1co = 200
x2co = 900
x3co = 1160
x4co = 1380
flag = 1
for i in students:
y=i
c=0
while c <= 2:
label = Label(base, text=y[0], font=("Arial 15 bold"), bg="silver", fg="black")
[Link](x=x1co, y=y1co)
label2 = Label(base, text=y[1], font=("Arial 15 bold"), bg="silver", fg='black')
[Link](x=x2co, y=y1co)
label3 = Label(base, text=y[2], font=('Arial 15 bold'), bg="silver", fg='black')
[Link](x=x3co, y=y1co)
label4 = Label(base, text=y[3], font=("Arial 15 bold"), bg="silver",
fg="black")
[Link](x=x4co, y=y1co)
c=c+1
y1co = y1co + 50
if flag > 8:
break
25
for i in all_lines:
temp = str(i)
one_line = [Link](',')
if one_line[11] == r_no:
temp = []
[Link](one_line[10])
[Link](one_line[1])
[Link](one_line[0])
[Link](one_line[6])
r_info.append(temp)
h1 = Label(base, text=" Information Of Students ",
font=("Arial 20 bold"), bg="dark slate grey",fg="white", padx=100, pady=5)
[Link](x=720, y=250)
h = "Bed No. Name Contact Workplace "
h2 = Label(base, text=h, font=("Arial 20 bold"), bg="dark orange", fg="white")
[Link](x=723, y=300)
x1co = 750 #Room no
y1co = 400
x2co = 855 #name
x3co = 1068 #phone
x4co = 1250 #Workplace
flag = 1
for i in r_info:
y=i
c=0
while c <= 2:
label = Label(base, text=y[0], font=("Arial 15 bold"), bg="silver",
fg="black")
[Link](x=x1co, y=y1co)
label2 = Label(base, text=y[1], font=("Arial 15 bold"), bg="silver",
fg='black')
[Link](x=x2co, y=y1co)
label3 = Label(base, text=y[2], font=('Arial 15 bold'), bg="silver",
fg='black')
[Link](x=x3co, y=y1co)
label4 = Label(base, text=y[3], font=("Arial 15 bold"), bg="silver",
fg="black")
[Link](x=x4co, y=y1co)
c=c+1
y1co = y1co + 100
if flag > 2:
break
search_btn = Button(base, text="Search", font=("Arial 20 bold"),
command=search)
search_btn.place(x=1200, y=140)
stud_info = Button(base, text="Information Of All Students", wraplength=180,
justify=CENTER, font=("Arial 20 bold"), padx=50, pady=1, command=all_girl_info)
stud_info.place(x=400, y=200)
stud_room_wise = Button(base, text="Room Info", font=("Arial 20 bold"), padx=60,
pady=5, command=room_wise)
26
stud_room_wise.place(x=400, y=400)
line = Canvas(base, height=680, width=5)
[Link](x=710, y=105)
27
current_date = date()
fopen = open("leave_applications.txt", "a")
[Link](i + "," + n + "," + r + "," + m + "," + reas + "," + current_date + "," + rdate
+ "," + "\n")
[Link]()
success = Label(base, text="Submit Successfully..!", font=("Arial 20 bold"),
fg="Black", bg="silver")
[Link](x=700, y=700)
submit = Button(base, text="Submit", font=("Arial 20 bold"), fg="black",
command=leave_info)
[Link](x=700, y=600)
28
key = str(pass_entry.get())
if id == "Sagar" and key == "sagar@123":
main()
else:
user_entry.focus()
user_entry.delete(0, END)
pass_entry.delete(0, END)
fail = Label(base, text="Wrong Username Or Password...!", font=("Arial 30
bold"),bg="silver", fg="red")
[Link](x=450, y=540)
image_path = "[Link]"
image = PhotoImage(file=image_path)
login_btn = Button(base, image=image,text='Login', font=("Arial 25 bold"),
fg="black",compound= LEFT,command=login)
login_btn.place(x=650, y=440)
[Link]()
29
6. RESULTS AND DISCUSSION
6.1. Results:
Login:
Home Page:
30
Add Student:
Rooms Available:
31
Add New Room:
Out Time:
32
In Time:
Visitor’s Information:
33
Information of Students:
Room Information:
34
Leave Application:
Text Files:
Student Information:
35
In and Out Time:
Leave Application:
36
6.2. Discussion
● Error-Free administration
● Offline program
37
7. CONCLUSION AND FUTURE ENHANCEMENT
7.1. Conclusion
After completing this project, sure the problems in the existing system would be
overcome. The “HOSTEL MANAGEMENT SYSTEM” process was made computerized
to reduce human errors and to increase efficiency. The main focus of this project is to
reduce human efforts. The maintenance of the records is made efficient, as all the records
are stored in various text files, through which the data can be retrieved easily. Several
User friendly coding have also developed. We have made efforts to change the existing
system into more developed by adding code to fill time by automatic. The data is stored
in the text which will be easy to retrieve the information and reading purpose.
The warden is given a unique id so He/she can access their account seamlessly.
This improves the efficiency of the program. The problems, which existed in the earlier
system, have been removed to a large extent. And it is expected that this project will go a
long way in satisfying user’s requirements.
38
Reusability is possible as and when required in this application. We can
update it in the next version. Reusable software reduces design, coding and testing cost by
amortizing effort over several designs. Reducing the amount of code also simplifies
understanding, which increases the likelihood that the code is correct.
• Understandability
A method is understandable if someone other than the creator of the
method can understand the code (as well as the creator after a time lapse). We use the
method, which is small and coherent, to accomplish this.
• Cost-effectiveness
Its cost is under the budget and made within a given time period. It is
desirable to aim for a system with a minimum cost subject to the condition that it must
satisfy the entire requirement. Scope of this document is to put down the requirements,
clearly identifying the information needed by the user, the source of the information and
outputs expected from the system.
39
8. BIBLIOGRAPHY
1. [Link]
2. [Link]
3. [Link]
4. [Link]
5. [Link]
6. [Link]
7. [Link]
8. [Link]
9. [Link]
10.Computer Science with Python, Class XII, Sumita Arora
40