-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.py
45 lines (33 loc) · 1.11 KB
/
gui.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
from tkinter import *
from weather import send_temperature_graph_email , get_weather
def on_send_email():
to_email = e1.get()
city = e2.get()
if not city:
print("Please Enter city")
if to_email and city:
try:
send_temperature_graph_email(to_email , city)
get_weather(city)
status_label.config(text="Email sent successfully.", fg="green")
except Exception as e:
status_label.config(text=f"Error sending email: {str(e)}", fg="red")
else:
print("Please enter an email address.")
root = Tk()
root.geometry("450x300")
root.title('Weather over email')
Label(root, text="Weather Update over Email !!").pack(pady=10)
frame = Frame(root)
frame.pack(pady=10)
Label(frame, text="Enter email").pack(side=LEFT)
e1 = Entry(frame)
e1.pack(side=LEFT, padx=5)
Label(frame, text="Enter city").pack(side=LEFT)
e2 = Entry(frame)
e2.pack(side=LEFT, padx=5)
button = Button(root, text='Send email', width=50, command=on_send_email)
button.pack(pady=20)
status_label = Label(root, text="")
status_label.pack(pady=10)
root.mainloop()