-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource code
More file actions
188 lines (138 loc) · 6.13 KB
/
source code
File metadata and controls
188 lines (138 loc) · 6.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import tkinter as tk
from tkinter import messagebox
# Data Storage
students = {}
hostel_info = {
"vacant_rooms": 5,
"registered_rooms": 0,
"mess_menu": ["Breakfast: Bread, Butter, Tea", "Lunch: Dal, Rice, Sabzi", "Dinner: Roti, Sabzi"],
"wifi_passwords": {"Building 1": "wifi123", "Building 2": "wifi456", "Building 3": "wifi789"}
}
complaints = []
# Function to create the main window frame
def create_window(title, geometry):
window = tk.Tk()
window.title(title)
window.geometry(geometry)
return window
# Signup Function
def signup():
window = create_window("Signup - Girls' Hostel", "600x500")
def register_user():
name = name_entry.get()
mobile = mobile_entry.get()
roll_number = roll_entry.get()
address = address_entry.get()
password = password_entry.get()
if roll_number in students:
messagebox.showerror("Error", "Student already exists!")
else:
students[roll_number] = {
"name": name,
"mobile": mobile,
"roll_number": roll_number,
"address": address,
"password": password
}
messagebox.showinfo("Success", "Account created successfully!")
window.destroy()
tk.Label(window, text="Name", bg="white").pack(pady=10)
name_entry = tk.Entry(window)
name_entry.pack()
tk.Label(window, text="Mobile Number", bg="white").pack(pady=10)
mobile_entry = tk.Entry(window)
mobile_entry.pack()
tk.Label(window, text="College Roll Number", bg="white").pack(pady=10)
roll_entry = tk.Entry(window)
roll_entry.pack()
tk.Label(window, text="Address", bg="white").pack(pady=10)
address_entry = tk.Entry(window)
address_entry.pack()
tk.Label(window, text="Password", bg="white").pack(pady=10)
password_entry = tk.Entry(window, show="*")
password_entry.pack()
tk.Button(window, text="Create Account", command=register_user).pack(pady=20)
window.mainloop()
# Login Function
def login():
window = create_window("Login - Girls' Hostel", "600x500")
def check_login():
roll_number = roll_entry.get()
password = password_entry.get()
if roll_number in students and students[roll_number]['password'] == password:
messagebox.showinfo("Success", "Login successful!")
window.destroy()
welcome_dashboard(students[roll_number]['name'])
else:
messagebox.showerror("Error", "Invalid roll number or password!")
tk.Label(window, text="Roll Number", bg="white").pack(pady=10)
roll_entry = tk.Entry(window)
roll_entry.pack()
tk.Label(window, text="Password", bg="white").pack(pady=10)
password_entry = tk.Entry(window, show="*")
password_entry.pack()
tk.Button(window, text="Login", command=check_login).pack(pady=20)
window.mainloop()
# Welcome Dashboard
def welcome_dashboard(name):
window = create_window("Dashboard - Girls' Hostel", "800x600")
tk.Label(window, text=f"WELCOME TO GIRLS HOSTEL, {name.upper()}", font=("Arial", 16), bg="white").pack(pady=20)
tk.Button(window, text="Mess Menu", command=show_mess_menu).pack(pady=10)
tk.Button(window, text="Allot Room", command=allot_room).pack(pady=10)
tk.Button(window, text="Wi-Fi Passwords", command=show_wifi_passwords).pack(pady=10)
tk.Button(window, text="Submit Complaint", command=submit_complaint).pack(pady=10)
window.mainloop()
# Mess Menu Page
def show_mess_menu():
window = create_window("Mess Menu", "600x400")
tk.Label(window, text="Today's Mess Menu", font=("Arial", 14), bg="white").pack(pady=10)
tk.Label(window, text="\n".join(hostel_info["mess_menu"]), bg="white").pack(pady=10)
tk.Button(window, text="Close", command=window.destroy).pack(pady=10)
window.mainloop()
# Room Allotment Page
def allot_room():
window = create_window("Room Allotment", "600x400")
if hostel_info["vacant_rooms"] > 0:
hostel_info["vacant_rooms"] -= 1
hostel_info["registered_rooms"] += 1
room_number = 101 + hostel_info["registered_rooms"]
tk.Label(window, text=f"Room {room_number} allotted successfully!", font=("Arial", 14), bg="white").pack(pady=10)
else:
tk.Label(window, text="No vacant rooms available!", font=("Arial", 14), bg="white").pack(pady=10)
tk.Button(window, text="Close", command=window.destroy).pack(pady=10)
window.mainloop()
# Wi-Fi Passwords Page
def show_wifi_passwords():
window = create_window("Wi-Fi Passwords", "600x400")
tk.Label(window, text="Wi-Fi Passwords", font=("Arial", 14), bg="white").pack(pady=10)
tk.Label(window, text="\n".join([f"{building}: {password}" for building, password in hostel_info["wifi_passwords"].items()]), bg="white").pack(pady=10)
tk.Button(window, text="Close", command=window.destroy).pack(pady=10)
window.mainloop()
# Submit Complaint Page
def submit_complaint():
window = create_window("Submit Complaint", "600x400")
tk.Label(window, text="Enter your complaint below:", font=("Arial", 14), bg="white").pack(pady=10)
complaint_entry = tk.Entry(window, width=40)
complaint_entry.pack(pady=10)
def submit():
complaint = complaint_entry.get()
if complaint:
complaints.append(complaint)
messagebox.showinfo("Success", "Complaint submitted!")
window.destroy()
else:
messagebox.showerror("Error", "Please enter a complaint.")
tk.Button(window, text="Submit", command=submit).pack(pady=10)
tk.Button(window, text="Close", command=window.destroy).pack(pady=10)
window.mainloop()
# Main Function - Home Page with Background Image Loading
def main_page():
window = create_window("Hostel Management System", "400x400")
tk.Button(window, text="Login", command=login, bg="red", fg="white").pack(side="left", padx=50, pady=20)
tk.Button(window, text="Signup", command=signup, bg="blue", fg="white").pack(side="right", padx=50, pady=20)
window.mainloop()
# Start the Application Function
def start_application():
main_page() # Call main_page here
# Initiate the application
start_application()