diff --git a/WeatherApp.py b/WeatherApp.py index 467d3c9..fb73a67 100644 --- a/WeatherApp.py +++ b/WeatherApp.py @@ -1,6 +1,13 @@ import tkinter as tk import requests - +import pyttsx3 +engine= pyttsx3.init() +voices= engine.getProperty('voices') +engine.setProperty('voice',voices[1].id) +def say(word): + engine.say(word) + engine.runAndWait() + HEIGHT = 500 WIDTH = 600 @@ -30,6 +37,7 @@ def get_weather(city): weather = response.json() label['text'] = format_response(weather) + say(label['text']) @@ -47,6 +55,7 @@ def get_weather(city): entry = tk.Entry(frame, font=40) entry.place(relwidth=0.65, relheight=1) +entry.focus() button = tk.Button(frame, text="Get Weather", font=40, command=lambda: get_weather(entry.get())) button.place(relx=0.7, relheight=1, relwidth=0.3) @@ -57,4 +66,4 @@ def get_weather(city): label = tk.Label(lower_frame) label.place(relwidth=1, relheight=1) -root.mainloop() \ No newline at end of file +root.mainloop() diff --git a/WeatherApp_withicons.py b/WeatherApp_withicons.py index e21821a..64cf5ff 100644 --- a/WeatherApp_withicons.py +++ b/WeatherApp_withicons.py @@ -1,6 +1,14 @@ import tkinter as tk import requests from PIL import Image, ImageTk +import pyttsx3 +engine= pyttsx3.init() +voices= engine.getProperty('voices') +engine.setProperty('voice',voices[1].id) + +def say(word): + engine.say(word) + engine.runAndWait() app = tk.Tk() @@ -52,6 +60,7 @@ def open_image(icon): textbox = tk.Entry(frame, font=40) textbox.place(relwidth=0.65, relheight=1) +textbox.focus() submit = tk.Button(frame, text='Get Weather', font=40, command=lambda: get_weather(textbox.get())) #submit.config(font=) @@ -73,4 +82,4 @@ def open_image(icon): -app.mainloop() \ No newline at end of file +app.mainloop()