-
Notifications
You must be signed in to change notification settings - Fork 0
/
Python Ultimate Student interface.py
551 lines (420 loc) · 18 KB
/
Python Ultimate Student interface.py
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
#openai
#gradio
#custom tkinter
#SpeechRecognition
#pyttsx3
#pyaudio
#webbrowser
#threading
'''
Login page using tkinter
first interface with greeting name based on data base
passing name to functions
each profiles greets with passed name (optional)
multiple profiles chatting with ui made with gradio
'''
'''import tkinter as tk
import gradio as gr
# Define the function that will be called when the button is clicked
def open_gradio_interface():
# Define your gradio interface here, replacing the placeholders with your actual function, inputs, and outputs
iface = gr.Interface(fn=my_gradio_function, inputs="my_input", outputs="my_output")
# Launch the gradio interface
iface.launch()
def my_gradio_function():
print("Hello world")
# Create the tkinter window
window = tk.Tk()
# Create the button and add it to the window
button = tk.Button(window, text="Open Gradio Interface", command=open_gradio_interface)
button.pack()
# Start the tkinter event loop
window.mainloop()
'''
#---------------------------------------------------------------
'''
import gradio as gr
import webbrowser
import tkinter as tk
import threading
# Define the Gradio program
def greet(name):
return "Hello, " + name + "!"
iface = gr.Interface(greet, "text", "text", title="Greeting App", description="Enter your name to get a greeting")
# Define the function that launches the Gradio program in a browser
def launch_gradio():
def run_gradio():
iface.launch()
thread = threading.Thread(target=run_gradio)
thread.start()
print("Click")
# Create a Tkinter window with a button
window = tk.Tk()
window.title("Gradio Launcher")
button = tk.Button(window, text="Launch Gradio", command=launch_gradio)
button.pack()
# Start the Tkinter event loop
window.mainloop()
'''
#---------------------------------------------------------------
'''
import tkinter as tk
import gradio as gr
import webbrowser
def say_hello(name):
return "Hello, " + name + "!"
def open_gradio():
iface = gr.Interface(fn=say_hello, inputs="text", outputs="text", title="Gradio Hello Program")
iface.launch(share=True)
root = tk.Tk()
root.title("Open Gradio Hello Program")
button = tk.Button(root, text="Open Gradio", command=open_gradio)
button.pack()
root.mainloop()
'''
#-----------------------------------------------------------------------------------------------------------------
from tkinter import *
from tkinter import messagebox
import ast
import datetime
#_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-Login Database_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
import pandas as pd
# Define file names
password_file = "C:/Users/DELL/Desktop/PPS Code projects/Final project/Student interface/passwordsnew.csv"
name_file = "C:/Users/DELL/Desktop/PPS Code projects/Final project/Student interface/namesnew.csv"
# Load data from files
passwords_df = pd.read_csv(password_file, index_col="Roll No.")
names_df = pd.read_csv(name_file, index_col="Roll No.")
# Define file names
password_file = "C:/Users/DELL/Desktop/PPS Code projects/Final project/Student interface/passwords -t.csv"
name_file = "C:/Users/DELL/Desktop/PPS Code projects/Final project/Student interface/names -t.csv"
# Load data from files
passwords_dft = pd.read_csv(password_file, index_col="Sapid")
names_dft = pd.read_csv(name_file, index_col="Sapid")
#_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-Login Logic_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
def teacherlog():
Sapid = sapin.get()
password = pw.get()
# Check if password is correct
if password != str(passwords_dft.loc[Sapid, "Password"]):
print("Invalid Password")
messagebox.showerror("Invalid", "Invalid password entered")
return
# If login successful, print student name-----------------------------
print("Login Successful. Welcome, ", names_dft.loc[Sapid, "Name"])
messagebox.showinfo("Success!", "Login successful")
f=open('C:/Users/DELL/Desktop/PPS Code projects/Final project/Temp.txt','w+')
f.write(Sapid)
f.close()
appt()
def login():
roll_no = sapin.get()
password = pw.get()
print(roll_no,password)
# Check if roll no. exists in passwords_df
if roll_no=="admin" and password=="admin123":
root.withdraw()
subprocess.Popen(["python", "C:/Users/DELL/Desktop/PPS Code projects/Final project/App/adminconsole.py"])
elif roll_no in passwords_dft.index:
teacherlog()
# Check if roll no. exists in passwords_df
elif roll_no not in passwords_df.index and roll_no not in passwords_dft.index:
print("Invalid Roll No.")
messagebox.showerror("Invalid", "Invalid SAP ID entered")
return
# Check if password is correct
elif password != str(passwords_df.loc[roll_no, "Password"]):
print("Invalid Password")
messagebox.showerror("Invalid", "Invalid password entered")
return
# If login successful, print student name-----------------------------
print("Login Successful. Welcome, ", names_df.loc[roll_no, "Name"])
messagebox.showinfo("Success!", "Login successful")
f=open('C:/Users/DELL/Desktop/PPS Code projects/Final project/Temp.txt','w+')
f.write(roll_no)
f.close()
app()
#-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-Signup Query_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
import subprocess
def run_script():
root.withdraw()
# Replace "other_script.py" with the filename of the other Python script
subprocess.Popen(["python", "C:/Users/DELL/Desktop/PPS Code projects/Final project/Signup window/Signup_stu.py"])
#_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-Admin Authenticate_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
def run_scriptt():
root.withdraw()
# Replace "other_script.py" with the filename of the other Python script
subprocess.Popen(["python", "C:/Users/DELL/Desktop/PPS Code projects/Final project/Signup window/Signup_tea.py"])
def login_prompt():
# Create the login window
login_window = Tk()
login_window.title("Admin Authorization")
login_window.geometry("+600+400")
login_window.config(bg="white")
login_window. resizable(False,False)
h=Label(login_window,text='Authenticate',fg='#d2232a',bg='white',font=('Bahnschrift',19,'bold'))
h.grid(row=0, column=0, padx=0, pady=10)
def on_entry(e):
# Move focus to next Entry widget
e.widget.tk_focusNext().focus()
def on_focus(event):
username_entry = event.widget
if username_entry.get() == 'Username':
username_entry.delete(0, 'end')
def on_focus_o(event):
password_entry=event.widget
if username_entry.get() =="" :
username_entry.insert(0, 'Username')
username_entry.config(show="")
# Create the username and password labels and entry fields
username_entry = Entry(login_window,width=25, fg="black", border=0, bg="white", font=('Bahnschrift',10))
username_entry.grid(row=1, column=0, padx=10, pady=0)
username_entry.bind("<FocusIn>", on_focus)
username_entry.bind("<FocusOut>", on_focus_o)
username_entry.bind("<Return>", on_entry)
username_entry.insert(0,'Username')
Frame(login_window,width=200,height=2,bg='black').grid(row=2, column=0, padx=5, pady=0)
def on_enter(e):
# Execute function when Return key is pressed in the last Entry widget
print("Function executed!")
submit_login()
def onto_focus(event):
pw = event.widget
if pw.get() == 'Password':
pw.delete(0, 'end')
pw.config(show='*')
def out_focus(event):
pw=event.widget
if pw.get() =="" :
pw.insert(0, 'Password')
pw.config(show="")
Frame(login_window,width=200,height=2,bg='white').grid(row=3, column=0, padx=5, pady=10)
password_entry = Entry(login_window, width=25, fg="black", border=0, bg="white", font=('Bahnschrift',10))
password_entry.grid(row=4, column=0, padx=0, pady=0)
password_entry.insert(0,'Password')
password_entry.bind("<FocusIn>", onto_focus)
password_entry.bind("<FocusOut>", out_focus)
password_entry.bind("<Return>", on_enter)
Frame(login_window,width=200,height=2,bg='black').grid(row=5, column=0, padx=5, pady=0)
# Create the submit button
def submit_login():
username = username_entry.get()
password = password_entry.get()
if username == "admin" and password == "admin123":
print("Login successful!")
messagebox.showinfo("Authorized", "Authentication Successful")
login_window.destroy()
run_scriptt()
else:
messagebox.showerror("Unauthorized", "Authentication Failed")
print("Authentication Failed")
return
submit_button = Button(login_window,width=29,pady=7,text='Authorize',bg='#d2232a',fg='white',border=0,cursor='hand2', command=submit_login)
submit_button.grid(row=6, column=0, columnspan=2, padx=5, pady=10)
# Function to change button color on hover
def on_hover(event):
submit_button['background'] = '#9f1a1f'
submit_button['foreground'] = 'white'
submit_button['font'] = 'Bahnschrift 9 underline'
# Function to change button color when not hovering
def off_hover(event):
submit_button['background'] = '#d2232a'
submit_button['foreground'] = 'white'
submit_button['font'] = 'Bahnschrift 9'
# Bind hover events to button
submit_button.bind('<Enter>', on_hover)
submit_button.bind('<Leave>', off_hover)
# Run the login window
login_window.mainloop()
'''def open_window():
# Create a new window
new_window = Toplevel(root)
new_window.config(bg='white')
# Create label and buttons
label = Label(new_window,text='Are you a',fg='#d2232a',bg='white',font=('Bahnschrift',13,'bold'))
label.pack(padx=10, pady=5)
a1=Button(new_window,width=29,pady=7,text='Teacher',bg='#d2232a',fg='white',border=0,cursor='hand2')
a1.pack(padx=5,pady=10)
# Function to change button color on hover
def on_hover(event):
a1['background'] = '#9f1a1f'
a1['foreground'] = 'white'
a1['font'] = 'Bahnschrift 9 underline'
# Function to change button color when not hovering
def off_hover(event):
a1['background'] = '#d2232a'
a1['foreground'] = 'white'
a1['font'] = 'Bahnschrift 9'
# Bind hover events to button
a1.bind('<Enter>', on_hover)
a1.bind('<Leave>', off_hover)
label = Label(new_window, text="OR",bg="white")
label.pack(padx=10, pady=5)
#Close query window---------------------------------
def close_window():
new_window.withdraw()
a2=Button(new_window,width=29,pady=7,text='Student',bg='#d2232a',fg='white',border=0,cursor='hand2',command=run_script)
a2.config(command=lambda: (close_window(), run_script()))
a2.pack(padx=5,pady=10)
# Function to change button color on hover
def on_hover(event):
a2['background'] = '#9f1a1f'
a2['foreground'] = 'white'
a2['font'] = 'Bahnschrift 9 underline'
# Function to change button color when not hovering
def off_hover(event):
a2['background'] = '#d2232a'
a2['foreground'] = 'white'
a2['font'] = 'Bahnschrift 9'
# Bind hover events to button
a2.bind('<Enter>', on_hover)
a2.bind('<Leave>', off_hover)'''
def open_window():
frme=Frame(root,width=350,height=320,bg="white")
frme.place(x=560,y=180)
# Create label and buttons
label = Label(frme,text='Are you a',fg='#d2232a',bg='white',font=('Bahnschrift',13,'bold'))
label.pack(padx=10, pady=5)
a1=Button(frme,width=29,pady=7,text='Teacher',bg='#d2232a',fg='white',border=0,cursor='hand2',command=login_prompt)
a1.pack(padx=5,pady=10)
# Function to change button color on hover
def on_hover(event):
a1['background'] = '#9f1a1f'
a1['foreground'] = 'white'
a1['font'] = 'Bahnschrift 9 underline'
# Function to change button color when not hovering
def off_hover(event):
a1['background'] = '#d2232a'
a1['foreground'] = 'white'
a1['font'] = 'Bahnschrift 9'
# Bind hover events to button
a1.bind('<Enter>', on_hover)
a1.bind('<Leave>', off_hover)
label2 = Label(frame, text="",bg="#5a5d5d",font=('Bahnschrift',1))
label2.pack(padx=0, pady=0)
label = Label(frme, text="OR",bg="white")
label.pack(padx=10, pady=5)
#Close query window---------------------------------
def close_window():
root.withdraw()
a2=Button(frme,width=29,pady=7,text='Student',bg='#d2232a',fg='white',border=0,cursor='hand2',command=run_script)
a2.config(command=lambda: (close_window(), run_script()))
a2.pack(padx=5,pady=10)
# Function to change button color on hover
def on_hover(event):
a2['background'] = '#9f1a1f'
a2['foreground'] = 'white'
a2['font'] = 'Bahnschrift 9 underline'
# Function to change button color when not hovering
def off_hover(event):
a2['background'] = '#d2232a'
a2['foreground'] = 'white'
a2['font'] = 'Bahnschrift 9'
# Bind hover events to button
a2.bind('<Enter>', on_hover)
a2.bind('<Leave>', off_hover)
#-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-App_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
'''def app():
root.withdraw()
roll_no = sapin.get()
app=Toplevel(root)
app.title("MPSTME Student Interface")
app.geometry('925x500+300+200')
app.config(bg="white")
sapid=sapin.get()
Label(app,text='Hello '+names_df.loc[roll_no, "Name"], bg='#fff',font=('Bahnschrift',43,'bold')).pack(expand=True)'''
def app():
root.withdraw()
# Replace "other_script.py" with the filename of the other Python script
subprocess.Popen(["python", "C:/Users/DELL/Desktop/PPS Code projects/Final project/App/App_Stu.py"])
def appt():
root.withdraw()
# Replace "other_script.py" with the filename of the other Python script
subprocess.Popen(["python", "C:/Users/DELL/Desktop/PPS Code projects/Final project/App/App_Tea.py"])
#_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-Login window UI_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
root=Tk()
root. title('Login')
root.geometry('925x500+300+200')
root.configure(bg="#fff")
root. resizable(False,False)
#Image-----------------------------------
img=PhotoImage(file='C:/Users/DELL/Desktop/PPS Code projects/Final project/Student interface/bg login.png')
Label(root,image=img,bg='white').place(x=0,y=0)
#Login Frame-----------------------------
frame=Frame(root,width=350,height=320,bg="white")
frame.place(x=520,y=100)
#Header Text-----------------------------
head=Label(frame,text='Sign In',fg='#d2232a',bg='white',font=('Bahnschrift',23,'bold'))
head.place(x=125,y=10 )
#SapID-----------------------------------
def on_enter(e):
# Move focus to next Entry widget
e.widget.tk_focusNext().focus()
def on_focus_in_sap(event):
sapin = event.widget
if sapin.get() == 'SapID':
sapin.delete(0, 'end')
def on_focus_out_sap(event):
pw=event.widget
if sapin.get() =="" :
sapin.insert(0, 'SapID')
sapin.config(show="")
sapin=Entry(frame, width=25, fg="black", border=0, bg="white", font=('Bahnschrift',12))
sapin.bind("<FocusIn>", on_focus_in_sap)
sapin.bind("<FocusOut>", on_focus_out_sap)
sapin.bind("<Return>", on_enter)
sapin.place(x=30,y=85)
sapin.insert(0,'SapID')
Frame(frame,width=295,height=2,bg='black').place(x=25,y=112)
#Password--------------------------------
def on_submit(e):
# Execute function when Return key is pressed in the last Entry widget
print("Function executed!")
login()
def on_focus_in(event):
pw = event.widget
if pw.get() == 'Password':
pw.delete(0, 'end')
pw.config(show='*')
def on_focus_out(event):
pw=event.widget
if pw.get() =="" :
pw.insert(0, 'Password')
pw.config(show="")
pw=Entry(frame, width=25, fg="black", border=0, bg="white", font=('Bahnschrift',12))
pw.bind("<FocusIn>", on_focus_in)
pw.bind("<FocusOut>", on_focus_out)
pw.bind("<Return>", on_submit)
pw.place(x=30,y=155)
pw.insert(0,'Password')
Frame(frame,width=295,height=2,bg='black').place(x=25,y=182)
#Buton-----------------------------------
ab=Button(frame,width=39,pady=7,text='Sign in',bg='#d2232a',fg='white',border=0,cursor='hand2',command=login)
ab.place(x=35,y=209)
# Function to change button color on hover
def on_hover(event):
ab['background'] = '#9f1a1f'
ab['foreground'] = 'white'
ab['font'] = 'Bahnschrift 9 underline'
# Function to change button color when not hovering
def off_hover(event):
ab['background'] = '#d2232a'
ab['foreground'] = 'white'
ab['font'] = 'Bahnschrift 9'
# Bind hover events to button
ab.bind('<Enter>', on_hover)
ab.bind('<Leave>', off_hover)
#Signup----------------------------------
# Create the hyperlink text
# Create the hyperlink-like label
def on_enter(e):
text.config(font=("Bahnschrift Underline", 10, "underline"), fg="#85161a")
def on_leave(e):
text.config(font=("Bahnschrift Underline", 10), fg="#d2232a")
text = Label(frame, text="Signup for a new account", font=("Bahnschrift Underline", 10), height=1, cursor="hand2", fg="#d2232a",bg="white")
text.place(x=25, y=260)
# Bind the hyperlink text to open a new window when clicked
text.bind("<Enter>", on_enter)
text.bind("<Leave>", on_leave)
text.bind("<Button-1>", lambda event: open_window())
root.mainloop()