0% found this document useful (0 votes)
6 views40 pages

Python Programming and Django Overview

The document provides an overview of Python, its features, and its evolution, including the transition from Python 2 to Python 3. It also discusses Python modules, the Django framework, file handling concepts, and the development of a Hostel Management System project. The project aims to automate and improve the efficiency of managing hostel-related data, addressing issues found in manual systems.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views40 pages

Python Programming and Django Overview

The document provides an overview of Python, its features, and its evolution, including the transition from Python 2 to Python 3. It also discusses Python modules, the Django framework, file handling concepts, and the development of a Hostel Management System project. The project aims to automate and improve the efficiency of managing hostel-related data, addressing issues found in manual systems.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

INTRODUCTION
1.1. About Python

Python is an interpreted, high-level, general-purpose programming language. Created


by Guido van Rossum and first released in 1991, Python's design philosophy
emphasizes code readability with its notable use of significant whitespace. Its language
constructs and object-oriented approach aim to help programmers write clear, logical code
for small and large-scale projects.

Python is dynamically typed and garbage-collected. It supports multiple programming


paradigms, including procedural, object-oriented, and functional programming. Python is
often described as a "batteries included" language due to its comprehensive standard
library.

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.

1.2. Overview of Python modules, django and files:


1.2.1. Overview of Python Modules:

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.

In addition to built-in functions, a large number of pre-defined functions are also


available as a part of libraries bundled with Python distributions. These functions are
defined in modules. A module is a file containing definitions of functions, classes,
variables, constants or any other Python objects. Contents of this file can be made
available to any other program.

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.

[Link] Some Predefined Modules of Python:

These include trigonometric functions, representation functions,


Math logarithmic functions, angle conversion functions, etc. In addition, two
mathematical constants are also defined in this module.
Numpy is the core library for scientific computing in Python. It provides
Numpy a high-performance multidimensional array object, and tools for
working with these arrays.
Mysql Python needs a MySQL driver to access the MySQL database.
Matplotlib is a visualization library in Python for 2D plots of arrays.
matplotlib Matplotlib is a multi-platform data visualization library built on NumPy
arrays and designed to work with the broader SciPy stack.
csv Python provides a CSV module to handle CSV files. To read/write data,
you need to loop through rows of the CSV.
To handle the data flow in a file, the JSON library in Python uses
json dump() function to convert the Python objects into their
respective JSON object, so it makes easy to write data to files.
datetime The datetime module supplies classes for manipulating dates and times
in both simple and complex ways.
Functions in the random module depend on a pseudo-random number
random generator function random(), which generates a random float number
between 0.0 and 1.0.

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.

1.​ Open a file


2.​ Read or write (perform operation)
3.​ Close the file
4.​
[Link] Functions use in File Handling
Function Operation
open() To create a file
close() To close an existing file
read() Reads at most n bytes, if no n is specified, reads the entire file.
Returns the read bytes in the form of a string.
readline() Reads a line of input, if n is specified reads at most n bytes.
readlines() Reads all lines and returns them in a list.
strip() Removes leading and trailing whitespaces.
write() Write data into file.
Writelines() Writes all strings in list as lines to file referenced by <filehandle>
Seek() Move the file pointer to the desired position.
tell() It will give the present position of the file pointer.

[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.

[Link] Opening a file


​ Python has a built-in function open() to open a file. This function returns a file
object, also called a handle, as it is used to read or modify the file accordingly.
>>> f = open("[Link]") # open file in current directory
>>> f = open("C:/Python33/[Link]") # specifying full path
We can specify the mode while opening a file. In mode, we specify whether we want to
read 'r', write 'w' or append 'a' to the file. We also specify if we want to open the file in
text mode or binary [Link] default is reading in text mode. In this mode, we get
strings when reading from the file.

[Link] Reading and writing a file


​ To read a file in Python, we must open the file in reading [Link] are various
methods available for this purpose. We can use the read(size) method to read in size

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]()

[Link] Closing a file


​ When we are done with operations to the file, we need to properly close the
[Link] a file will free up the resources that were tied with the file and is done using
Python close() method. Python has a garbage collector to clean up unreferenced objects
but, we must not rely on it to close the file.
f = open("[Link]”)
# perform file operations
[Link]()

7
2. SYSTEM REQUIREMENTS

●​ Operating System: Windows 7, 8 and 10.

●​ Processor: Dual Core 1.4GHz Processor

●​ RAM: Minimum 1 GB

●​ Hard Disk Space: Minimum 750MB space required.

●​ Software: Python 3.6.5 and MySQL 5.5

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

4.1. Modules Used:


●​ tkinter
●​ PIL
●​ OS
●​ matplotlib

4.2. Modules Purposes:


●​ tkinter – The Tkinter module in Python allows us to build GUI applications
in Python
●​ PIL – PIL is an additional, free, open-source library for the Python
programming language that provides support for opening, manipulating,
and saving many different image file formats
●​ OS- This module in python provides functions for interacting with the
operating system. OS comes under python’s standard utility modules.
●​ matplotlib –is a comprehensive library for creating static, animated, and
interactive visualizations in Python

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)

#Add student's information to the txt file

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()

'''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)'''
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=750, y=350)
[Link](x=840, y=350)
[Link](x=950, y=350)
def add():
file_name = ""
bed1 = bed2 = bed3 = None
r = (rm_n_entry.get())
if G==1:
bed1 = "B1"
bed2 = "B2"
bed3 = "B3"
file_name = "room_info_boys.txt"
f2 = open(file_name, "r")
if G==2:
bed1 = "G1"
bed2 = "G2"
bed3 = "G3"
file_name = "room_info_girls.txt"
f2 = open(file_name, "r")
if G==0:
bed1 = "O1"
bed2 = "O2"
bed3 = "O3"
file_name = "room_info_others.txt"
f2 = open(file_name, "r")
all_lines = [Link]()
count = 0
for i in all_lines:
temp = str(i)
one_line = [Link](',')
if one_line[0] == r:

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)

#In and out time

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)

ser_btn = Button(base, text="Search", font=("Arial 20 bold"), command=search)


ser_btn.place(x=1000, y=280)

#Information abt students in the hostel


def view_info():
canvas = Canvas(base, bg='silver', height=675, width=1215)
[Link](x=320, y=105)
def all_girl_info():
canvas = Canvas(base, bg='silver', height=675, width=810)
[Link](x=715, y=105)
h1 = Label(base, text="Information Of Students", font=("Arial 20 bold"), bg="dark
slate grey", fg="white",padx=270, pady=5)
[Link](x=720, y=105)
h = "Room NO. Name Roll no "
h2 = Label(base, text=h, font=("Arial 20 bold"), bg="dark orange", fg="white")
[Link](x=723, y=150)
students = []
f1 = open("student_info.txt", "r")

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

#Displays room wise information of students


def room_wise():
canvas = Canvas(base, bg='silver', height=675, width=810)
[Link](x=715, y=105)
l1 = Label(base, text="Enter Room No.", font=("Arial 20 bold"), bg="silver",
fg="black")
[Link](x=750, y=150)
l1_entry = Entry(base, width=10, font=("Arial 20 bold"))
l1_entry.place(x=1000, y=150)
l1_entry.focus()
def search():
r_no = str(l1_entry.get())
f1 = open("student_info.txt", "r")
all_lines = [Link]()
r_info = []

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)

#Applying for leave


def leave_application():
canvas = Canvas(base, bg='silver', height=675, width=1210)
[Link](x=320, y=105)
h1 = Label(base, text="Leave Application", bg="dark slate grey", font=("Arial 20
bold"), fg="white", padx=485, pady=10)
[Link](x=320, y=105)
h_id = Label(base, text="Hostel ID", bg="silver", font=("Arial 20 bold"), fg="black")
h_id.place(x=400, y=200)
id_entry = Entry(base, width=15, font=("Arial 20"))
id_entry.place(x=550, y=200)
n_label = Label(base, text="Name", bg="silver", font=("Arial 20 bold"), fg="black")
n_label.place(x=800, y=200)
n_entry = Entry(base, width=20, font=("Arial 20"))
n_entry.place(x=900, y=200)
r_label = Label(base, text="Room No.", bg="silver", font=("Arial 20 bold"), fg="black")
r_label.place(x=400, y=300)
r_entry = Entry(base, width=15, font=("Arial 20"))
r_entry.place(x=550, y=300)
m_no = Label(base, text="Mobile No.", bg="silver", font=("Arial 20 bold"), fg="black")
m_no.place(x=800, y=300)
m_entry = Entry(base, width=15, font=("Arial 20"))
m_entry.place(x=950, y=300)
reason = Label(base, text="Reason For Leave", bg="silver", font=("Arial 20 bold"),
fg="black")
[Link](x=400, y=400)
reason_entry = Entry(base, width=20, font=("Arial 20"))
reason_entry.place(x=700, y=400)
return_date = Label(base, text="Return Date", bg="silver", font=("Arial 20 bold"),
fg="black")
return_date.place(x=400, y=500)
x = Label(base, text="(YEAR-DD-MM)", font=("Arial 15 bold"), bg="silver",
fg="black")
[Link](x=1000, y=500)
date_entry = Entry(base, width=18, font=("Arial 20"))
date_entry.place(x=700, y=500)
def leave_info():
i = str(id_entry.get())
n = str(n_entry.get())
r = str(r_entry.get())
m = str(m_entry.get())
reas = str(reason_entry.get())
rdate = str(date_entry.get())

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)

add_std_btn = Button(base, text=" Add Student ", font=("Arial 20 bold"), padx=15,


bg="white", command=add_stud)
add_std_btn.place(x=45, y=150)
add_new_room = Button(base, text=" Add New Room ", font=("Arial 20 bold"),
bg="white", command=add_room)
add_new_room.place(x=45, y=230)
in_ot_time = Button(base, text=" In And Outtime ", font=("Arial 20 bold"), bg="white",
command=in_out_time)
in_ot_time.place(x=45, y=310)
visitor = Button(base, text=" Visitor ", font=("Arial 20 bold"), bg="white", padx=55,
command=visitor)
[Link](x=45, y=390)
view_info = Button(base, text="View Information ", font=("Arial 20 bold"), bg="white",
command=view_info)
view_info.place(x=45, y=470)
leave_application = Button(base, text="Leave Application", font=("Arial 20 bold"),
bg="white", command=leave_application)
leave_application.place(x=45, y=550)
exit = Button(base, text="EXIT", font=("Arial 20 bold"), bg="white", padx=70,
command=quit)
[Link](x=45, y=630)

#Login Username:Sagar Password:sagar@123

username = Label(base,text="Username", font=("Arial 25 bold"), bg="silver", fg="black")


[Link](x=470, y=240)
#Username entry
user_entry = Entry(base, width=17, font=("Arial 20"))
user_entry.place(x=650, y=245)
user_entry.focus()
password = Label(base, text="Password", font=("Arial 25 bold"), bg="silver", fg="black")
[Link](x=470, y=350)
#Password entry
pass_entry = Entry(base, width=17, font="Arial 20")
pass_entry.place(x=650, y=355)
def login():
id = str(user_entry.get())

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

This software’s advantages:


●​ User friendly​

●​ It has details about each and every student​

●​ Searches whole database quickly​

●​ It’s safe and secure​

●​ Finding data becomes simple and smooth​

●​ Data can be modified easily​

●​ Error-Free administration

But this software also has disadvantages:

●​ Does not have student module

●​ 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.

7.2. Future Enhancement


​ This application can be easily implemented under various situations. We can add
new features as and when we require. Reusability is possible as and when required in this
application.
SOFTWARE SCOPE:
•​ Extensibility
​ ​ This software is extendable in ways that its original developers may not
expect. The following principles enhance extensibility like hide data structure, avoid
traversing multiple links or methods, avoid case statements on object type and distinguish
public and private operations.
•​ Reusability

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.

●​ Features can be introduced


Search bar can be introduced further for enabling a easy search and extra module
can be developed for the usage of the resident in the hostel, we can also enhance the
interface of the software which will make the user to use the software easily.

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

You might also like